Documentation Center

List commerce categories and products

Use the externalItems GraphQL query get a list of commerce categories and products.

Example request

The first sample code block illustrates a request to retrieve all the products under a specified category.

{
  externalItems(
    namespace: "SAPCommerce"
    filter: {
      context: {
        namespace: "SAPCommerce"
        id: "sunglasses",
        type: "Category"
      }
    }
  )  {
    edges {
      node {
        ... on Product {
          identity  {
            id
          }
          title
          price {
            formattedValue
          }
        }
      }
    }
  }
}

Example response

The second code block illustrates the corresponding response with the requested data for each product.

{
  "data": {
    "externalItems": {
      "edges": [
        {
          "node": {
            "identity": {
              "id": "30404"
            },
            "title": "Shades Von Zipper Papa G black gloss black gloss/grey",
            "price": {
              "formattedValue": "£67.96"
            }
          }
        },
        {
          "node": {
            "identity": {
              "id": "300044617"
            },
            "title": "Shades Anon Convict black fade grey gradient",
            "price": {
              "formattedValue": "£67.96"
            }
          }
        }
      ]
    }
  }
}