-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(graphcache) - Handle fields with associated GraphQLError as cache mi…
…sses and provide errors to updaters (#1356) * Add Context.path tracking the currently field alias path * Remove active ctx.path tracking from query in production It's not needed to track current errors from results there, so it can alternatively be fully removed. * Add note to ResolveInfo type on why path isn't exposed via types * Provide the current field's GraphQLError on an updater's context * Update docs to add information about the error field * Overwrite null values as undefined when field has an associated error When a field has an associated GraphQLError then the `fieldValue` should be written as `undefined` rather than `null`. * Replace isFieldMissing with getFieldError * Isolate path/errorMap on context in context.__internal 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. * Fix leftover global errorMap in shared.ts * Add tests for errored fields set to undefined rather than null * Add changeset * Move updateContext in write.ts' updater call * Deduplicate writeOptimistic logic with startWrite
- Loading branch information
Showing
8 changed files
with
261 additions
and
100 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@urql/exchange-graphcache': major | ||
--- | ||
|
||
Add improved error awareness to Graphcache. When Graphcache now receives a `GraphQLError` (via a `CombinedError`) it checks whether the `GraphQLError`'s `path` matches up with `null` values in the `data`. Any `null` values that the write operation now sees in the data will be replaced with a "cache miss" value (i.e. `undefined`) when it has an associated error. This means that errored fields from your GraphQL API will be marked as uncached and won't be cached. Instead the client will now attempt a refetch of the data so that errors aren't preventing future refetches or with schema awareness it will attempt a refetch automatically. Additionally, the `updates` functions will now be able to check whether the current field has any errors associated with it with `info.error`. |
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
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
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
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
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
Oops, something went wrong.