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:{projectKey}/graphql

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

Here is an example of a GraphQL query:

$ curl -X POST \
-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

Reference Expansion

The GraphQL API supports Reference Expansion, just like the HTTP API.

By convention, the GraphQL API offers two fields for each expandable reference:

Expanding a reference in the GraphQL API impacts the performance of the request. You can use the GraphiQL’s Profiling function to measure the impact for your project:

GraphiQL profiling