@apollo/client 4.0.0-alpha.11 → 4.0.0-alpha.12
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/.changeset/brave-moons-juggle.md +5 -0
- package/.changeset/pre.json +5 -0
- package/.changeset/short-tomatoes-attend.md +5 -0
- package/.changeset/silly-seas-confess.md +5 -0
- package/.changeset/sour-kids-deliver.md +5 -0
- package/.changeset/witty-paws-marry.md +26 -0
- package/CHANGELOG.md +37 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +15 -22
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +4 -21
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/LocalState.cjs.map +1 -1
- package/__cjs/core/LocalState.d.cts +1 -1
- package/__cjs/core/ObservableQuery.cjs +5 -5
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +1 -1
- package/__cjs/core/QueryManager.cjs +11 -11
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +9 -9
- package/__cjs/core/index.cjs +7 -7
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -2
- package/__cjs/core/types.d.cts +3 -3
- package/__cjs/core/watchQueryOptions.d.cts +4 -4
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +1 -1
- package/__cjs/invariantErrorCodes.cjs +47 -37
- package/__cjs/link/batch/batchLink.cjs +2 -2
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +2 -2
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/batching.d.cts +1 -1
- package/__cjs/link/batch-http/batchHttpLink.cjs +2 -2
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +2 -2
- package/__cjs/link/context/index.cjs +2 -2
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +2 -2
- package/__cjs/link/core/types.d.cts +4 -4
- package/__cjs/link/error/index.cjs +3 -3
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +2 -2
- package/__cjs/link/http/HttpLink.cjs +2 -2
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +2 -2
- package/__cjs/link/http/createHttpLink.cjs +2 -2
- package/__cjs/link/http/createHttpLink.cjs.map +1 -1
- package/__cjs/link/http/createHttpLink.d.cts +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.d.cts +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +1 -1
- package/__cjs/link/http/selectURI.cjs.map +1 -1
- package/__cjs/link/http/selectURI.d.cts +1 -1
- package/__cjs/link/{core/index.cjs → index.cjs} +6 -6
- package/__cjs/link/index.cjs.map +1 -0
- package/__cjs/link/index.d.cts +8 -0
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +2 -2
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -2
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +1 -1
- package/__cjs/link/retry/delayFunction.cjs.map +1 -1
- package/__cjs/link/retry/delayFunction.d.cts +1 -1
- package/__cjs/link/retry/retryFunction.cjs.map +1 -1
- package/__cjs/link/retry/retryFunction.d.cts +1 -1
- package/__cjs/link/retry/retryLink.cjs +2 -2
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +2 -2
- package/__cjs/link/schema/index.cjs +2 -2
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +2 -2
- package/__cjs/link/subscriptions/index.cjs +2 -2
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/subscriptions/index.d.cts +2 -2
- package/__cjs/link/utils/createOperation.cjs.map +1 -1
- package/__cjs/link/utils/createOperation.d.cts +1 -1
- package/__cjs/link/utils/transformOperation.cjs.map +1 -1
- package/__cjs/link/utils/transformOperation.d.cts +1 -1
- package/__cjs/link/utils/validateOperation.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.d.cts +1 -1
- package/__cjs/link/ws/index.cjs +2 -2
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +2 -2
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +13 -13
- package/__cjs/react/types/deprecated.d.cts +3 -3
- package/__cjs/testing/core/mocking/mockLink.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +2 -2
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs +2 -2
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +2 -2
- package/__cjs/testing/internal/link.cjs +7 -1
- package/__cjs/testing/internal/link.cjs.map +1 -1
- package/__cjs/testing/internal/link.d.cts +3 -2
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +1 -1
- package/__cjs/utilities/common/errorHandling.cjs.map +1 -1
- package/__cjs/utilities/common/errorHandling.d.cts +1 -1
- package/__cjs/utilities/common/incrementalResult.cjs.map +1 -1
- package/__cjs/utilities/common/incrementalResult.d.cts +1 -1
- package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/common/mergeOptions.d.cts +2 -2
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +4 -21
- package/core/ApolloClient.js +15 -22
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +1 -1
- package/core/LocalState.js +2 -2
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.js +5 -5
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +9 -9
- package/core/QueryManager.js +9 -9
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +2 -2
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +3 -3
- package/core/watchQueryOptions.d.ts +4 -4
- package/errors/index.d.ts +1 -1
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +47 -37
- package/legacyEntryPoints/link/index.d.ts +1 -0
- package/legacyEntryPoints/link/index.js +1 -0
- package/legacyEntryPoints/link/link.cjs +1 -0
- package/legacyEntryPoints/link/link.d.cts +1 -0
- package/link/batch/batchLink.d.ts +2 -2
- package/link/batch/batchLink.js +1 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batchHttpLink.d.ts +2 -2
- package/link/batch-http/batchHttpLink.js +1 -1
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +2 -2
- package/link/context/index.js +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/types.d.ts +4 -4
- package/link/error/index.d.ts +2 -2
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +2 -2
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/createHttpLink.d.ts +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +1 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/index.d.ts +8 -0
- package/link/index.js +7 -0
- package/link/index.js.map +1 -0
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.js +1 -1
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +2 -2
- package/link/retry/retryLink.js +1 -1
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +2 -2
- package/link/schema/index.js +1 -1
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +2 -2
- package/link/subscriptions/index.js +1 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/createOperation.d.ts +1 -1
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/transformOperation.d.ts +1 -1
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +2 -2
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +12 -12
- package/react/hooks/useMutation.d.ts +13 -13
- package/react/hooks/useMutation.js.map +1 -1
- package/react/types/deprecated.d.ts +3 -3
- package/testing/core/mocking/mockLink.d.ts +2 -2
- package/testing/core/mocking/mockLink.js +1 -1
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +2 -2
- package/testing/core/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/internal/link.d.ts +3 -2
- package/testing/internal/link.js +7 -1
- package/testing/internal/link.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +1 -1
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +1 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +2 -2
- package/utilities/common/mergeOptions.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/link/core/index.cjs.map +0 -1
- package/__cjs/link/core/index.d.cts +0 -8
- package/legacyEntryPoints/link/core/core.cjs +0 -1
- package/legacyEntryPoints/link/core/core.d.cts +0 -1
- package/legacyEntryPoints/link/core/index.d.ts +0 -1
- package/legacyEntryPoints/link/core/index.js +0 -1
- package/link/core/index.d.ts +0 -8
- package/link/core/index.js +0 -7
- package/link/core/index.js.map +0 -1
package/.changeset/pre.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"afraid-grapes-call",
|
|
9
9
|
"afraid-moons-arrive",
|
|
10
10
|
"beige-mirrors-talk",
|
|
11
|
+
"brave-moons-juggle",
|
|
11
12
|
"brave-radios-wait",
|
|
12
13
|
"bright-ads-share",
|
|
13
14
|
"calm-frogs-remain",
|
|
@@ -99,7 +100,9 @@
|
|
|
99
100
|
"shiny-carrots-invent",
|
|
100
101
|
"short-jokes-jam",
|
|
101
102
|
"short-months-complain",
|
|
103
|
+
"short-tomatoes-attend",
|
|
102
104
|
"silly-knives-exist",
|
|
105
|
+
"silly-seas-confess",
|
|
103
106
|
"slimy-chicken-melt",
|
|
104
107
|
"slimy-maps-press",
|
|
105
108
|
"slow-ravens-explain",
|
|
@@ -111,6 +114,7 @@
|
|
|
111
114
|
"smooth-coins-collect",
|
|
112
115
|
"smooth-pens-reply",
|
|
113
116
|
"soft-mails-clean",
|
|
117
|
+
"sour-kids-deliver",
|
|
114
118
|
"sour-pillows-guess",
|
|
115
119
|
"strange-seahorses-impress",
|
|
116
120
|
"swift-rivers-share",
|
|
@@ -132,6 +136,7 @@
|
|
|
132
136
|
"unlucky-sheep-change",
|
|
133
137
|
"warm-ties-sit",
|
|
134
138
|
"wicked-forks-double",
|
|
139
|
+
"witty-paws-marry",
|
|
135
140
|
"yellow-cats-judge",
|
|
136
141
|
"young-phones-fold",
|
|
137
142
|
"young-snails-grin",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Require the `link` option when instantiating `ApolloClient`. This removes the `uri`, `credentials` and `headers` options from `ApolloClient` in favor of passing an instantiated `HttpLink` directly. To migrate:
|
|
6
|
+
|
|
7
|
+
**If using `uri`, `credentials`, or `headers` options**
|
|
8
|
+
```diff
|
|
9
|
+
new ApolloClient({
|
|
10
|
+
// ...
|
|
11
|
+
- uri,
|
|
12
|
+
- credentials,
|
|
13
|
+
- headers,
|
|
14
|
+
+ link: new HttpLink({ uri, credentials, headers }),
|
|
15
|
+
// or if you prefer the function call approach:
|
|
16
|
+
+ link: createHttpLink({ uri, credentials, headers }),
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**If creating a client without the `link` option**
|
|
21
|
+
```diff
|
|
22
|
+
new ApolloClient({
|
|
23
|
+
// ...
|
|
24
|
+
+ link: ApolloLink.empty()
|
|
25
|
+
});
|
|
26
|
+
```
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.0.0-alpha.12
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#12586](https://github.com/apollographql/apollo-client/pull/12586) [`605db8e`](https://github.com/apollographql/apollo-client/commit/605db8e94fe2ce74c0a395f38f6873d40f431365) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `typeDefs` option from `ApolloClient`.
|
|
8
|
+
|
|
9
|
+
- [#12588](https://github.com/apollographql/apollo-client/pull/12588) [`eed825a`](https://github.com/apollographql/apollo-client/commit/eed825a2549f1d21fff2ec179815206b3baf0fcb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `TContext` generic argument from all types that use it. `TContext` is replaced with `DefaultContext` which can be modified using declaration merging.
|
|
10
|
+
|
|
11
|
+
- [#12590](https://github.com/apollographql/apollo-client/pull/12590) [`a005e82`](https://github.com/apollographql/apollo-client/commit/a005e822de7b24783f85be45df142ffbb9bc561b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Drop `graphql` v15 as a valid peer dependency.
|
|
12
|
+
|
|
13
|
+
- [#12591](https://github.com/apollographql/apollo-client/pull/12591) [`a7e7383`](https://github.com/apollographql/apollo-client/commit/a7e738328951f5dac25a5fe48d28b3640a3e0eb9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename the `@apollo/client/link/core` entrypoint to `@apollo/client/link`.
|
|
14
|
+
|
|
15
|
+
- [#12589](https://github.com/apollographql/apollo-client/pull/12589) [`15f5a1c`](https://github.com/apollographql/apollo-client/commit/15f5a1c29ac05015387a7bbc2dbe9a91d09fedfa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Require the `link` option when instantiating `ApolloClient`. This removes the `uri`, `credentials` and `headers` options from `ApolloClient` in favor of passing an instantiated `HttpLink` directly. To migrate:
|
|
16
|
+
|
|
17
|
+
**If using `uri`, `credentials`, or `headers` options**
|
|
18
|
+
|
|
19
|
+
```diff
|
|
20
|
+
new ApolloClient({
|
|
21
|
+
// ...
|
|
22
|
+
- uri,
|
|
23
|
+
- credentials,
|
|
24
|
+
- headers,
|
|
25
|
+
+ link: new HttpLink({ uri, credentials, headers }),
|
|
26
|
+
// or if you prefer the function call approach:
|
|
27
|
+
+ link: createHttpLink({ uri, credentials, headers }),
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**If creating a client without the `link` option**
|
|
32
|
+
|
|
33
|
+
```diff
|
|
34
|
+
new ApolloClient({
|
|
35
|
+
// ...
|
|
36
|
+
+ link: ApolloLink.empty()
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
3
40
|
## 4.0.0-alpha.11
|
|
4
41
|
|
|
5
42
|
### Major Changes
|
|
@@ -94,7 +94,7 @@ class ApolloCache {
|
|
|
94
94
|
if (environment_1.__DEV__) {
|
|
95
95
|
const actualFragmentName = fragmentName || (0, utilities_1.getFragmentDefinition)(fragment).name.value;
|
|
96
96
|
if (!id) {
|
|
97
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
97
|
+
__DEV__ && invariant_1.invariant.warn(97, actualFragmentName);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
const diffOptions = {
|
|
@@ -81,7 +81,7 @@ class EntityStore {
|
|
|
81
81
|
// then there are no fields to be merged, so we're done.
|
|
82
82
|
if (!incoming)
|
|
83
83
|
return;
|
|
84
|
-
(0, invariant_1.invariant)(typeof dataId === "string",
|
|
84
|
+
(0, invariant_1.invariant)(typeof dataId === "string", 83);
|
|
85
85
|
const merged = new utilities_1.DeepMerger(storeObjectReconciler).merge(existing, incoming);
|
|
86
86
|
// Even if merged === existing, existing may have come from a lower
|
|
87
87
|
// layer, so we always need to set this.data[dataId] on this level.
|
|
@@ -181,7 +181,7 @@ class EntityStore {
|
|
|
181
181
|
if (environment_1.__DEV__) {
|
|
182
182
|
const checkReference = (ref) => {
|
|
183
183
|
if (this.lookup(ref.__ref) === undefined) {
|
|
184
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
184
|
+
__DEV__ && invariant_1.invariant.warn(84, ref);
|
|
185
185
|
return true;
|
|
186
186
|
}
|
|
187
187
|
};
|
|
@@ -210,7 +210,7 @@ class EntityStore {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
if (seenReference && someNonReference !== undefined) {
|
|
213
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
213
|
+
__DEV__ && invariant_1.invariant.warn(85, someNonReference);
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -41,7 +41,7 @@ function keyFieldsFnFromSpecifier(specifier) {
|
|
|
41
41
|
// context.readField for this extraction.
|
|
42
42
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
43
43
|
}
|
|
44
|
-
(0, invariant_1.invariant)(extracted !== void 0,
|
|
44
|
+
(0, invariant_1.invariant)(extracted !== void 0, 86, schemaKeyPath.join("."), object);
|
|
45
45
|
return extracted;
|
|
46
46
|
}));
|
|
47
47
|
return `${context.typename}:${JSON.stringify(keyObject)}`;
|
|
@@ -203,7 +203,7 @@ class Policies {
|
|
|
203
203
|
const rootId = "ROOT_" + which.toUpperCase();
|
|
204
204
|
const old = this.rootTypenamesById[rootId];
|
|
205
205
|
if (typename !== old) {
|
|
206
|
-
(0, invariant_1.invariant)(!old || old === which,
|
|
206
|
+
(0, invariant_1.invariant)(!old || old === which, 87, which);
|
|
207
207
|
// First, delete any old __typename associated with this rootId from
|
|
208
208
|
// rootIdsByTypename.
|
|
209
209
|
if (old)
|
|
@@ -348,7 +348,7 @@ class Policies {
|
|
|
348
348
|
if (supertypeSet.has(supertype)) {
|
|
349
349
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
350
350
|
if (checkingFuzzySubtypes) {
|
|
351
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
351
|
+
__DEV__ && invariant_1.invariant.warn(88, typename, supertype);
|
|
352
352
|
}
|
|
353
353
|
// Record positive results for faster future lookup.
|
|
354
354
|
// Unfortunately, we cannot safely cache negative results,
|
|
@@ -559,7 +559,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
if (environment_1.__DEV__ && options.from === void 0) {
|
|
562
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
562
|
+
__DEV__ && invariant_1.invariant.warn(89, (0, utilities_1.stringifyForDisplay)(Array.from(readFieldArgs)));
|
|
563
563
|
}
|
|
564
564
|
if (void 0 === options.variables) {
|
|
565
565
|
options.variables = variables;
|
|
@@ -569,7 +569,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
569
569
|
function makeMergeObjectsFunction(store) {
|
|
570
570
|
return function mergeObjects(existing, incoming) {
|
|
571
571
|
if ((0, helpers_js_1.isArray)(existing) || (0, helpers_js_1.isArray)(incoming)) {
|
|
572
|
-
throw (0, invariant_1.newInvariantError)(
|
|
572
|
+
throw (0, invariant_1.newInvariantError)(90);
|
|
573
573
|
}
|
|
574
574
|
// These dynamic checks are necessary because the parameters of a
|
|
575
575
|
// custom merge function can easily have the any type, so the type
|
|
@@ -197,7 +197,7 @@ class StoreReader {
|
|
|
197
197
|
else {
|
|
198
198
|
const fragment = (0, utilities_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
199
199
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
200
|
-
throw (0, invariant_1.newInvariantError)(
|
|
200
|
+
throw (0, invariant_1.newInvariantError)(91, selection.name.value);
|
|
201
201
|
}
|
|
202
202
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
203
203
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
@@ -281,7 +281,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
281
281
|
if ((0, utilities_1.isNonNullObject)(value)) {
|
|
282
282
|
(0, invariant_1.invariant)(
|
|
283
283
|
!(0, utilities_1.isReference)(value),
|
|
284
|
-
|
|
284
|
+
92,
|
|
285
285
|
(0, helpers_js_1.getTypenameFromStoreObject)(store, value),
|
|
286
286
|
field.name.value
|
|
287
287
|
);
|
|
@@ -72,7 +72,7 @@ class StoreWriter {
|
|
|
72
72
|
context,
|
|
73
73
|
});
|
|
74
74
|
if (!(0, utilities_1.isReference)(ref)) {
|
|
75
|
-
throw (0, invariant_1.newInvariantError)(
|
|
75
|
+
throw (0, invariant_1.newInvariantError)(93, result);
|
|
76
76
|
}
|
|
77
77
|
// So far, the store has not been modified, so now it's time to process
|
|
78
78
|
// context.incomingById and merge those incoming fields into context.store.
|
|
@@ -222,7 +222,7 @@ class StoreWriter {
|
|
|
222
222
|
// provide a default value, so its absence from the written data should
|
|
223
223
|
// not be cause for alarm.
|
|
224
224
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
225
|
-
__DEV__ && invariant_1.invariant.error(
|
|
225
|
+
__DEV__ && invariant_1.invariant.error(94, (0, utilities_1.resultKeyNameFromField)(field), result);
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
// Identify the result object, even if dataId was already provided,
|
|
@@ -369,7 +369,7 @@ class StoreWriter {
|
|
|
369
369
|
else {
|
|
370
370
|
const fragment = (0, utilities_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
371
371
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
372
|
-
throw (0, invariant_1.newInvariantError)(
|
|
372
|
+
throw (0, invariant_1.newInvariantError)(95, selection.name.value);
|
|
373
373
|
}
|
|
374
374
|
if (fragment &&
|
|
375
375
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -542,7 +542,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
542
542
|
}
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
545
|
+
__DEV__ && invariant_1.invariant.warn(96, fieldName, parentType, childTypenames.length ?
|
|
546
546
|
"either ensure all objects of type " +
|
|
547
547
|
childTypenames.join(" and ") +
|
|
548
548
|
" have an ID or a custom merge function, or "
|
|
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.ApolloClient = exports.mergeOptions = void 0;
|
|
8
8
|
const graphql_1 = require("graphql");
|
|
9
9
|
const rxjs_1 = require("rxjs");
|
|
10
|
-
const
|
|
11
|
-
const http_1 = require("@apollo/client/link/http");
|
|
10
|
+
const link_1 = require("@apollo/client/link");
|
|
12
11
|
const utilities_1 = require("@apollo/client/utilities");
|
|
13
12
|
Object.defineProperty(exports, "mergeOptions", { enumerable: true, get: function () { return utilities_1.mergeOptions; } });
|
|
14
13
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
@@ -47,7 +46,6 @@ class ApolloClient {
|
|
|
47
46
|
version;
|
|
48
47
|
queryDeduplication;
|
|
49
48
|
defaultOptions;
|
|
50
|
-
typeDefs;
|
|
51
49
|
devtoolsConfig;
|
|
52
50
|
queryManager;
|
|
53
51
|
devToolsHookCb;
|
|
@@ -81,24 +79,19 @@ class ApolloClient {
|
|
|
81
79
|
* ```
|
|
82
80
|
*/
|
|
83
81
|
constructor(options) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
82
|
+
if (environment_1.__DEV__) {
|
|
83
|
+
(0, invariant_1.invariant)(options.cache, 58);
|
|
84
|
+
(0, invariant_1.invariant)(options.link, 59);
|
|
86
85
|
}
|
|
87
|
-
const {
|
|
86
|
+
const { cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0,
|
|
88
87
|
// Expose the client instance as window.__APOLLO_CLIENT__ and call
|
|
89
88
|
// onBroadcast in queryManager.broadcastQueries to enable browser
|
|
90
89
|
// devtools, but disable them by default in production.
|
|
91
|
-
connectToDevTools, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, resolvers,
|
|
92
|
-
let { link } = options;
|
|
93
|
-
if (!link) {
|
|
94
|
-
link =
|
|
95
|
-
uri ? new http_1.HttpLink({ uri, credentials, headers }) : core_1.ApolloLink.empty();
|
|
96
|
-
}
|
|
90
|
+
connectToDevTools, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, resolvers, fragmentMatcher, name: clientAwarenessName, version: clientAwarenessVersion, devtools, dataMasking, link, } = options;
|
|
97
91
|
this.link = link;
|
|
98
92
|
this.cache = cache;
|
|
99
93
|
this.queryDeduplication = queryDeduplication;
|
|
100
94
|
this.defaultOptions = defaultOptions || {};
|
|
101
|
-
this.typeDefs = typeDefs;
|
|
102
95
|
this.devtoolsConfig = {
|
|
103
96
|
...devtools,
|
|
104
97
|
enabled: devtools?.enabled ?? connectToDevTools,
|
|
@@ -246,13 +239,13 @@ class ApolloClient {
|
|
|
246
239
|
options = (0, utilities_1.mergeOptions)(this.defaultOptions.query, options);
|
|
247
240
|
}
|
|
248
241
|
if (environment_1.__DEV__) {
|
|
249
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network",
|
|
250
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "standby",
|
|
251
|
-
(0, invariant_1.invariant)(options.query,
|
|
252
|
-
(0, invariant_1.invariant)(options.query.kind === "Document",
|
|
253
|
-
(0, invariant_1.invariant)(!options.returnPartialData,
|
|
254
|
-
(0, invariant_1.invariant)(!options.pollInterval,
|
|
255
|
-
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange,
|
|
242
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 60);
|
|
243
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "standby", 61);
|
|
244
|
+
(0, invariant_1.invariant)(options.query, 62);
|
|
245
|
+
(0, invariant_1.invariant)(options.query.kind === "Document", 63);
|
|
246
|
+
(0, invariant_1.invariant)(!options.returnPartialData, 64);
|
|
247
|
+
(0, invariant_1.invariant)(!options.pollInterval, 65);
|
|
248
|
+
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange, 66);
|
|
256
249
|
(0, utilities_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
|
|
257
250
|
}
|
|
258
251
|
return this.queryManager.query(options);
|
|
@@ -372,7 +365,7 @@ class ApolloClient {
|
|
|
372
365
|
this.devToolsHookCb = cb;
|
|
373
366
|
}
|
|
374
367
|
__requestRaw(payload) {
|
|
375
|
-
return (0,
|
|
368
|
+
return (0, link_1.execute)(this.link, payload, { client: this });
|
|
376
369
|
}
|
|
377
370
|
/**
|
|
378
371
|
* Resets your entire store by clearing out your cache and then re-executing
|
|
@@ -474,7 +467,7 @@ class ApolloClient {
|
|
|
474
467
|
// result.queries and result.results instead, you shouldn't have to worry
|
|
475
468
|
// about preventing uncaught rejections for the Promise.all result.
|
|
476
469
|
result.catch((error) => {
|
|
477
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
470
|
+
__DEV__ && invariant_1.invariant.debug(67, error);
|
|
478
471
|
});
|
|
479
472
|
return result;
|
|
480
473
|
}
|