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

fix(graphcache): Switch fragment heuristic to always be truthy on writes #2455

Merged
merged 1 commit into from
May 24, 2022

Conversation

kitten
Copy link
Member

@kitten kitten commented May 24, 2022

Previously we assumed that if an unknown fragment was being applied it'd
be an exceptional case and would not have to apply if the cache doesn't
already know all its fields.

We can now (theoretically) safely switch to always return true on writes.
When we encounter a field that isn't in the data, as returned by the API
then we can eagerly write anyway and let it fail.

This is safe because if we were to encounter undefined data, this signals
to the cache that the field should be deleted, which is correct.

This is important for cases where the fragment applies to an interface
of a node rather than to a concrete type.

Previously we assumed that if an unknown fragment was being applied it'd
be an exceptional case and would not have to apply if the cache doesn't
already know all its fields.

We can now (theoretically) safely switch to always return `true` on writes.
When we encounter a field that isn't in the data, as returned by the API
then we can eagerly write anyway and let it fail.

This is important for cases where the fragment applies to an interface
of a node rather than to a concrete type.
@kitten kitten requested a review from JoviDeCroock May 24, 2022 15:21
@changeset-bot
Copy link

changeset-bot bot commented May 24, 2022

🦋 Changeset detected

Latest commit: 6aa01c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/exchange-graphcache Patch

Not sure what this means? Click here to learn what changesets are.

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

@kitten kitten merged commit cabbcd7 into main May 24, 2022
@kitten kitten deleted the fix/heuristic-fragment-matching branch May 24, 2022 15:31
@urql-ci urql-ci mentioned this pull request May 24, 2022
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

Successfully merging this pull request may close these issues.

2 participants