0

Environment:

  • Sitecore 10.2 XM
  • Headless 20
  • SXA 10.2
  • SPE 6.3

Problem

When I fill in the Component GraphQL Query field for a Json Rendering with something simple like this:

Component GraphQL Query field

query IntegrationQuery($contextItem:String!, $datasource:String!, $language: String!) {
  item(path: $contextItem, language: $language) {
     displayName
  } 
}

Expected Results

I expect that query to shape the Layout Service response when I retrieve a route layout with that rendering in the presentation details. I imagine the response would look something like this:

"jss-main": [{
 "uid": "c56a8699-5e33-4c04-bcab-ce57642e05e4",
 "componentName": "locations",
 "dataSource": "",
 "data" : {
   "item": {
     "displayName": "Chicago"
   }
 }
}]

Actual Results

Instead, I got an empty component that looks like this:

"jss-main": [{
 "uid": "c56a8699-5e33-4c04-bcab-ce57642e05e4",
 "componentName": "locations",
 "dataSource": ""
}]

Assumptions & Troubleshooting Attempted

  1. I assume that the Sitecore.LayoutService.GraphQL.LayoutService.GraphQLAwareRenderingContentsResolver is responsible for injecting the GraphQL response into the rendering's Json output.

  2. I noticed that this resolver is patched in for the default LayoutService configuration

    <sitecore>
     <layoutService>
       <configurations>
         <config name="default">
           <rendering>
             <renderingContentsResolver set:type="Sitecore.LayoutService.GraphQL.LayoutService.GraphQLAwareRenderingContentsResolver, Sitecore.LayoutService.GraphQL" resolve="true" />
           </rendering>
         </config>
       </configurations>
     </layoutService>
    </sitecore>
    

    Since my site is using SXA and is configured with the sxa-jss Layout Service configuration, I also patched this resolver for this configuration. No Luck :(

    SXA Site Configuration

  3. I also patched this resolver into the jss Layout Service configuration. Still No Luck

  4. I've reviewed the Sitecore logs on both CM and CD. No errors related to the Layout Service or the GraphQLAware Content Resolver.

In Summary

I've combed through the Sitecore docs looking for more information on how this field is supposed to work and cannot figure out what I'm doing wrong.

Update: Workaround

I've identified a workaround that might help others with the same problem. You can create your own 'custom' resolver in the content tree under: /sitecore/system/Modules/Layout Service/Rendering Contents Resolvers

Make sure that the Type field is set to: Sitecore.JavaScriptServices.GraphQL.LayoutService.GraphQLAwareRenderingContentsResolver, Sitecore.JavaScriptServices.GraphQL

GraphQL Aware Rendering Contents Resolver

Once this is set, you can assign this Rendering Content Resolver to any Json Rendering that uses GraphQL to shape the Component response in the Layout Service.

The expectation is that this resolver should be the default and this extra configuration is not required. Working with Sitecore Support to get to the root cause.

1
  • 1
    Does it make sense to post your work around as an Answer, instead of an embed in your Question?
    – Pete Navarra
    Aug 1 at 18:51

1 Answer 1

0

Workaround

The expectation is that the GraphQLAwareRenderingContentsResolver should be the default for any Json Renderings.

With that said, I've identified a workaround that might help others with the same problem. You can create your own 'custom' resolver in the content tree under: /sitecore/system/Modules/Layout Service/Rendering Contents Resolvers

Make sure that the Type field is set to: Sitecore.JavaScriptServices.GraphQL.LayoutService.GraphQLAwareRenderingContentsResolver, Sitecore.JavaScriptServices.GraphQL

GraphQL Aware Rendering Contents Resolver

Once this is set, you can assign this Rendering Content Resolver to any Json Rendering that uses GraphQL to shape the Component response in the Layout Service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.