More in Learn

Querying the Catalogue

The Catalogue API provides an easy way to fetch products, folders, and documents from the catalogue.

In order to perform these operations, ensure that you have the proper authentication (if necessary) and user permissions.

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.

Circle loading spinnerImage of a partial circle indicating &qoute;loading&qoute;.Fetching snippet...

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:

  • path: the path of the folder you’re trying to retrieve data from.
  • language: simply refers to the language.
  • version: this variable can have one of two values, draft or published, depending on whether you would like to retrieve 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 help?

Join and ask our
slack community.

Join our slack community