This introduces a new property to the Graphcache config named directives, this will function as a more selective way to apply resolvers. i.e. you can do @_relayPagination only when you want it.
The directives config is populated by object entries that define client-only/local directives. A directive is a function that accepts an object of arguments passed to directives and must return a resolver.
If you add an entry relayPagination: (directiveArgs) => yourResolver then @_relayPagination will become available. All directives with a leading underscore are stripped from queries sent to the API after #3317.
This means that you can selectively implement local/client-only directives that only change what resolver is used in Graphcache!
Additionally, this introduces two default directives @_optional and @_required as a means to facilitate optional query selections without the client-controlled nullability spec being shipped 😅 this bridges the gap between schemaless and schema-aware graphcache.
You can add @_optional to allow Graphcache to default any field to a null value.
And, you can add @_required to tell Graphcache that a field is required, even if it's cached as null.
Resolves #3191
See https://github.com/urql-graphql/urql/pull/3317 for more information on client-only directives.
Summary
This introduces a new property to the Graphcache config named
directives
, this will function as a more selective way to apply resolvers. i.e. you can do@_relayPagination
only when you want it.The
directives
config is populated by object entries that define client-only/local directives. A directive is a function that accepts an object of arguments passed to directives and must return a resolver.If you add an entry
relayPagination: (directiveArgs) => yourResolver
then@_relayPagination
will become available. All directives with a leading underscore are stripped from queries sent to the API after #3317.This means that you can selectively implement local/client-only directives that only change what resolver is used in Graphcache!
Additionally, this introduces two default directives
@_optional
and@_required
as a means to facilitate optional query selections without the client-controlled nullability spec being shipped 😅 this bridges the gap between schemaless and schema-aware graphcache.You can add
@_optional
to allow Graphcache to default any field to anull
value. And, you can add@_required
to tell Graphcache that a field is required, even if it's cached asnull
.