In order to perform these operations, ensure that you have the proper authentication (if necessary) and user permissions.
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.
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"
}