Use integrated GraphQL in a JSS app
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:
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/configin the JSS app, but can also be stored with Sitecore).
Attach your JSS app to the GraphQL endpoint. On the JSS
<app>definition, add a
graphQLEndpointproperty 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.