-
-
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
(graphcache) - Handle fields with associated GraphQLError as cache misses and provide errors to updaters #1356
Conversation
It's not needed to track current errors from results there, so it can alternatively be fully removed.
When a field has an associated GraphQLError then the `fieldValue` should be written as `undefined` rather than `null`.
This is to further hide the implementation from the user and to ensure that sub-write methods like `updateQuery` or `writeFragment` on the Store don't interfere with this logic as they'd build up their own paths.
🦋 Changeset detectedLatest commit: 6a284f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Definitely a nice upgrade and I'm a big fan of handling errors consistently with undefined
Resolve #1344
Summary
This change attempts to improve Graphcache's error handling and error awareness. Instead of ignoring the added information that
GraphQLError#path
may provide for individual null'ed out fields, Graphcache now processes these errors and dynamically replacesnull
values (links and records) as it writes them withundefined
— i.e. uncached / cache misses — when an associatedGraphQLError
has been received for a given field.Set of changes
Context.__internal.path
tracking the current data path via aliases and indicesContext.__internal.errorMap
tracking the currentCombinedError
'sGraphQLError
s by their pathsContext.error
which shows an updater its current field's error if any existsfieldValue
inwrite
withundefined
rather thannull
if the current field has an associated error to itSize change from
6.87kB gzip
to7.07kB gzip
(an increase of0.2kB gzip
)