Create an advanced GraphQL query

Learn how to query Composable Commerce with GraphQL to find out Project information.

Ask about this Page
Copy for LLM
View as Markdown

After completing this page, you should be able to:

  • Identify the correct usage of GraphQL to find out Project information and use reference expansion.

Besides providing support for all CRUD (create, update, delete) operations to manage resources in a Composable Commerce Project, GraphQL provides additional features, such as the possibility to monitor the health of your Project and even automate processes.

Use GraphQL for fetching information about Project limits

Composable Commerce provides the ability through GraphQL to access information about your Project, including what limits exist and in some cases what the current count of a resource is. For example, you can query the limit of the number of Customers you can have in your Project as well as how many you currently have.

You can also query other Project information like the name and key.
For an example of querying Project information and resource limits in a single request, see Advanced queries in the GraphQL API reference.
The response includes Project metadata (such as key, name, and trial end date) and resource limits. Current counts are shown for Customers, Carts, Discounts, Product Types, and Stores.

Use Reference Expansion

In Composable Commerce, resources often have references to other resources. For example, a Product references its Product Type and a Customer can reference a Customer Group. An Order also references the Cart it was created from.

Expanding a reference adds to the query complexity because Composable Commerce makes a second database request in series with the primary retrieval. This is true for both REST and GraphQL. For full details, including field conventions and example queries, see Reference Expansion in the GraphQL API reference.

Use introspection

GraphQL provides a built-in introspection system that lets you query the schema to discover available types, fields, and their relationships. Introspection is useful for developing tools that generate GraphQL queries, even without prior knowledge of the available elements.
You can query to find all available types, or drill into a specific type to discover its fields, their types, and nullability. For details on using introspection with Composable Commerce, see the GraphQL API reference.

Test your knowledge