Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docusaurus/docs/cms/plugins/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,25 @@ To increase GraphQL security even further, 3rd-party tools can be used. See the

The GraphQL plugin adds a GraphQL endpoint accessible and provides access to a GraphQL playground, accessing at the `/graphql` route of the Strapi admin panel, to interactively build your queries and mutations and read documentation tailored to your content types. For detailed instructions on how to use the GraphQL Playground, please refer to the official <ExternalLink to="https://www.apollographql.com/docs/apollo-server/v2/testing/graphql-playground" text="Apollo Server documentation"/>.


:::note
Strapi uses `documentId` as the unique identifier for entities instead of `id`. When using Apollo Client with Strapi's GraphQL API, you need to [configure](https://www.apollographql.com/docs/react/caching/cache-configuration#customizing-identifier-generation-globally) the `InMemoryCache` to use `documentId` for cache normalization:

```javascript
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client';

const client = new ApolloClient({
link: new HttpLink({ uri: "http://localhost:1337/graphql" }),
cache: new InMemoryCache({
dataIdFromObject: (o) => `${o.__typename}:${o["documentId"]}`,
}),
});
```

This ensures that Apollo Client correctly caches and updates your GraphQL data based on Strapi's identifier structure.
:::


### Usage with the Users & Permissions feature {#usage-with-the-users--permissions-plugin}

The [Users & Permissions feature](/cms/features/users-permissions) allows protecting the API with a full authentication process.
Expand Down
19 changes: 19 additions & 0 deletions docusaurus/static/llms-code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28753,6 +28753,25 @@ export default {
```


## Usage
Description: :::note Strapi uses documentId as the unique identifier for entities instead of id.
(Source: https://docs.strapi.io/cms/plugins/graphql#usage)

Language: JavaScript
File path: N/A

```js
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client';

const client = new ApolloClient({
link: new HttpLink({ uri: "http://localhost:1337/graphql" }),
cache: new InMemoryCache({
dataIdFromObject: (o) => `${o.__typename}:${o["documentId"]}`,
}),
});
```


## Registration
Description: Code example from "Registration"
(Source: https://docs.strapi.io/cms/plugins/graphql#registration)
Expand Down