Using GraphQL in JSS Next.js apps
JSS Next.jss apps enable a variety of data fetching options with GraphQL.
You can configure a new or existing JSS Next.js application to query the XM Cloud GraphQL endpoints, instead of using the equivalent REST APIs.
-
To create a Next.js application that uses the JSS GraphQL API for fetching layout and dictionary data, choose GraphQL when prompted during the app creation process.
-
If you created your Next.js JSS app with REST as the data fetching method, you can reconfigure the sample JSS Next.js app to use GraphQL instead.
In addition to fetching dictionary and layout data using the JSS GraphQL API, you can use GraphQL to run queries at the component level.
To write type-protected code with rich IDE assists using GraphQL types and TypeScript static data typing, you can introspect the GraphQL schema.