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

(graphcache) - Increase consistency of __typename in cached results #1185

Merged
merged 11 commits into from
Dec 2, 2020

Conversation

kitten
Copy link
Member

@kitten kitten commented Dec 2, 2020

See #1184

Summary

Note: More testing is needed before we can safely ship this.

Increase the consistency of when and how the __typename field is added to results. Instead of adding it by default and automatically first, the __typename field will now be added along with the usual selection set. The write operation will issue a warning if it's in the selection but missing in the result, as it should, and the query operation will add it as it did before but at the correct position of the result, assuming that it's in all selection sets. The slight change here is that it now won't be added to root results by default and only if it's being queried explicitly.

Set of changes

  • Allow makeSelectionIterator to iterate __typename field
  • Remove data.__typename assignment in readSelection and add special logic for __typename field assignment
  • Update query.test.ts cases to include __typename explicitly where needed

The `__typename` field does not need to be added to root
types by default and must not be added first, as it shouldn't
be necessary. Instead we can assume that it's in the result
and copy it over once it's reached in the selection iteration.
@kitten kitten requested a review from JoviDeCroock December 2, 2020 10:21
@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2020

🦋 Changeset detected

Latest commit: a085142

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 Minor

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 force-pushed the fix/instructed-typename-ordering branch from efdb1c1 to f154c94 Compare December 2, 2020 10:38
@kitten kitten force-pushed the fix/instructed-typename-ordering branch from f4c5b9d to 3d55f8c Compare December 2, 2020 12:03
I believe this should be a minor bump since we're adding a new
warning.
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