Use integrated GraphQL in a JSS app

Current version: 21.x

When the Sitecore Layout Service renders a page, it returns a JSON representation of the layout of the page and the data for each component. Normally, the component data is a set of fields from the Sitecore datasource item. Integrated GraphQL lets you re-shape this into a GraphQL query result.

To use Integrated GraphQL:

  1. Define a Sitecore GraphQL API endpoint that has the schema you want to query. Get this working first, and play with the schema using GraphiQL ($endpointUrl/ui) to ensure it works. Generally, the endpoint is defined using the JSS app's config patch file (stored under /sitecore/config in the JSS app, but can also be stored with Sitecore).

  2. Attach your JSS app to the GraphQL endpoint. On the JSS <app> definition, add a graphQLEndpoint property pointing to the URL of the endpoint. For example, <app name="MyJssApp" graphQLEndpoint="/sitecore/api/jssbasicapp" />.

You can use Integrated GraphQL in Sitecore-first apps and in code-first apps.

Do you have some feedback for us?

If you have suggestions for improving this article,