GraphQL API

This document gives an overview of GraphQL API.

The commercetools platform provides a GraphQL API. It currently supports following entities:

You can access the GraphQL endpoint with following URL:

https://api.commercetools.com/{projectKey}/graphql

It accepts POST requests with following fields in a JSON body:

Here is an example of a GraphQL query:

$ curl -X POST https://api.sphere.io/my-shop/graphql \
  -H "Content-Type:application/json" \
  -H "Authorization:Bearer ..." \
  -d '{"query": "query ($sku: String!) {product(sku: $sku) {id version}}", "variables": {"sku": "SKU-123"}}'

Product attributes as well as custom fields are dynamically generated for project’s GraphQL schema, depending on your ProductType and Type definitions, in an eventually consistent fashion.

In order to explore the GraphQL API, you can use an interactive GraphiQL environment which is available as a part of Impex.

Here is a short demonstration if the GraphiQL tool and how you can use it to discover the schema:

GraphiQL demonstration