﻿#### 

There are two options how rendering and its associated data are serialized: **Rendering Contents Resolver** and **Component GraphQL Query** (read about comparison of them by the following link: [Comparison of GraphQL query vs Rendering Content Resolving](https://www.brimit.com/blog/comparison-of-graphql-query-vs-rendering-content-resolving)

By default, only one of them can be used. Once the Component GraphQL Query field has any value, the Rendering Content Resolver is not utilized any more. But sometimes it is good to have both of them enabled at the same time. For example, when you need to use a Rendering Content Resolver to get and calculate data from a third party, and still want to get data from a datasource or context item which is easier to reach via GraphQL. In this article I will show how we can achieve that.

First of all, we need to revert the original RenderingContentsResolver, which was overridden by GraphQL provider. It definitely works fine, but it has wrong logic in terms of our goal. It provides data from GraphQL only in case of an  empty Rendering Contents Resolver field.

![Revering default processor](https://www.brimit.com/-/media/images/blog/graphql-and-rendering-content-together/revering-default-processor.png)

The config file is available [here](https://github.com/ampach/Sitecore/blob/master/graphql-and-Content-rendering-resolver/GraphQLandRenderingContentResolver.config)

Then, we need to implement a **GraphQLContentsResolver** processor which will extend the output with a data from GraphQL query:

![GraphQL Contents Resolver](https://www.brimit.com/-/media/images/blog/graphql-and-rendering-content-together/graphqlcontentsresolver.png) 

The complete code is available by the [link](https://github.com/ampach/Sitecore/blob/master/graphql-and-Content-rendering-resolver/GraphQLContentsResolver.cs).

Then we need to patch the configuration to register the processor:

 ![Register a new processor](https://www.brimit.com/-/media/images/blog/graphql-and-rendering-content-together/register-a-new-prcessor.png)

The config file is available [here](https://github.com/ampach/Sitecore/blob/master/graphql-and-Content-rendering-resolver/GraphQLandRenderingContentResolver.config)

The code above will be run after the *Sitecore.LayoutService.Presentation.Pipelines.RenderJsonRendering.ResolveRenderingContents* that retrieves data using Rendering Content Resolver selected on the rendering item.

The currently created processor uses a default Sitecore’s **GraphQLAwareRenderingContentsResolver** to execute GraphQL query and extend the already existing content.

Now, rendering associated data is always extended with a GraphQL query execution results if the query is set.. Only one thing is left. I also want to be able to use GraphQL only. It is very simple, we need to implement a custom Rendering Content Resolver which returns empty object:

![Empty Rendering Content Resolver](https://www.brimit.com/-/media/images/blog/graphql-and-rendering-content-together/emptyrenderingcontentresolver.png)

The complete code is available by the [link](https://github.com/ampach/Sitecore/blob/master/graphql-and-Content-rendering-resolver/EmptyRenderingContentResolver.cs).

Then create a Rendering Content Resolver item in Sitecore:

![GraphQL Query Only item](https://www.brimit.com/-/media/images/blog/graphql-and-rendering-content-together/graphql-query-only-item.png)

There are three possible variants to serialize rendering data:

- Rendering Content Resolver and GraphQL - choose resolver and add GraphQL query

- Only Rendering Content Resolver - choose resolver and keep GraphQL query empty

- Only GraphQL query - choose **GraphQL Query Only** resolver and add GraphQL 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=4ed96123-4480-4364-acaa-db048ff52bd1&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=JSS%3A%20How%20to%20use%20GraphQL%20query%20and%20Rendering%20Contents%20Resolver%20together&amp;kw=JSS,GraphQL,Query,Sitecore,Rendering,Resolver&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fhow-to-use-graphql-query-and-rendering-contents-resolver-together&amp;r=&amp;lt=271&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=75520)