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

feat(graphcache): allow for defining inline-fragment/fragment-definition client controlled nullability directives #3502

Closed JoviDeCroock closed 4 months ago

JoviDeCroock commented 5 months ago

Summary

This allows for defining @_optional and @_required on both a fragment-definition as well as an inline-fragment. This to facilitate patterns like a refetchable-fragment where you can refetch parts of a document.

Example

query {
  todo {
    id
    text
    author { id name }
    ... on Todo @_optional { seenBy(first: 10, after: $after) }

  }
}

Now we can paginate over seenBy without losing the data surrounding it, this is good for composing fragments from i.e. a list with the parent.

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: 2006a6a2a2c21b5d6661008e91e41a1629fff49a

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