Ok, having spent some time trying to figure out how this whole thing works in Sitecore, I can now say, that SXA-JSS does not support integrated GQL.
The problem lies in the sxa-jss configuration for the
LayoutService, which is selected by default when you create a new SXA JSS site.
The configuration above comes from this file:
In that file Sitecore uses
Sitecore.XA.JSS.Foundation.Presentation.ContentsResolvers.RenderingContentsResolver, Sitecore.XA.JSS.Foundation.Presentation as the
renderingContentResolver and if you disassemble the class, you'll see that it does not execute any GQL at all!
From here you have two options:
- Create a patch file to replace that class in
configuration/sitecore/layoutservice/configurations/config[@name="sxa-jss"]/rendering/renderingContentsResolver[@type="Sitecore.XA.JSS.Foundation.Presentation.ContentsResolvers.RenderingContentsResolver, Sitecore.XA.JSS.Foundation.Presentation"] with a content resolver that is GQL aware, i.e.:
- In the settings of your SXA JSS site, change the
jss (instead of the default sxa-jss).
The only thing that the SXA ContentResolver does is that it injects the DisableEditing flag and makes sure that the Media.AlwaysIncludeServerUrl setting is respected in your JSON output, so patching it or replacing the configuration with JSS should not do any more harm.
Either way, I've reached out to Sitecore to have them comment on the problem. Once I get their feedback, I'll update my reply.
Sitecore came back with an answer confirming that the sxa-jss configuration does not support running integrated GQL queries and this is by design. They added this configuration for compatibility reasons and said that it should not be used for JSS apps. Instead, if you have a JSS app, you need to switch it to the jss
The 'sxa-jss' was added to allow the compatibility between SXA and JSS.
However, you should use 'jss' layout service configuration for JSS apps.
All you custom JSS apps should by default inherit this default app and all >attributes that are not overridden directly.