From d1a905461d4378522c3257de00afba2ae8decd22 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 16 Dec 2024 02:22:32 -0700 Subject: [PATCH 1/2] Drop support for React 16 (#12222) --- .changeset/clever-zebras-mate.md | 5 +++++ .circleci/config.yml | 1 - package-lock.json | 4 ++-- package.json | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changeset/clever-zebras-mate.md diff --git a/.changeset/clever-zebras-mate.md b/.changeset/clever-zebras-mate.md new file mode 100644 index 0000000000..5832f7649f --- /dev/null +++ b/.changeset/clever-zebras-mate.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": major +--- + +Drop support for React 16. diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b1adebcaf..a7341fbe87 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -178,7 +178,6 @@ workflows: - "graphql@15" - "graphql@16" - "graphql@^17.0.0-alpha" - - "@types/react@16.8 @types/react-dom@16.8" - "@types/react@17 @types/react-dom@17" - "@types/react@18 @types/react-dom@18" - "@types/react@19 @types/react-dom@19" diff --git a/package-lock.json b/package-lock.json index b4b5f3c140..5f979dcd65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -119,8 +119,8 @@ "peerDependencies": { "graphql": "^15.0.0 || ^16.0.0", "graphql-ws": "^5.5.5", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc", + "react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc", + "react-dom": "^17.0.0 || ^18.0.0 || >=19.0.0-rc", "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" }, "peerDependenciesMeta": { diff --git a/package.json b/package.json index 7b8d02741a..cb4b03db48 100644 --- a/package.json +++ b/package.json @@ -74,8 +74,8 @@ "peerDependencies": { "graphql": "^15.0.0 || ^16.0.0", "graphql-ws": "^5.5.5", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc", + "react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc", + "react-dom": "^17.0.0 || ^18.0.0 || >=19.0.0-rc", "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" }, "peerDependenciesMeta": { From 69c1cb6f831941598987185238a299b050a364bd Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 16 Dec 2024 02:32:24 -0700 Subject: [PATCH 2/2] Remove `subscribeAndCount` testing utility (#12223) Co-authored-by: Lenz Weber-Tronic Co-authored-by: phryneas --- .api-reports/api-report-testing.api.md | 3 -- .api-reports/api-report-testing_core.api.md | 3 -- .changeset/shiny-carrots-invent.md | 5 ++++ src/__tests__/__snapshots__/exports.ts.snap | 2 -- src/testing/core/index.ts | 1 - src/testing/core/subscribeAndCount.ts | 32 --------------------- 6 files changed, 5 insertions(+), 41 deletions(-) create mode 100644 .changeset/shiny-carrots-invent.md delete mode 100644 src/testing/core/subscribeAndCount.ts diff --git a/.api-reports/api-report-testing.api.md b/.api-reports/api-report-testing.api.md index 00f01de37d..2b2bd0e052 100644 --- a/.api-reports/api-report-testing.api.md +++ b/.api-reports/api-report-testing.api.md @@ -1814,9 +1814,6 @@ Item // @public (undocumented) type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object; -// @public (undocumented) -export function subscribeAndCount(reject: (reason: any) => any, observable: Observable, cb: (handleCount: number, result: TResult) => any): Subscription; - // @public (undocumented) type SubscribeToMoreOptions = { document: DocumentNode | TypedDocumentNode; diff --git a/.api-reports/api-report-testing_core.api.md b/.api-reports/api-report-testing_core.api.md index 1606498c68..473326a16a 100644 --- a/.api-reports/api-report-testing_core.api.md +++ b/.api-reports/api-report-testing_core.api.md @@ -1771,9 +1771,6 @@ Item // @public (undocumented) type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object; -// @public (undocumented) -export function subscribeAndCount(reject: (reason: any) => any, observable: Observable, cb: (handleCount: number, result: TResult) => any): Subscription; - // @public (undocumented) type SubscribeToMoreOptions = { document: DocumentNode | TypedDocumentNode; diff --git a/.changeset/shiny-carrots-invent.md b/.changeset/shiny-carrots-invent.md new file mode 100644 index 0000000000..0ba9824650 --- /dev/null +++ b/.changeset/shiny-carrots-invent.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": major +--- + +Remove `subscribeAndCount` testing utility from `@apollo/client/testing`. diff --git a/src/__tests__/__snapshots__/exports.ts.snap b/src/__tests__/__snapshots__/exports.ts.snap index 7765424785..1019413b6b 100644 --- a/src/__tests__/__snapshots__/exports.ts.snap +++ b/src/__tests__/__snapshots__/exports.ts.snap @@ -363,7 +363,6 @@ Array [ "itAsync", "mockObservableLink", "mockSingleLink", - "subscribeAndCount", "tick", "wait", "withErrorSpy", @@ -380,7 +379,6 @@ Array [ "itAsync", "mockObservableLink", "mockSingleLink", - "subscribeAndCount", "tick", "wait", "withErrorSpy", diff --git a/src/testing/core/index.ts b/src/testing/core/index.ts index e999590509..94af1dbe3e 100644 --- a/src/testing/core/index.ts +++ b/src/testing/core/index.ts @@ -9,7 +9,6 @@ export { mockObservableLink, } from "./mocking/mockSubscriptionLink.js"; export { createMockClient } from "./mocking/mockClient.js"; -export { default as subscribeAndCount } from "./subscribeAndCount.js"; export { itAsync } from "./itAsync.js"; export { wait, tick } from "./wait.js"; export * from "./withConsoleSpy.js"; diff --git a/src/testing/core/subscribeAndCount.ts b/src/testing/core/subscribeAndCount.ts deleted file mode 100644 index 4b366193b5..0000000000 --- a/src/testing/core/subscribeAndCount.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { - ObservableSubscription, - Observable, -} from "../../utilities/index.js"; -import { asyncMap } from "../../utilities/index.js"; - -export default function subscribeAndCount( - reject: (reason: any) => any, - observable: Observable, - cb: (handleCount: number, result: TResult) => any -): ObservableSubscription { - // Use a Promise queue to prevent callbacks from being run out of order. - let queue = Promise.resolve(); - let handleCount = 0; - - const subscription = asyncMap(observable, (result) => { - // All previous asynchronous callbacks must complete before cb can - // be invoked with this result. - return (queue = queue - .then(() => { - return cb(++handleCount, result); - }) - .catch(error)); - }).subscribe({ error }); - - function error(e: any) { - subscription.unsubscribe(); - reject(e); - } - - return subscription; -}