urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.54k stars 444 forks source link

fix(graphcache): Cascade `@defer`, `@_optional`, and `@_required` state only per nested fragment spread #3517

Closed kitten closed 4 months ago

kitten commented 4 months ago

Summary

This fixes @_optional to work when the selection contains a sub-selection fragment spread. Previously, other fragment spreads inside an @_optional spread would become non-optional/non-required again, since the value of deferRef would be reset with another isOptional() check.

This also applies the same principle to @defer. Previously, @defer would cascade to all child selection fields. This meant that any field nested inside a @defer-ed fragment would be able to be deferred and be completely optional, even if it's direct parent wasn't a deferred fragment spread.

Set of changes

changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: b04d84dde02de05aaf11a2c76a941d2d35e178b7

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