﻿#### 

The Sitecore GraphQL API is an implementation of a GraphQL server on top of Sitecore. It is designed to be a generic GraphQL service platform, i.e. it's designed to host your API and present it via GraphQL queries. The API also supports real-time data using GraphQL subscriptions.

Last year we worked on building sites based on Sitecore JSS architecture. As usual, all of our pages had a datasource that are located in an item in the PageComponents folder:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/datasources.png) 

For example, we want to have a component that renders all banners from the Banners folder. We use the Component GraphQL Query to define a structure of data that comes from the Layout Service. By default, GraphQL doesn’t support the Sitecore item queries, such as query:./\*[@@name='Page Components']. But sometimes it would be great to have more flexibility than requesting an item only by item path or its ID. To make it possible, we decided to build a custom query. You can find the code below.

![](https://www.brimit.com/-/media/project/brimit/blog/2020/article-single-sample1.png) 

The complete code is available by the [link](https://github.com/ampach/Sitecore/blob/master/GraphQL%20Queries/SelectSingleItemQuery.cs).

Then we need to register our query:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/article-single-sample2.png) 

The config file is available [here](https://github.com/ampach/Sitecore/blob/master/GraphQL%20Queries/SelectSingleItemQuery.config).

When the query is deployed to the website root, we can build the following query:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/sitecore-item-query.png)

![](https://www.brimit.com/-/media/project/brimit/blog/article-single-sample3.png)

Also, using this extension, we can can rebuild the query mentioned in [GraphQL Extensibility: SiteRelativeItem Query](https://www.brimit.com/blog/graphql-extensibility-siterelativeitem-query) by building the query like below.

![](https://www.brimit.com/-/media/project/brimit/blog/article-single-sample4.png) 

The result will be the same as in the case of using the [SiteRelativeItem Query](https://www.brimit.com/blog/graphql-extensibility-siterelativeitem-query).

###### More from author

[##### Deploy custom headless Sitecore solution in Sitecore XM Cloud
November 10, 2022](https://www.brimit.com/blog/deploy-custom-headless-sitecore-solution-in-sitecore-xm-cloud)[##### Running custom next.js editing host in Sitecore XM Cloud
September 29, 2022](https://www.brimit.com/blog/running-custom-next-js-editing-host-in-sitecore-xm-cloud)[##### Running node.js based rendering host in Sitecore Managed Cloud
August 3, 2022](https://www.brimit.com/blog/running-node-js-based-rendering-host-in-sitecore-managed-cloud)

###### Author

[!\[artsiom-photo\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/artsiom-200.jpg?h=202&amp;iar=0&amp;w=200&amp;hash=41797D2540DF6EB6FDF558360F6F62B8)
Artsem Prashkovich
Sitecore MVP/ Solution Architect](https://www.brimit.com/blog/author?authors=Artsem%20Prashkovich)

###### More by category

[#Events](https://www.brimit.com/blog?categories=#Events)[#How-to](https://www.brimit.com/blog?categories=#How-to)[#News](https://www.brimit.com/blog?categories=#News)[#Guides](https://www.brimit.com/blog?categories=#Guides)

###### More by platform

[DXP](https://www.brimit.com/blog?platforms=DXP)[Sales and marketing automation](https://www.brimit.com/blog?platforms=Sales%20and%20marketing%20automation)[Application innovation](https://www.brimit.com/blog?platforms=Application%20innovation)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=43e2eaa8-1237-40af-bffd-9e4077d780e1&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=GraphQL%20Extensibility%3A%20%E2%80%9CSelectSingleItem%E2%80%9D%20Query&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fgraphql-extensibility-select-single-item-query&amp;r=&amp;lt=314&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=888046)