﻿#### 

We mainly use the Component GraphQL Query to define how a rendering and its associated data are serialized when we create a multisite application based on Sitecore JSS architecture. With time, we found out that the default functionality is not enough for our needs.

Let’s imagine that we have two Sitecore sites. Each of them has a Robots Configuration item with different values for the Robots File Content field:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/ia.png?h=498&amp;w=800&amp;hash=D9C2861E784BB65463C466C4CC9A822D)

Then, we have a rendering that uses a GraphQL to build the data that will be provided by the Layout Service. This rendering needs to read the robots configuration from the context site and render robots.txt file. By default, GraphQL can resolve items by item path, ID or short ID only. But to meet our requirement, we need to be able to resolve items by a relative path, based on the context site.

As long as this kind of query is not supported by default, we decided to implement the custom query:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/article-relative-sample1.png) 

The complete code is available by the [link](https://github.com/ampach/Sitecore/blob/master/GraphQL%20Queries/SiteRelativeItemQuery.cs).

Then we need to register our query:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/article-relative-sample2.png) 

The config file is available [here](https://github.com/ampach/Sitecore/blob/master/GraphQL%20Queries/SiteRelativeItemQuery.config)

When all changes are deployed to the website root, we can build the following query:

![](https://www.brimit.com/-/media/project/brimit/blog/2020/gql-query.png) 

In the result, we have an item which is resolved by a relative path based on the context (or specified in query arguments) site.

###### 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=4a8da537-6ae9-4da1-bdf3-d71bf471048e&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=How%20to%20organize%20Dictionaries%20on%20a%20JSS%20website&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fhow-to-organize-dictionaries-on-a-jss-website&amp;r=&amp;lt=267&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=181223)