Skip to content

Commit

Permalink
Ensure onError is called when errorPolicy is set to "all" and par…
Browse files Browse the repository at this point in the history
…tial data is returned (#10383)

* Minor tweak to test name to make it more clear its intent

* Add 2 new tests to ensure onError is called with network and graphql errors

* Add wait and tick helpers for testing

* Fix typo

* Add tests to validate when onError is called when errorPolicy is ignore

* Slight verbage change

* Add test to validate partial data is removed from result

* Add check of data

* Add test to validate graphql errors are discarded with partial data

* Add missing semicolons

* Add missing expectation

* Add failing tests for onError not being called with errorPolicy = "all"

* Add failing test for calling onCompleted with partial data

* Remove unneeded mock in test

* Ensure `onError` is called when GraphQL errors are returned

* Fix onCompleted mock not passed to hook

* Update bundlesize

* Update snapshot tests

* Add changeset
  • Loading branch information
jerelmiller authored Jan 4, 2023
1 parent 73b0bb5 commit 5c5ca9b
Show file tree
Hide file tree
Showing 7 changed files with 431 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-cameras-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@apollo/client': patch
---

Ensure the `onError` callback is called when the `errorPolicy` is set to "all" and partial data is returned.
2 changes: 1 addition & 1 deletion config/bundlesize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join } from "path";
import { gzipSync } from "zlib";
import bytes from "bytes";

const gzipBundleByteLengthLimit = bytes("32KB");
const gzipBundleByteLengthLimit = bytes("32.03KB");
const minFile = join("dist", "apollo-client.min.cjs");
const minPath = join(__dirname, "..", minFile);
const gzipByteLen = gzipSync(readFileSync(minPath)).byteLength;
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/__snapshots__/exports.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ Array [
"mockObservableLink",
"mockSingleLink",
"subscribeAndCount",
"tick",
"wait",
"withErrorSpy",
"withLogSpy",
"withWarningSpy",
Expand All @@ -335,6 +337,8 @@ Array [
"mockObservableLink",
"mockSingleLink",
"subscribeAndCount",
"tick",
"wait",
"withErrorSpy",
"withLogSpy",
"withWarningSpy",
Expand Down
Loading

0 comments on commit 5c5ca9b

Please sign in to comment.