Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request]: Add note for @strapi/plugin-graphql and @apollo/client consumers about InMemoryCache #2379

Open
unrevised6419 opened this issue Feb 11, 2025 · 0 comments

Comments

@unrevised6419
Copy link
Contributor

unrevised6419 commented Feb 11, 2025

Summary

Add a note for @strapi/plugin-graphql and @apollo/client consumers to configure InMemoryCache to work with documentId

Why is it needed?

I'm using Strapi v5, and were configuring Apollo Client, and could not find any note about this in the docs.

As Strapi v5 is using documentId instead of id, would be good to notify users that they need to configure the InMemoryCache if they would like it to work fine.

Suggested solution(s)

const apolloClient = new ApolloClient({
	cache: new InMemoryCache({
		dataIdFromObject: (o) => {
			const maybeEntityId = o["documented"]
			const maybeComponentId = o["id"]
			const id = maybeEntityId ?? maybeComponentId
			return `${o.__typename}:${id}`
		},
	}),
});
@unrevised6419 unrevised6419 changed the title [Request]: Add note for @strapi/plugin-graphql and Apollo Client consumers about InMemoryCache [Request]: Add note for @strapi/plugin-graphql and @apollo/client consumers about InMemoryCache Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant