How To Set-Up Sitecore GraphQL

October 28, 2022

In this blog post, we will go through the features of Sitecore GraphQL Browser. Please note this is mostly for development work, refer to the official Sitecore documentation when setting up for production.

Setting Up Sitecore GraphQL

Head into the web.config of your Site and set <compilation debug="true">. This should be disabled in Production scenarios, but since we're just using it for development, it's fine.

Open up Sitecore.Services.GraphQL.Content.Master and make note of the API url under the 'master' node.

Sitecore.Services.GraphQL.Content.Master.config master node

Accessing Your GraphQL Endpoint

To access your GraphQL endpoint head to http:///sitecore/api/graph/items/master/ui you can use this GUI to compose queries and see what data is being returned.

Sitecore Experience Graph Browser

Below is an example query that you can use to scan every Sitecore item under a certain node, looking for a specific template.

{ search(keyword: "", rootItem: "/sitecore/content/Home", fieldsEqual: [{name: "_templatename", value: "Content Page"}]) { results { totalCount items { name } } } }

Documentation

If you need some guidance on how to build your queries, the Sitecore GraphQL UI has some built-in documentation on the side.

Sitecore Experience Graph Browser

Documentation Explorer in Sitecore Experience Graph Browser

Closing

This is just the basics on how to get started using Sitecore GraphQL. You can also run these queries through other Platforms, such as Postman.

Thank you for reading, and I hope to cover how to run these queries in more detail in future blog posts.