-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
feat(graphcache): local directives #3306
Merged
kitten
merged 16 commits into
urql-graphql:main
from
JoviDeCroock:graphcache-directives
Jul 21, 2023
Merged
feat(graphcache): local directives #3306
kitten
merged 16 commits into
urql-graphql:main
from
JoviDeCroock:graphcache-directives
Jul 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JoviDeCroock
commented
Jul 16, 2023
JoviDeCroock
force-pushed
the
graphcache-directives
branch
3 times, most recently
from
July 19, 2023 17:57
6f58479
to
4a59c8a
Compare
JoviDeCroock
force-pushed
the
graphcache-directives
branch
from
July 19, 2023 19:18
4a59c8a
to
7148e5f
Compare
kitten
reviewed
Jul 19, 2023
Co-authored-by: Phil Pluckthun <[email protected]>
Co-authored-by: Phil Pluckthun <[email protected]>
Co-authored-by: Phil Pluckthun <[email protected]>
JoviDeCroock
force-pushed
the
graphcache-directives
branch
6 times, most recently
from
July 19, 2023 20:42
9fadcdf
to
2cc1f23
Compare
JoviDeCroock
commented
Jul 19, 2023
JoviDeCroock
force-pushed
the
graphcache-directives
branch
3 times, most recently
from
July 19, 2023 20:52
31e7a77
to
48407f3
Compare
JoviDeCroock
force-pushed
the
graphcache-directives
branch
from
July 19, 2023 20:53
48407f3
to
eefd806
Compare
kitten
approved these changes
Jul 20, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #3191
See #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
.