From 09d38bf98b282e2f37fda03f43985e59dd472e2b Mon Sep 17 00:00:00 2001 From: Naor Peled Date: Mon, 27 Jan 2025 10:05:10 +0200 Subject: [PATCH 1/8] Update queries.mdx --- docs/source/data/queries.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/data/queries.mdx b/docs/source/data/queries.mdx index bd15ebf1a84..7eef344c6ad 100644 --- a/docs/source/data/queries.mdx +++ b/docs/source/data/queries.mdx @@ -439,6 +439,7 @@ This is the default fetch policy. Apollo Client executes the query _only_ against the cache. It never queries your server in this case. + A `cache-only` query throws an error if the cache does not contain data for all requested fields. @@ -469,6 +470,7 @@ Provides a fast response while also helping to keep cached data consistent with Apollo Client executes the full query against your GraphQL server, _without_ first checking the cache. The query's result _is_ stored in the cache. + Prioritizes consistency with server data, but can't provide a near-instantaneous response when cached data is available. From d43f629f8dee01fc0e3c23bdb6a7b1ab3dac5a83 Mon Sep 17 00:00:00 2001 From: Naor Peled Date: Mon, 27 Jan 2025 10:40:05 +0200 Subject: [PATCH 2/8] Update queries.mdx --- docs/source/data/queries.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/data/queries.mdx b/docs/source/data/queries.mdx index 7eef344c6ad..8c11a7cac6f 100644 --- a/docs/source/data/queries.mdx +++ b/docs/source/data/queries.mdx @@ -455,6 +455,7 @@ A `cache-only` query throws an error if the cache does not contain data for all Apollo Client executes the full query against both the cache _and_ your GraphQL server. The query automatically updates if the result of the server-side query modifies cached fields. + Provides a fast response while also helping to keep cached data consistent with server data. From 63e308c3efb1b826f36ab7629994d5c69e3adce1 Mon Sep 17 00:00:00 2001 From: Maria Elisabeth Schreiber Date: Mon, 27 Jan 2025 09:20:05 -0700 Subject: [PATCH 3/8] Update apollo-link-subscriptions.md --- docs/source/api/link/apollo-link-subscriptions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/api/link/apollo-link-subscriptions.md b/docs/source/api/link/apollo-link-subscriptions.md index 7dc4a71a537..313e33fab4a 100644 --- a/docs/source/api/link/apollo-link-subscriptions.md +++ b/docs/source/api/link/apollo-link-subscriptions.md @@ -33,7 +33,7 @@ const link = new GraphQLWsLink( The `GraphQLWsLink` constructor takes a single argument, which is a `Client` returned from the `graphql-ws` `createClient` function. -The `createClient` function can take many options, described in the [`graphql-ws` docs for `ClientOptions`](https://the-guild.dev/graphql/ws/docs/interfaces/client.ClientOptions). The one required option is `url`, which is the URL (typically starting with `ws://` or `wss://`, which are the equivalents of `http://` and `https://` respectively) to your WebSocket server. (Note that this differs from the [older link's URL option](./apollo-link-ws), which is named `uri` instead of `url`.) +The `createClient` function can take many options, described in the [`graphql-ws` docs for `ClientOptions`](https://the-guild.dev/graphql/ws/docs/client/interfaces/ClientOptions). The one required option is `url`, which is the URL (typically starting with `ws://` or `wss://`, which are the equivalents of `http://` and `https://` respectively) to your WebSocket server. (Note that this differs from the [older link's URL option](./apollo-link-ws), which is named `uri` instead of `url`.) ## Usage From 0ea97e5877e58441392c2e937a4f8933cb0f6edc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 09:21:28 -0700 Subject: [PATCH 4/8] Version Packages (#12293) Co-authored-by: github-actions[bot] --- .changeset/lemon-singers-pay.md | 5 ----- .changeset/ten-rules-stare.md | 5 ----- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 .changeset/lemon-singers-pay.md delete mode 100644 .changeset/ten-rules-stare.md diff --git a/.changeset/lemon-singers-pay.md b/.changeset/lemon-singers-pay.md deleted file mode 100644 index bf013dce813..00000000000 --- a/.changeset/lemon-singers-pay.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Remove unused dependency `response-iterator` diff --git a/.changeset/ten-rules-stare.md b/.changeset/ten-rules-stare.md deleted file mode 100644 index f7d5ebdfa7b..00000000000 --- a/.changeset/ten-rules-stare.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fixes an issue where `client.watchFragment`/`useFragment` with `@includes` crashes when a separate cache update writes to the conditionally included fields. diff --git a/CHANGELOG.md b/CHANGELOG.md index 33b1eb2f84c..fb62dad7b77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # @apollo/client +## 3.12.8 + +### Patch Changes + +- [#12292](https://github.com/apollographql/apollo-client/pull/12292) [`3abd944`](https://github.com/apollographql/apollo-client/commit/3abd944e4adde5d94d91133f2bf6ed1c7744f8c5) Thanks [@phryneas](https://github.com/phryneas)! - Remove unused dependency `response-iterator` + +- [#12287](https://github.com/apollographql/apollo-client/pull/12287) [`bf313a3`](https://github.com/apollographql/apollo-client/commit/bf313a39d342a73dc3e9b3db9415c71c2573db3f) Thanks [@phryneas](https://github.com/phryneas)! - Fixes an issue where `client.watchFragment`/`useFragment` with `@includes` crashes when a separate cache update writes to the conditionally included fields. + ## 3.12.7 ### Patch Changes diff --git a/package-lock.json b/package-lock.json index 5a2cca35bcf..7f9ab4c9b58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apollo/client", - "version": "3.12.7", + "version": "3.12.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apollo/client", - "version": "3.12.7", + "version": "3.12.8", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index dd4d8f617ee..ca77d5bfbc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apollo/client", - "version": "3.12.7", + "version": "3.12.8", "description": "A fully-featured caching GraphQL client.", "private": true, "keywords": [ From 7f71d7e769620501690bf55f4ce6488587b8ff65 Mon Sep 17 00:00:00 2001 From: Maria Elisabeth Schreiber Date: Mon, 27 Jan 2025 12:50:04 -0700 Subject: [PATCH 5/8] Update sidebar --- docs/source/_sidebar.yaml | 177 ++++++++++++++++++++++++++++++++++++++ docs/source/config.json | 107 ----------------------- 2 files changed, 177 insertions(+), 107 deletions(-) create mode 100644 docs/source/_sidebar.yaml delete mode 100644 docs/source/config.json diff --git a/docs/source/_sidebar.yaml b/docs/source/_sidebar.yaml new file mode 100644 index 00000000000..d26de2ac14a --- /dev/null +++ b/docs/source/_sidebar.yaml @@ -0,0 +1,177 @@ +switcher: + heading: "Apollo Client (Web)" + versions: + - label: v3 + latest: true + href: ./ + - label: v2 + href: ./v2 +items: + - label: Introduction + href: "." + - label: Why Apollo Client? + href: ./why-apollo + - label: Get started + href: ./get-started + - label: Changelog + href: https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md + - label: Fetching + children: + - label: Queries + href: ./data/queries + - label: Suspense + href: ./data/suspense + - label: Fragments + href: ./data/fragments + - label: Mutations + href: ./data/mutations + - label: Refetching + href: ./data/refetching + - label: Subscriptions + href: ./data/subscriptions + - label: Directives + href: ./data/directives + - label: Error handling + href: ./data/error-handling + - label: Document transforms + href: ./data/document-transforms + - label: Best practices + href: ./data/operation-best-practices + - label: Caching + children: + - label: Overview + href: ./caching/overview + - label: Configuration + href: ./caching/cache-configuration + - label: Reading and writing + href: ./caching/cache-interaction + - label: Garbage collection and eviction + href: ./caching/garbage-collection + - label: Customizing field behavior + href: ./caching/cache-field-behavior + - label: Memory Management + href: ./caching/memory-management + - label: Advanced topics + href: ./caching/advanced-topics + - label: Pagination + children: + - label: Overview + href: ./pagination/overview + - label: Core API + href: ./pagination/core-api + - label: Offset-based + href: ./pagination/offset-based + - label: Cursor-based + href: ./pagination/cursor-based + - label: keyArgs + href: ./pagination/key-args + - label: Local State + children: + - label: Overview + href: ./local-state/local-state-management + - label: Local-only fields + href: ./local-state/managing-state-with-field-policies + - label: Reactive variables + href: ./local-state/reactive-variables + - label: Client-side schema + href: ./local-state/client-side-schema + - label: Local resolvers + href: ./local-state/local-resolvers + - label: Development & Testing + children: + - label: Developer tools + href: ./development-testing/developer-tooling + - label: Using TypeScript + href: ./development-testing/static-typing + - label: Testing React components + href: ./development-testing/testing + - label: Schema-driven testing + href: ./development-testing/schema-driven-testing + - label: Mocking schema capabilities + href: ./development-testing/client-schema-mocking + - label: Reducing bundle size + href: ./development-testing/reducing-bundle-size + - label: Performance + children: + - label: Improving performance + href: ./performance/performance + - label: Optimistic mutation results + href: ./performance/optimistic-ui + - label: Server-side rendering + href: ./performance/server-side-rendering + - label: Compiling queries with Babel + href: ./performance/babel + - label: Integrations + children: + - label: Using Apollo Client with your view layer + href: ./integrations/integrations + - label: Integrating with React Native + href: ./integrations/react-native + - label: Loading queries with Webpack + href: ./integrations/webpack + - label: Networking + children: + - label: Basic HTTP networking + href: ./networking/basic-http-networking + - label: Advanced HTTP networking + href: ./networking/advanced-http-networking + - label: Authentication + href: ./networking/authentication + - label: Migrating + children: + - label: Migrating to Apollo Client 3.0 + href: ./migrating/apollo-client-3-migration + - label: Hooks migration guide + href: ./migrating/hooks-migration + - label: API Reference + children: + - label: Core + children: + - label: ApolloClient + href: ./api/core/ApolloClient + - label: InMemoryCache + href: ./api/cache/InMemoryCache + - label: ObservableQuery + href: ./api/core/ObservableQuery + - label: React + children: + - label: Hooks + href: ./api/react/hooks + - label: Preloading + href: ./api/react/preloading + - label: Testing + href: ./api/react/testing + - label: SSR + href: ./api/react/ssr + - label: Components (deprecated) + href: ./api/react/components + - label: HOC (deprecated) + href: ./api/react/hoc + - label: Apollo Link + children: + - label: Overview + href: ./api/link/introduction + - label: HTTP + href: ./api/link/apollo-link-http + - label: HTTP Batch + href: ./api/link/apollo-link-batch-http + - label: Context + href: ./api/link/apollo-link-context + - label: Error + href: ./api/link/apollo-link-error + - label: Persisted Queries + href: ./api/link/persisted-queries + - label: Remove Typename + href: ./api/link/apollo-link-remove-typename + - label: REST + href: ./api/link/apollo-link-rest + - label: Retry + href: ./api/link/apollo-link-retry + - label: Schema + href: ./api/link/apollo-link-schema + - label: Subscriptions (newer protocol) + href: ./api/link/apollo-link-subscriptions + - label: WebSocket (older protocol) + href: ./api/link/apollo-link-ws + - label: Community links + href: ./api/link/community-links diff --git a/docs/source/config.json b/docs/source/config.json deleted file mode 100644 index 5e85cecba5f..00000000000 --- a/docs/source/config.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "title": "Client (React)", - "version": "v3", - "algoliaFilters": [ - "docset:apollo-client", - "docset:apollo-server" - ], - "sidebar": { - "Introduction": "/", - "Why Apollo Client?": "/why-apollo", - "Get started": "/get-started", - "Changelog": "https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md", - "Fetching": { - "Queries": "/data/queries", - "Suspense": "/data/suspense", - "Mutations": "/data/mutations", - "Refetching": "/data/refetching", - "Subscriptions": "/data/subscriptions", - "Fragments": "/data/fragments", - "Directives": "/data/directives", - "Error handling": "/data/error-handling", - "Document transforms": "/data/document-transforms", - "Best practices": "/data/operation-best-practices" - }, - "Caching": { - "Overview": "/caching/overview", - "Configuration": "/caching/cache-configuration", - "Reading and writing": "/caching/cache-interaction", - "Garbage collection and eviction": "/caching/garbage-collection", - "Customizing field behavior": "/caching/cache-field-behavior", - "Memory Management": "/caching/memory-management", - "Advanced topics": "/caching/advanced-topics" - }, - "Pagination": { - "Overview": "/pagination/overview", - "Core API": "/pagination/core-api", - "Offset-based": "/pagination/offset-based", - "Cursor-based": "/pagination/cursor-based", - "keyArgs": "/pagination/key-args" - }, - "Local State": { - "Overview": "/local-state/local-state-management", - "Local-only fields": "/local-state/managing-state-with-field-policies", - "Reactive variables": "/local-state/reactive-variables", - "Client-side schema": "/local-state/client-side-schema", - "Local resolvers": "/local-state/local-resolvers" - }, - "Development & Testing": { - "Developer tools": "/development-testing/developer-tooling", - "Using TypeScript": "/development-testing/static-typing", - "Testing React components": "/development-testing/testing", - "Schema-driven testing": "/development-testing/schema-driven-testing", - "Mocking schema capabilities": "/development-testing/client-schema-mocking", - "Reducing bundle size": "/development-testing/reducing-bundle-size" - }, - "Performance": { - "Improving performance": "/performance/performance", - "Optimistic mutation results": "/performance/optimistic-ui", - "Server-side rendering": "/performance/server-side-rendering", - "Compiling queries with Babel": "/performance/babel" - }, - "Integrations": { - "Using Apollo Client with your view layer": "/integrations/integrations", - "Integrating with React Native": "/integrations/react-native", - "Loading queries with Webpack": "/integrations/webpack" - }, - "Networking": { - "Basic HTTP networking": "/networking/basic-http-networking", - "Advanced HTTP networking": "/networking/advanced-http-networking", - "Authentication": "/networking/authentication" - }, - "Migrating": { - "Migrating to Apollo Client 3.0": "/migrating/apollo-client-3-migration", - "Hooks migration guide": "/migrating/hooks-migration" - }, - "API Reference": { - "Core": { - "ApolloClient": "/api/core/ApolloClient", - "InMemoryCache": "/api/cache/InMemoryCache", - "ObservableQuery": "/api/core/ObservableQuery" - }, - "React": { - "Hooks": "/api/react/hooks", - "Preloading": "/api/react/preloading", - "Testing": "/api/react/testing", - "SSR": "/api/react/ssr", - "Components (deprecated)": "/api/react/components", - "HOC (deprecated)": "/api/react/hoc" - }, - "Apollo Link": { - "Overview": "/api/link/introduction", - "HTTP": "/api/link/apollo-link-http", - "HTTP Batch": "/api/link/apollo-link-batch-http", - "Context": "/api/link/apollo-link-context", - "Error": "/api/link/apollo-link-error", - "Persisted Queries": "/api/link/persisted-queries", - "Remove Typename": "/api/link/apollo-link-remove-typename", - "REST": "/api/link/apollo-link-rest", - "Retry": "/api/link/apollo-link-retry", - "Schema": "/api/link/apollo-link-schema", - "Subscriptions (newer protocol)": "/api/link/apollo-link-subscriptions", - "WebSocket (older protocol)": "/api/link/apollo-link-ws", - "Community links": "/api/link/community-links" - } - } - } -} From 45120e86b21f7591cc52b5f3a6e5c116f50951f2 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Wed, 29 Jan 2025 03:35:09 +1100 Subject: [PATCH 6/8] Update fragment doc with Codegen Client Preset support (#12290) --- docs/source/data/fragments.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/data/fragments.mdx b/docs/source/data/fragments.mdx index ee6ccd596f0..d8f4fdf4373 100644 --- a/docs/source/data/fragments.mdx +++ b/docs/source/data/fragments.mdx @@ -1135,7 +1135,7 @@ const config: CodegenConfig = { ##### With the `client-preset` -Support for the `@unmask` directive was introduced with `@graphql-codegen/client-preset` [v4.5.1](https://github.com/dotansimha/graphql-code-generator/releases/tag/release-1732308151614) +Support for the `@unmask` directive was introduced with `@graphql-codegen/client-preset` [v4.6.0](https://github.com/dotansimha/graphql-code-generator/releases/tag/release-1738065376043) You can't use the `client-preset` [Fragment Masking](https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#fragment-masking) and Apollo Client's data masking features simultaneously. @@ -1157,11 +1157,11 @@ To migrate from CodeGen's fragment masking feature to Apollo Client's data maski // ... // disables the incompatible GraphQL Codegen fragment masking feature fragmentMasking: false, + }, + config: { customDirectives: { apolloUnmask: true } - }, - config: { inlineFragmentTypes: "mask", } } From 68e29dd70551f0c9215f879ec20d07fb7c43a6a7 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Tue, 28 Jan 2025 19:18:59 +0100 Subject: [PATCH 7/8] de-flake tests (#12315) --- src/react/hooks/__tests__/useBackgroundQuery.test.tsx | 2 +- src/react/hooks/__tests__/useQuery.test.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx index 6ce0564cc63..a335ede0877 100644 --- a/src/react/hooks/__tests__/useBackgroundQuery.test.tsx +++ b/src/react/hooks/__tests__/useBackgroundQuery.test.tsx @@ -339,7 +339,7 @@ it("will resubscribe after disposed when mounting useReadQuery", async () => { } // Wait long enough for auto dispose to kick in - await wait(50); + await wait(80); expect(client.getObservableQueries().size).toBe(0); expect(client).not.toHaveSuspenseCacheEntryUsing(query); diff --git a/src/react/hooks/__tests__/useQuery.test.tsx b/src/react/hooks/__tests__/useQuery.test.tsx index 355508a22e2..f8b3ae81343 100644 --- a/src/react/hooks/__tests__/useQuery.test.tsx +++ b/src/react/hooks/__tests__/useQuery.test.tsx @@ -2916,7 +2916,7 @@ describe("useQuery Hook", () => { const { takeSnapshot, unmount } = await renderHookToSnapshotStream( () => useQuery(query, { - pollInterval: 10, + pollInterval: 25, fetchPolicy: "cache-and-network", }), { @@ -2955,7 +2955,7 @@ describe("useQuery Hook", () => { expect(requestSpy).toHaveBeenCalledTimes(1); } - await wait(10); + await wait(25); { const result = await takeSnapshot(); From 86f23a4ae9cea0ac35a269e34f52ca7dacacd844 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 29 Jan 2025 10:41:52 -0700 Subject: [PATCH 8/8] Remove `wait-for-observables` in favor of `ObservableStream` (#12317) --- package-lock.json | 16 --------- package.json | 1 - src/link/retry/__tests__/retryLink.ts | 47 ++++++++++++++++----------- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f9ab4c9b58..98f763a6de8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -115,7 +115,6 @@ "tsx": "4.19.2", "typedoc": "0.25.0", "typescript": "5.7.3", - "wait-for-observables": "1.0.3", "web-streams-polyfill": "4.0.0", "whatwg-fetch": "3.6.20" }, @@ -13564,21 +13563,6 @@ "node": ">=12" } }, - "node_modules/wait-for-observables": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/wait-for-observables/-/wait-for-observables-1.0.3.tgz", - "integrity": "sha1-Oz3vX1VrS2QR9giJl0bdOc/cw/M=", - "dev": true, - "dependencies": { - "tslib": "^1.8.0" - } - }, - "node_modules/wait-for-observables/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index ca77d5bfbc9..5b780ebd8d6 100644 --- a/package.json +++ b/package.json @@ -198,7 +198,6 @@ "tsx": "4.19.2", "typedoc": "0.25.0", "typescript": "5.7.3", - "wait-for-observables": "1.0.3", "web-streams-polyfill": "4.0.0", "whatwg-fetch": "3.6.20" }, diff --git a/src/link/retry/__tests__/retryLink.ts b/src/link/retry/__tests__/retryLink.ts index b9f3e14440d..85955021588 100644 --- a/src/link/retry/__tests__/retryLink.ts +++ b/src/link/retry/__tests__/retryLink.ts @@ -1,11 +1,11 @@ import gql from "graphql-tag"; -import waitFor from "wait-for-observables"; import { ApolloLink } from "../../core/ApolloLink"; import { execute } from "../../core/execute"; import { Observable } from "../../../utilities/observables/Observable"; import { fromError } from "../../utils/fromError"; import { RetryLink } from "../retryLink"; +import { ObservableStream } from "../../../testing/internal"; const query = gql` { @@ -23,9 +23,10 @@ describe("RetryLink", () => { const retry = new RetryLink({ delay: { initial: 1 }, attempts: { max } }); const stub = jest.fn(() => fromError(standardError)) as any; const link = ApolloLink.from([retry, stub]); + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitError(standardError, { timeout: 1000 }); - const [{ error }] = (await waitFor(execute(link, { query }))) as any; - expect(error).toEqual(standardError); expect(stub).toHaveBeenCalledTimes(max); }); @@ -34,9 +35,11 @@ describe("RetryLink", () => { const data = { data: { hello: "world" } }; const stub = jest.fn(() => Observable.of(data)); const link = ApolloLink.from([retry, stub]); + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitValue(data); + await expect(stream).toComplete(); - const [{ values }] = (await waitFor(execute(link, { query }))) as any; - expect(values).toEqual([data]); expect(stub).toHaveBeenCalledTimes(1); }); @@ -50,9 +53,11 @@ describe("RetryLink", () => { stub.mockReturnValueOnce(fromError(standardError)); stub.mockReturnValueOnce(Observable.of(data)); const link = ApolloLink.from([retry, stub]); + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitValue(data); + await expect(stream).toComplete(); - const [{ values }] = (await waitFor(execute(link, { query }))) as any; - expect(values).toEqual([data]); expect(stub).toHaveBeenCalledTimes(2); }); @@ -129,13 +134,14 @@ describe("RetryLink", () => { }); const stub = jest.fn(() => fromError(standardError)) as any; const link = ApolloLink.from([retry, stub]); + const stream1 = new ObservableStream(execute(link, { query })); + const stream2 = new ObservableStream(execute(link, { query })); + + await Promise.all([ + expect(stream1).toEmitError(standardError), + expect(stream2).toEmitError(standardError), + ]); - const [result1, result2] = (await waitFor( - execute(link, { query }), - execute(link, { query }) - )) as any; - expect(result1.error).toEqual(standardError); - expect(result2.error).toEqual(standardError); expect(stub).toHaveBeenCalledTimes(10); }); @@ -144,9 +150,10 @@ describe("RetryLink", () => { const retry = new RetryLink({ delay: delayStub, attempts: { max: 3 } }); const linkStub = jest.fn(() => fromError(standardError)) as any; const link = ApolloLink.from([retry, linkStub]); - const [{ error }] = (await waitFor(execute(link, { query }))) as any; + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitError(standardError); - expect(error).toEqual(standardError); const operation = (delayStub.mock.calls[0] as any)[1]; expect(delayStub.mock.calls).toEqual([ [1, operation, standardError], @@ -166,9 +173,10 @@ describe("RetryLink", () => { }); const linkStub = jest.fn(() => fromError(standardError)) as any; const link = ApolloLink.from([retry, linkStub]); - const [{ error }] = (await waitFor(execute(link, { query }))) as any; + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitError(standardError); - expect(error).toEqual(standardError); const operation = attemptStub.mock.calls[0][1]; expect(attemptStub.mock.calls).toEqual([ [1, operation, standardError], @@ -191,9 +199,10 @@ describe("RetryLink", () => { () => new Observable((o) => o.error(standardError)) ) as any; const link = ApolloLink.from([retry, linkStub]); - const [{ error }] = (await waitFor(execute(link, { query }))) as any; + const stream = new ObservableStream(execute(link, { query })); + + await expect(stream).toEmitError(standardError); - expect(error).toEqual(standardError); const operation = attemptStub.mock.calls[0][1]; expect(attemptStub.mock.calls).toEqual([ [1, operation, standardError],