Querying Sitecore Experience Edge using the GraphQL endpoint

Akshay Sura - Partner

28 Feb 2021

Share on social media

One of the biggest advantages of the Sitecore Experience Edge is the GraphQL endpoint. Today we will explore the GraphQL endpoint provided with the Experience Edge Delivery endpoint.

Your Delivery Endpoint GraphQL playground: https://YOURINSTANCEURL/api/graphql/ide

Your Delivery GraphQL Endpoint: https://edge-beta.sitecorecloud.io/api/graphql/v1

Your Preview Endpoint: https://YOURINSTANCEURL/api/graphql/preview/ide/

Your Preview GraphQL Endpoint: https://YOURINSTANCEURL/api/graphql/preview/v1

Once you get access to your GraphQL Endpoint, generate an API key for you to use. We have the choice of Delivery or Preview.


Configure the key in your GraphQL playground by using the header section. Use the X-GQL-Token header and specify your token. You would have a token for your Delivery and another one for your Preview endpoints.

Look through the Docs section to map your query. In my case, I am trying to pull all the blog posts.

I now know what my query should look like. Use the typeahead and IntelliSense capability to pick up your fields in your query.

The following is my simple query which brings in all the blog posts.

query { allM_Content_Blog { total results { id blog_Title blog_Quote blog_Body } } }

The result of this query is shown below:

Once you start using GraphQL you wouldn't want to use anything else. Now let's try to find a specific blog post.

query { m_Content_Blog (id: "Content.NutritionTipsBlogPost"){ id blog_Title blog_Quote blog_Body } } We get back the blog post shown below.


We can customize the GraphQL query to pull in relationships and values multiple levels deep. That is the beauty of GraphQL. No need for multiple calls.

If you have any questions, please get in touch with me. @akshaysura13 on Twitter or on Slack.

Follow us on Twitter

Follow us on LinkedIn

Follow us on YouTube

Sign up to our newsletter


Tags:

Sitecore Experience Edge
Headless CMS
Jamstack
Content Hub
CaaS

Share on social media

Akshay Sura

Akshay is an eight-time Sitecore MVP who has spent more than a decade working exclusively on Sitecore projects.

In addition to his work as a solution architect, Akshay is also one of the founders of SUGCON North America 2015, SUGCON India 2018 & 2019, Unofficial Sitecore Training, and the Sitecore Slack.

Akshay founded and continues to run the Sitecore Hackathon. As one of the managing partners of Konabos Consulting, Akshay will continue to work with clients to lead projects and mentor their existing teams.


Subscribe to newsletter