Skip to main content
More in Learn

Querying the Catalogue

The Product Information Management (PIM) API provides an easy way to fetch products, folders and documents.

Basic Query

To fetch any item via the Catalogue API, the catalogue query root is used. In the example query below, we are retrieving a folder named shop and the names of the subfolders within it.

Query Variables

Variables in GraphQL allow you to run the same query multiple times with different arguments. In order to get a specific item using the Catalogue API, you will need to specify the following query variables i.e. the path, the language, and the version.

  • path: implies the path of the folder you are trying to retrieve the data from.
  • language: simply refers to the language.
  • version: this variable can have either of the two values - draft or published depending on whether you would like to get only the published sections or the ones that have yet to be published as well. By default this is set to published.

Declaring Variables

The query variables are declared right after the query keyword and begin with '$'. In the example below, the three variables are declared and each of their types are specified. These variables are then passed to the arguments, which are language, path, and version in this case.

query ($language: String!, $path: String, $version: VersionLabel!) {
catalogue(language: $language, path: $path, version: $version) {...}
}

If you head over to the GraphQL playground, you can specify these variables at the bottom-left corner. The following JSON object is how the variables for the above query are defined.

{
"language": "en",
"path": "/shop/sofas",
"version": "published"
}
People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community