apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.34k stars 2.66k forks source link

[Data masking] Ensure `@unmask` can be used with the fragment registry #12029

Closed jerelmiller closed 1 month ago

jerelmiller commented 1 month ago

Fixes #12028

Ensures that fragments registered with the fragment registry can be looked up by the data masking algorithm.

This change adds a new lookupFragment API in the base cache class that allows custom caches to provide lookups for fragments by name. For example, InMemoryCache has the fragment registry, so it overrides the base implementation and uses the fragment registry to lookup a fragment by name.

As a part of this, I've moved the implementation of maskFragment and maskOperation over to QueryManager where I believe it fits better. This makes it a much more private API and makes it much more obvious that custom cache implementations don't need to interact with these APIs directly since we want the core Apollo Client controlling the implementation.

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: f6466d84d2adf2115226e48d5d675816e9def987

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR