@apollo/client 3.10.3 → 3.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/apollo-client.cjs +166 -134
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +81 -8
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +81 -8
- package/cache/core/cache.js +8 -4
- package/cache/core/cache.js.map +1 -1
- package/core/ApolloClient.js +2 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +7 -11
- package/core/QueryInfo.js.map +1 -1
- package/core/core.cjs +5 -7
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +5 -7
- package/dev/dev.cjs +32 -27
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +32 -27
- package/invariantErrorCodes.js +32 -26
- package/link/batch-http/batch-http.cjs +6 -5
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +6 -5
- package/link/batch-http/batchHttpLink.js +15 -10
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/error/error.cjs +3 -2
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +3 -2
- package/link/error/index.js +3 -2
- package/link/error/index.js.map +1 -1
- package/package.json +10 -6
- package/react/hooks/hooks.cjs +62 -34
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +62 -34
- package/react/hooks/internal/useRenderGuard.js +37 -12
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +10 -13
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.js +7 -8
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +3 -3
- package/react/hooks/useLoadableQuery.js +11 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.js +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -2
- package/react/hooks/useQuery.js +26 -12
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +3 -3
- package/react/hooks/useQueryRefHandlers.js +7 -2
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +2 -2
- package/react/hooks/useReadQuery.js +7 -2
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +4 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +4 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +68 -6
- package/react/internal/cache/QueryReference.js +4 -0
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/index.d.ts +2 -2
- package/react/internal/index.js +1 -1
- package/react/internal/index.js.map +1 -1
- package/react/internal/internal.cjs +92 -0
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +92 -0
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/query-preloader/createQueryPreloader.d.ts +6 -6
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/types.d.ts +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +4 -4
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +4 -4
- package/testing/core/mocking/mockLink.d.ts +8 -3
- package/testing/core/mocking/mockLink.js +5 -5
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/internal/profile/profile.js +6 -2
- package/testing/internal/profile/profile.js.map +1 -1
- package/testing/matchers/toBeDisposed.js +4 -13
- package/testing/matchers/toBeDisposed.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/utilities.cjs +19 -19
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +19 -19
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/client",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.5",
|
|
4
4
|
"description": "A fully-featured caching GraphQL client.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -95,11 +95,11 @@
|
|
|
95
95
|
"@types/react-dom": "18.3.0",
|
|
96
96
|
"@types/relay-runtime": "14.1.23",
|
|
97
97
|
"@types/use-sync-external-store": "0.0.6",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "7.
|
|
99
|
-
"@typescript-eslint/parser": "7.
|
|
100
|
-
"@typescript-eslint/rule-tester": "7.
|
|
101
|
-
"@typescript-eslint/types": "7.
|
|
102
|
-
"@typescript-eslint/utils": "7.
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "7.9.0",
|
|
99
|
+
"@typescript-eslint/parser": "7.9.0",
|
|
100
|
+
"@typescript-eslint/rule-tester": "7.9.0",
|
|
101
|
+
"@typescript-eslint/types": "7.9.0",
|
|
102
|
+
"@typescript-eslint/utils": "7.9.0",
|
|
103
103
|
"acorn": "8.11.3",
|
|
104
104
|
"blob-polyfill": "7.0.20220408",
|
|
105
105
|
"bytes": "3.1.2",
|
|
@@ -108,6 +108,8 @@
|
|
|
108
108
|
"eslint-import-resolver-typescript": "3.6.1",
|
|
109
109
|
"eslint-plugin-import": "npm:@phryneas/eslint-plugin-import@2.27.5-pr.2813.2817.199971c",
|
|
110
110
|
"eslint-plugin-local-rules": "2.0.1",
|
|
111
|
+
"eslint-plugin-react-compiler": "0.0.0-experimental-c8b3f72-20240517",
|
|
112
|
+
"eslint-plugin-react-hooks": "4.6.2",
|
|
111
113
|
"eslint-plugin-testing-library": "6.2.2",
|
|
112
114
|
"expect-type": "0.19.0",
|
|
113
115
|
"fetch-mock": "9.11.0",
|
|
@@ -122,8 +124,10 @@
|
|
|
122
124
|
"prettier": "3.1.1",
|
|
123
125
|
"react": "18.3.1",
|
|
124
126
|
"react-17": "npm:react@^17",
|
|
127
|
+
"react-19": "npm:react@19.0.0-rc-cc1ec60d0d-20240607",
|
|
125
128
|
"react-dom": "18.3.1",
|
|
126
129
|
"react-dom-17": "npm:react-dom@^17",
|
|
130
|
+
"react-dom-19": "npm:react-dom@19.0.0-rc-cc1ec60d0d-20240607",
|
|
127
131
|
"react-error-boundary": "4.0.13",
|
|
128
132
|
"recast": "0.23.6",
|
|
129
133
|
"resolve": "1.22.8",
|
package/react/hooks/hooks.cjs
CHANGED
|
@@ -95,15 +95,26 @@ function useDeepMemo(memoFn, deps) {
|
|
|
95
95
|
return ref.current.value;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
|
|
101
|
-
}
|
|
102
|
-
var RenderDispatcher = null;
|
|
98
|
+
var Ctx;
|
|
99
|
+
function noop() { }
|
|
103
100
|
function useRenderGuard() {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
if (!Ctx) {
|
|
102
|
+
Ctx = React__namespace.createContext(null);
|
|
103
|
+
}
|
|
104
|
+
return React__namespace.useCallback(
|
|
105
|
+
function () {
|
|
106
|
+
var orig = console.error;
|
|
107
|
+
try {
|
|
108
|
+
console.error = noop;
|
|
109
|
+
React__namespace["useContext" ](Ctx);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
console.error = orig;
|
|
117
|
+
}
|
|
107
118
|
}, []);
|
|
108
119
|
}
|
|
109
120
|
|
|
@@ -148,14 +159,16 @@ function _useQuery(query, options) {
|
|
|
148
159
|
return useInternalState(useApolloClient(options.client), query).useQuery(options);
|
|
149
160
|
}
|
|
150
161
|
function useInternalState(client, query) {
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
var forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
|
|
163
|
+
function createInternalState(previous) {
|
|
164
|
+
return Object.assign(new InternalState(client, query, previous), {
|
|
165
|
+
forceUpdateState: forceUpdateState,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
var _a = React__namespace.useState(createInternalState), state = _a[0], updateState = _a[1];
|
|
169
|
+
if (client !== state.client || query !== state.query) {
|
|
170
|
+
updateState((state = createInternalState(state)));
|
|
156
171
|
}
|
|
157
|
-
var state = stateRef.current;
|
|
158
|
-
state.forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
|
|
159
172
|
return state;
|
|
160
173
|
}
|
|
161
174
|
var InternalState = (function () {
|
|
@@ -218,7 +231,8 @@ var InternalState = (function () {
|
|
|
218
231
|
this.renderPromises = React__namespace.useContext(context.getApolloContext()).renderPromises;
|
|
219
232
|
this.useOptions(options);
|
|
220
233
|
var obsQuery = this.useObservableQuery();
|
|
221
|
-
var result = useSyncExternalStore(
|
|
234
|
+
var result = useSyncExternalStore(
|
|
235
|
+
React__namespace.useCallback(function (handleStoreChange) {
|
|
222
236
|
if (_this.renderPromises) {
|
|
223
237
|
return function () { };
|
|
224
238
|
}
|
|
@@ -453,17 +467,15 @@ function useLazyQuery(query, options) {
|
|
|
453
467
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
454
468
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
455
469
|
internalState.getDefaultFetchPolicy();
|
|
456
|
-
var
|
|
457
|
-
called: !!execOptionsRef.current,
|
|
458
|
-
});
|
|
470
|
+
var forceUpdateState = internalState.forceUpdateState, obsQueryFields = internalState.obsQueryFields;
|
|
459
471
|
var eagerMethods = React__namespace.useMemo(function () {
|
|
460
472
|
var eagerMethods = {};
|
|
461
473
|
var _loop_1 = function (key) {
|
|
462
|
-
var method =
|
|
474
|
+
var method = obsQueryFields[key];
|
|
463
475
|
eagerMethods[key] = function () {
|
|
464
476
|
if (!execOptionsRef.current) {
|
|
465
477
|
execOptionsRef.current = Object.create(null);
|
|
466
|
-
|
|
478
|
+
forceUpdateState();
|
|
467
479
|
}
|
|
468
480
|
return method.apply(this, arguments);
|
|
469
481
|
};
|
|
@@ -473,8 +485,9 @@ function useLazyQuery(query, options) {
|
|
|
473
485
|
_loop_1(key);
|
|
474
486
|
}
|
|
475
487
|
return eagerMethods;
|
|
476
|
-
}, []);
|
|
477
|
-
|
|
488
|
+
}, [forceUpdateState, obsQueryFields]);
|
|
489
|
+
var called = !!execOptionsRef.current;
|
|
490
|
+
var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
|
|
478
491
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
479
492
|
execOptionsRef.current =
|
|
480
493
|
executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
@@ -486,7 +499,7 @@ function useLazyQuery(query, options) {
|
|
|
486
499
|
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
487
500
|
promise.catch(function () { });
|
|
488
501
|
return promise;
|
|
489
|
-
}, []);
|
|
502
|
+
}, [eagerMethods, initialFetchPolicy, internalState]);
|
|
490
503
|
return [execute, result];
|
|
491
504
|
}
|
|
492
505
|
|
|
@@ -506,9 +519,9 @@ function useMutation(mutation, options) {
|
|
|
506
519
|
mutation: mutation,
|
|
507
520
|
options: options,
|
|
508
521
|
});
|
|
509
|
-
{
|
|
522
|
+
React__namespace.useLayoutEffect(function () {
|
|
510
523
|
Object.assign(ref.current, { client: client, options: options, mutation: mutation });
|
|
511
|
-
}
|
|
524
|
+
});
|
|
512
525
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
513
526
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
514
527
|
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
@@ -582,15 +595,20 @@ function useMutation(mutation, options) {
|
|
|
582
595
|
}, []);
|
|
583
596
|
var reset = React__namespace.useCallback(function () {
|
|
584
597
|
if (ref.current.isMounted) {
|
|
585
|
-
var result_3 = {
|
|
598
|
+
var result_3 = {
|
|
599
|
+
called: false,
|
|
600
|
+
loading: false,
|
|
601
|
+
client: ref.current.client,
|
|
602
|
+
};
|
|
586
603
|
Object.assign(ref.current, { mutationId: 0, result: result_3 });
|
|
587
604
|
setResult(result_3);
|
|
588
605
|
}
|
|
589
606
|
}, []);
|
|
590
607
|
React__namespace.useEffect(function () {
|
|
591
|
-
|
|
608
|
+
var current = ref.current;
|
|
609
|
+
current.isMounted = true;
|
|
592
610
|
return function () {
|
|
593
|
-
|
|
611
|
+
current.isMounted = false;
|
|
594
612
|
};
|
|
595
613
|
}, []);
|
|
596
614
|
return [execute, tslib.__assign({ reset: reset }, result)];
|
|
@@ -846,11 +864,11 @@ function _useSuspenseQuery(query, options) {
|
|
|
846
864
|
};
|
|
847
865
|
}, [queryRef.result]);
|
|
848
866
|
var result = fetchPolicy === "standby" ? skipResult : __use(promise);
|
|
849
|
-
var fetchMore = React__namespace.useCallback(
|
|
867
|
+
var fetchMore = React__namespace.useCallback(function (options) {
|
|
850
868
|
var promise = queryRef.fetchMore(options);
|
|
851
869
|
setPromise([queryRef.key, queryRef.promise]);
|
|
852
870
|
return promise;
|
|
853
|
-
}
|
|
871
|
+
}, [queryRef]);
|
|
854
872
|
var refetch = React__namespace.useCallback(function (variables) {
|
|
855
873
|
var promise = queryRef.refetch(variables);
|
|
856
874
|
setPromise([queryRef.key, queryRef.promise]);
|
|
@@ -975,6 +993,7 @@ function useLoadableQuery(query, options) {
|
|
|
975
993
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
976
994
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
977
995
|
var _b = React__namespace.useState(null), queryRef = _b[0], setQueryRef = _b[1];
|
|
996
|
+
internal.assertWrappedQueryRef(queryRef);
|
|
978
997
|
var internalQueryRef = queryRef && internal.unwrapQueryRef(queryRef);
|
|
979
998
|
if (queryRef && (internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.didChangeOptions(watchQueryOptions))) {
|
|
980
999
|
var promise = internalQueryRef.applyOptions(watchQueryOptions);
|
|
@@ -1012,10 +1031,17 @@ function useLoadableQuery(query, options) {
|
|
|
1012
1031
|
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
1013
1032
|
});
|
|
1014
1033
|
setQueryRef(internal.wrapQueryRef(queryRef));
|
|
1015
|
-
}, [
|
|
1034
|
+
}, [
|
|
1035
|
+
query,
|
|
1036
|
+
queryKey,
|
|
1037
|
+
suspenseCache,
|
|
1038
|
+
watchQueryOptions,
|
|
1039
|
+
calledDuringRender,
|
|
1040
|
+
client,
|
|
1041
|
+
]);
|
|
1016
1042
|
var reset = React__namespace.useCallback(function () {
|
|
1017
1043
|
setQueryRef(null);
|
|
1018
|
-
}, [
|
|
1044
|
+
}, []);
|
|
1019
1045
|
return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset }];
|
|
1020
1046
|
}
|
|
1021
1047
|
|
|
@@ -1026,6 +1052,7 @@ function useQueryRefHandlers(queryRef) {
|
|
|
1026
1052
|
: useApolloClient())(queryRef);
|
|
1027
1053
|
}
|
|
1028
1054
|
function _useQueryRefHandlers(queryRef) {
|
|
1055
|
+
internal.assertWrappedQueryRef(queryRef);
|
|
1029
1056
|
var _a = React__namespace.useState(queryRef), previousQueryRef = _a[0], setPreviousQueryRef = _a[1];
|
|
1030
1057
|
var _b = React__namespace.useState(queryRef), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
1031
1058
|
var internalQueryRef = internal.unwrapQueryRef(queryRef);
|
|
@@ -1056,6 +1083,7 @@ function useReadQuery(queryRef) {
|
|
|
1056
1083
|
: useApolloClient())(queryRef);
|
|
1057
1084
|
}
|
|
1058
1085
|
function _useReadQuery(queryRef) {
|
|
1086
|
+
internal.assertWrappedQueryRef(queryRef);
|
|
1059
1087
|
var internalQueryRef = React__namespace.useMemo(function () { return internal.unwrapQueryRef(queryRef); }, [queryRef]);
|
|
1060
1088
|
var getPromise = React__namespace.useCallback(function () { return internal.getWrappedPromise(queryRef); }, [queryRef]);
|
|
1061
1089
|
if (internalQueryRef.disposed) {
|
|
@@ -1068,7 +1096,7 @@ function _useReadQuery(queryRef) {
|
|
|
1068
1096
|
internal.updateWrappedQueryRef(queryRef, promise);
|
|
1069
1097
|
forceUpdate();
|
|
1070
1098
|
});
|
|
1071
|
-
}, [internalQueryRef]), getPromise, getPromise);
|
|
1099
|
+
}, [internalQueryRef, queryRef]), getPromise, getPromise);
|
|
1072
1100
|
var result = __use(promise);
|
|
1073
1101
|
return React__namespace.useMemo(function () {
|
|
1074
1102
|
return {
|