@apollo/client
Advanced tools
Comparing version 3.10.1 to 3.10.2
@@ -431,3 +431,3 @@ 'use strict'; | ||
var version = "3.10.1"; | ||
var version = "3.10.2"; | ||
@@ -434,0 +434,0 @@ function maybe(thunk) { |
import type { Operation } from "../core/index.js"; | ||
export declare const selectURI: (operation: Operation, fallbackURI?: string | ((operation: Operation) => string) | undefined) => any; | ||
export declare const selectURI: (operation: Operation, fallbackURI?: string | ((operation: Operation) => string)) => any; | ||
//# sourceMappingURL=selectURI.d.ts.map |
{ | ||
"name": "@apollo/client", | ||
"version": "3.10.1", | ||
"version": "3.10.2", | ||
"description": "A fully-featured caching GraphQL client.", | ||
@@ -70,4 +70,4 @@ "private": false, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.15.2", | ||
"@babel/parser": "7.24.1", | ||
"@arethetypeswrong/cli": "0.15.3", | ||
"@babel/parser": "7.24.5", | ||
"@changesets/changelog-github": "0.5.0", | ||
@@ -78,3 +78,3 @@ "@changesets/cli": "2.27.1", | ||
"@graphql-tools/utils": "10.0.13", | ||
"@microsoft/api-extractor": "7.42.3", | ||
"@microsoft/api-extractor": "7.43.1", | ||
"@rollup/plugin-node-resolve": "11.2.1", | ||
@@ -84,3 +84,3 @@ "@size-limit/esbuild-why": "11.1.2", | ||
"@testing-library/jest-dom": "6.4.2", | ||
"@testing-library/react": "14.2.2", | ||
"@testing-library/react": "15.0.6", | ||
"@testing-library/react-12": "npm:@testing-library/react@^12", | ||
@@ -114,3 +114,3 @@ "@testing-library/user-event": "14.5.2", | ||
"eslint-plugin-local-rules": "2.0.1", | ||
"eslint-plugin-testing-library": "6.2.0", | ||
"eslint-plugin-testing-library": "6.2.2", | ||
"expect-type": "0.18.0", | ||
@@ -148,3 +148,3 @@ "fetch-mock": "9.11.0", | ||
"typedoc": "0.25.0", | ||
"typescript": "5.4.3", | ||
"typescript": "5.4.5", | ||
"wait-for-observables": "1.0.3", | ||
@@ -151,0 +151,0 @@ "web-streams-polyfill": "4.0.0", |
@@ -839,8 +839,2 @@ 'use strict'; | ||
}, [queryRef]); | ||
React__namespace.useEffect(function () { | ||
if (queryRef.disposed) { | ||
suspenseCache.add(cacheKey, queryRef); | ||
queryRef.reinitialize(); | ||
} | ||
}); | ||
var skipResult = React__namespace.useMemo(function () { | ||
@@ -954,5 +948,8 @@ var error = toApolloError(queryRef.result); | ||
React__namespace.useEffect(function () { | ||
if (queryRef.disposed) { | ||
suspenseCache.add(cacheKey, queryRef); | ||
} | ||
var id = setTimeout(function () { | ||
if (queryRef.disposed) { | ||
suspenseCache.add(cacheKey, queryRef); | ||
} | ||
}); | ||
return function () { return clearTimeout(id); }; | ||
}); | ||
@@ -1070,8 +1067,3 @@ var fetchMore = React__namespace.useCallback(function (options) { | ||
} | ||
React__namespace.useEffect(function () { | ||
if (internalQueryRef.disposed) { | ||
internalQueryRef.reinitialize(); | ||
} | ||
return internalQueryRef.retain(); | ||
}, [internalQueryRef]); | ||
React__namespace.useEffect(function () { return internalQueryRef.retain(); }, [internalQueryRef]); | ||
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) { | ||
@@ -1078,0 +1070,0 @@ return internalQueryRef.listen(function (promise) { |
@@ -41,12 +41,16 @@ import { __spreadArray } from "tslib"; | ||
} | ||
// Handle strict mode where the query ref might be disposed when useEffect | ||
// runs twice. We add the queryRef back in the suspense cache so that the next | ||
// render will reuse this queryRef rather than initializing a new instance. | ||
// This also prevents issues where rerendering useBackgroundQuery after the | ||
// queryRef has been disposed, either automatically or by unmounting | ||
// useReadQuery will ensure the same queryRef is maintained. | ||
// This prevents issues where rerendering useBackgroundQuery after the | ||
// queryRef has been disposed would cause the hook to return a new queryRef | ||
// instance since disposal also removes it from the suspense cache. We add | ||
// the queryRef back in the suspense cache so that the next render will reuse | ||
// this queryRef rather than initializing a new instance. | ||
React.useEffect(function () { | ||
if (queryRef.disposed) { | ||
suspenseCache.add(cacheKey, queryRef); | ||
} | ||
// Since the queryRef is disposed async via `setTimeout`, we have to wait a | ||
// tick before checking it and adding back to the suspense cache. | ||
var id = setTimeout(function () { | ||
if (queryRef.disposed) { | ||
suspenseCache.add(cacheKey, queryRef); | ||
} | ||
}); | ||
return function () { return clearTimeout(id); }; | ||
// Omitting the deps is intentional. This avoids stale closures and the | ||
@@ -53,0 +57,0 @@ // conditional ensures we aren't running the logic on each render. |
@@ -24,12 +24,3 @@ import * as React from "rehackt"; | ||
} | ||
React.useEffect(function () { | ||
// It may seem odd that we are trying to reinitialize the queryRef even | ||
// though we reinitialize in render above, but this is necessary to | ||
// handle strict mode where this useEffect will be run twice resulting in a | ||
// disposed queryRef before the next render. | ||
if (internalQueryRef.disposed) { | ||
internalQueryRef.reinitialize(); | ||
} | ||
return internalQueryRef.retain(); | ||
}, [internalQueryRef]); | ||
React.useEffect(function () { return internalQueryRef.retain(); }, [internalQueryRef]); | ||
var promise = useSyncExternalStore(React.useCallback(function (forceUpdate) { | ||
@@ -36,0 +27,0 @@ return internalQueryRef.listen(function (promise) { |
@@ -53,29 +53,2 @@ import { __assign, __spreadArray } from "tslib"; | ||
}, [queryRef]); | ||
// This effect handles the case where strict mode causes the queryRef to get | ||
// disposed early. Previously this was done by using a `setTimeout` inside the | ||
// dispose function, but this could cause some issues in cases where someone | ||
// might expect the queryRef to be disposed immediately. For example, when | ||
// using the same client instance across multiple tests in a test suite, the | ||
// `setTimeout` has the possibility of retaining the suspense cache entry for | ||
// too long, which means that two tests might accidentally share the same | ||
// `queryRef` instance. By immediately disposing, we can avoid this situation. | ||
// | ||
// Instead we can leverage the work done to allow the queryRef to "resume" | ||
// after it has been disposed without executing an additional network request. | ||
// This is done by calling the `initialize` function below. | ||
React.useEffect(function () { | ||
if (queryRef.disposed) { | ||
// Calling the `dispose` function removes it from the suspense cache, so | ||
// when the component rerenders, it instantiates a fresh query ref. | ||
// We address this by adding the queryRef back to the suspense cache | ||
// so that the lookup on the next render uses the existing queryRef rather | ||
// than instantiating a new one. | ||
suspenseCache.add(cacheKey, queryRef); | ||
queryRef.reinitialize(); | ||
} | ||
// We can omit the deps here to get a fresh closure each render since the | ||
// conditional will prevent the logic from running in most cases. This | ||
// should also be a touch faster since it should be faster to check the `if` | ||
// statement than for React to compare deps on this effect. | ||
}); | ||
var skipResult = React.useMemo(function () { | ||
@@ -82,0 +55,0 @@ var error = toApolloError(queryRef.result); |
@@ -129,5 +129,7 @@ import { __assign } from "tslib"; | ||
_this.references--; | ||
if (!_this.references) { | ||
_this.dispose(); | ||
} | ||
setTimeout(function () { | ||
if (!_this.references) { | ||
_this.dispose(); | ||
} | ||
}); | ||
}; | ||
@@ -134,0 +136,0 @@ }; |
@@ -116,5 +116,7 @@ 'use strict'; | ||
_this.references--; | ||
if (!_this.references) { | ||
_this.dispose(); | ||
} | ||
setTimeout(function () { | ||
if (!_this.references) { | ||
_this.dispose(); | ||
} | ||
}); | ||
}; | ||
@@ -121,0 +123,0 @@ }; |
/// <reference types="node" /> | ||
import { validate } from "graphql"; | ||
import type { GraphQLSchema } from "graphql"; | ||
@@ -4,0 +3,0 @@ /** |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var version = "3.10.1"; | ||
var version = "3.10.2"; | ||
@@ -10,0 +10,0 @@ function maybe(thunk) { |
import { Observable } from "../../index.js"; | ||
import type { CreateMultipartSubscriptionOptions } from "../shared.js"; | ||
export declare function createFetchMultipartSubscription(uri: string, { fetch: preferredFetch, headers }?: CreateMultipartSubscriptionOptions): ({ query, variables, }: { | ||
query?: string | undefined; | ||
query?: string; | ||
variables: undefined | Record<string, any>; | ||
}) => Observable<unknown>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export var version = "3.10.1"; | ||
export var version = "3.10.2"; | ||
//# sourceMappingURL=version.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6836464
59568