GraphQL Explorer
Accessing the explorer
You can access your GraphQL explorer at this url
{ServerUrl}/api/graphql/:repoParams
:repo - Name of repository in CM BoxCreating Queries in the explorer
Example Query
You can test content queries in your repository using the operation section of the explorer. This example will query all files that exist in your repository
Query
query Query { items { items { ... on File { name id slug } } }}Headers
In the headers tab below the operation window you will need to add Authorization as a header key with a value that inlcudes your API token
Header Key
AuthorizationHeader Value
Bearer {token}Response
{ "data": { "items": { "items": [ { "name": "item1", "id": "ITEM_C63E510AD0BB4897950B2385215B53C9", "slug": "file_1714506050833_item1" }, { "name": "item2", "id": "ITEM_81488926400E4415BB2C55AE8AE475DD", "slug": "file_1714578164821_item2" }, { "name": "item3", "id": "ITEM_0E8FDD17D1E7405FA8ED4A7E939B387D", "slug": "file_1714504125448_item3" } ] } }}Creating your own query
The left side of the explorer generates all possible query options at each level. Clicking the plus button on the left of the possible type/field will add it to your query. Clicking on the type/field name will take you one level deeper without adding it to the query.
To create the previous example query, you can use the plus button to add the following to your query
- Add query: Query
- Add items(...): SearchResponse
- Add items(): [AllContent]
- Add name: String
- Add id: ID!
- Add slug: StringThis should result in the same query and response as the example query.
Query Arguments
Most fields in the query can take in an argument to adjust the response. These are the possible arguments:
id: ID - Query by content idslug: String - Query by content slugsettings: QuerySettings - Refer to QuerySettings sectionapiName: String - restrict query with string search by api name (getCategory only)shortname: String - restrict query with string search by short name (getTaxonomy, taxonomies only)Query Settings argument
advancedQuery: Stringfilters: JSON - object for querying specific fields in responsefolder: String - querying items in specific folderlimit: Int - restrict number of response resultsquery: String - query by name fieldsort: String - sort by response fieldsstart: Int - starting position for responsestatus: [String] - array of strings for querying by status(s)types: [String] - array of strings for querying by type(s)version: String - query by version numberExample query with arguments
In this example, there are 6 items that have the same name, but can be queried to find their id’s and slugs. There are 4 different types in this repository: File, Image, Video, and Upload.
Query
query Query($settings: QuerySettings) { items(settings: $settings) { count items { ... on File { name id slug } ... on Image { name id slug } ... on Video { name id slug } ... on Upload { name id slug } } }}All results in repository
{ "data": { "items": { "count": 6, "items": [ { "name": "test1", "id": "ITEM_619493D4F2C7489990A2C76DAAC3C8E1", "slug": "upload_1714767180679_test1" }, { "name": "test1", "id": "ITEM_7F71D42B0515434092AD8ADDF70E8CBC", "slug": "video_1714767166490_test1" }, { "name": "test1", "id": "ITEM_02ECFC34A23A4478A7879C52801FBC96", "slug": "video_1714767147786_test1" }, { "name": "test1", "id": "ITEM_6A83DFD2277C4288954AAC9C6A472C61", "slug": "image_1714766498197_test1" }, { "name": "test1", "id": "ITEM_4C3116E71BF04995A91DF06CD7145B6C", "slug": "file_1714766444134_test1" }, { "name": "test1", "id": "ITEM_829C2ACED55744CBB5BE3361C414CB27", "slug": "file_1714766434942_test1" } ] } }}Variables
When you add settings to the variables in the explorer, it will filter the results. This query will now be filtered to include only File and Image.
{ "settings": { "query": "test1", "sort": "updatedDate:DESC", "limit": 10, "types": ["file","image"] }}Filtered Results
{ "data": { "items": { "count": 3, "items": [ { "name": "test1", "id": "ITEM_6A83DFD2277C4288954AAC9C6A472C61", "slug": "image_1714766498197_test1" }, { "name": "test1", "id": "ITEM_4C3116E71BF04995A91DF06CD7145B6C", "slug": "file_1714766444134_test1" }, { "name": "test1", "id": "ITEM_829C2ACED55744CBB5BE3361C414CB27", "slug": "file_1714766434942_test1" } ] } }}