@apollo/client 4.0.0-alpha.2 → 4.0.0-alpha.4
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/eighty-squids-fix.md +15 -0
- package/.changeset/four-ghosts-watch.md +5 -0
- package/.changeset/funny-jeans-invent.md +16 -0
- package/.changeset/khaki-spies-work.md +11 -0
- package/.changeset/light-apes-rescue.md +5 -0
- package/.changeset/odd-lemons-relax.md +5 -0
- package/.changeset/pre.json +7 -0
- package/.changeset/unlucky-kiwis-sell.md +5 -0
- package/CHANGELOG.md +58 -0
- package/__cjs/core/ApolloClient.cjs +22 -13
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +13 -1
- package/__cjs/core/ObservableQuery.cjs +29 -10
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +6 -3
- package/__cjs/core/QueryInfo.cjs +8 -7
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +1 -0
- package/__cjs/core/QueryManager.cjs +36 -10
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +11 -0
- package/__cjs/core/watchQueryOptions.d.cts +18 -25
- package/__cjs/react/hooks/index.cjs +13 -8
- package/__cjs/react/hooks/index.cjs.map +1 -1
- package/__cjs/react/hooks/index.d.cts +6 -12
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +146 -43
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +51 -26
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +263 -266
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +105 -32
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +198 -3
- package/__cjs/react/hooks/useQuery.cjs +9 -12
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +279 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +21 -20
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +26 -24
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +127 -4
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +40 -37
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +202 -35
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +2 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +2 -8
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +1 -0
- package/__cjs/react/internal/types.d.cts +46 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +2 -3
- package/__cjs/react/ssr/RenderPromises.cjs.map +1 -1
- package/__cjs/react/ssr/RenderPromises.d.cts +6 -3
- package/__cjs/react/types/deprecated.cjs +3 -0
- package/__cjs/react/types/deprecated.cjs.map +1 -0
- package/__cjs/react/types/deprecated.d.cts +65 -0
- package/__cjs/react/types/types.documentation.d.cts +0 -8
- package/__cjs/testing/matchers/index.cjs +2 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs.map +1 -1
- package/__cjs/testing/matchers/toEqualLazyQueryResult.d.cts +2 -2
- package/__cjs/testing/matchers/toEqualQueryResult.cjs +0 -1
- package/__cjs/testing/matchers/toEqualQueryResult.cjs.map +1 -1
- package/__cjs/testing/matchers/toEqualQueryResult.d.cts +3 -3
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs +44 -0
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toEqualStrictTyped.d.cts +3 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.d.cts +1 -1
- package/core/ApolloClient.d.ts +13 -1
- package/core/ApolloClient.js +22 -13
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +6 -3
- package/core/ObservableQuery.js +29 -10
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -0
- package/core/QueryInfo.js +8 -7
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +11 -0
- package/core/QueryManager.js +36 -10
- package/core/QueryManager.js.map +1 -1
- package/core/watchQueryOptions.d.ts +18 -25
- package/package.json +1 -1
- package/react/hooks/index.d.ts +6 -12
- package/react/hooks/index.js +6 -6
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +146 -43
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +51 -26
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +263 -266
- package/react/hooks/useLazyQuery.js +1 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +105 -32
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +198 -3
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +279 -4
- package/react/hooks/useQuery.js +9 -12
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +21 -20
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +26 -24
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +127 -4
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +40 -37
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +202 -35
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/index.d.ts +2 -1
- package/react/index.js.map +1 -1
- package/react/internal/cache/QueryReference.js +2 -8
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/index.d.ts +1 -0
- package/react/internal/index.js.map +1 -1
- package/react/internal/types.d.ts +46 -0
- package/react/query-preloader/createQueryPreloader.d.ts +2 -3
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/RenderPromises.d.ts +6 -3
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/types/deprecated.d.ts +65 -0
- package/react/types/deprecated.js +2 -0
- package/react/types/deprecated.js.map +1 -0
- package/react/types/types.documentation.d.ts +0 -8
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toEqualLazyQueryResult.d.ts +2 -2
- package/testing/matchers/toEqualLazyQueryResult.js.map +1 -1
- package/testing/matchers/toEqualQueryResult.d.ts +3 -3
- package/testing/matchers/toEqualQueryResult.js +0 -1
- package/testing/matchers/toEqualQueryResult.js.map +1 -1
- package/testing/matchers/toEqualStrictTyped.d.ts +3 -0
- package/testing/matchers/toEqualStrictTyped.js +40 -0
- package/testing/matchers/toEqualStrictTyped.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/__cjs/react/types/types.d.cts +0 -671
- package/react/types/types.d.ts +0 -671
- /package/__cjs/react/{types → internal}/types.cjs +0 -0
- /package/__cjs/react/{types → internal}/types.cjs.map +0 -0
- /package/react/{types → internal}/types.js +0 -0
- /package/react/{types → internal}/types.js.map +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`ObservableQuery.setOptions` has been removed as it was an alias of `reobserve`. Prefer using `reobserve` directly instead.
|
|
6
|
+
|
|
7
|
+
```diff
|
|
8
|
+
const observable = client.watchQuery(options);
|
|
9
|
+
|
|
10
|
+
// Use reobserve to set new options and reevaluate the query
|
|
11
|
+
- observable.setOptions(newOptions);
|
|
12
|
+
+ observable.reobserve(newOptions);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
As a result of this change, `reobserve` has been marked for public use and is no longer considered an internal API. The `newNetworkStatus` argument has been removed to facilitate this change.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Network errors triggered by queries now adhere to the `errorPolicy`. This means that GraphQL errors and network errors now behave the same way. Previously promise-based APIs, such as `client.query`, would reject the promise with the network error even if `errorPolicy` was set to `ignore`. The promise is now resolved with the `error` property set to the network error instead.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`ssrMode`, `ssrForceFetchDelay` and `disableNetworkFetches` have been reworked:
|
|
6
|
+
|
|
7
|
+
Previously, a `ObservableQuery` created by `client.query` or `client.watchQuery`
|
|
8
|
+
while one of those were active would permanently be changed from a `fetchPolicy`
|
|
9
|
+
of `"network-only"` or `"cache-and-network"` to `"cache-first"`, and stay that way
|
|
10
|
+
even long after `disableNetworkFetches` would have been deactivated.
|
|
11
|
+
|
|
12
|
+
Now, the `ObservableQuery` will keep their original `fetchPolicy`, but queries
|
|
13
|
+
made during `disableNetworkFetches` will just apply the `fetchPolicy` replacement
|
|
14
|
+
at request time, just for that one request.
|
|
15
|
+
|
|
16
|
+
`ApolloClient.disableNetworkFetches` has been renamed to `ApolloClient.prioritizeCacheValues` to better reflect this behaviour.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Flatten out React hook types. As a result, the base types have been removed. Prefer using the hook types instead. Removed types include:
|
|
6
|
+
- `BaseMutationOptions`
|
|
7
|
+
- `BaseQueryOptions`
|
|
8
|
+
- `BaseSubscriptionOptions`
|
|
9
|
+
- `ObservableQueryFields`
|
|
10
|
+
- `MutationSharedOptions`
|
|
11
|
+
- `QueryFunctionOptions`
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`useQuery` no longer returns `reobserve` as part of its result. It was possible to use `reobserve` to set new options on the underlying `ObservableQuery` instance which differed from the options passed to the hook. This could result in unexpected results. Instead prefer to rerender the hook with new options.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Rename all React hook result types and options. These types have all moved under a namespace that matches the hook name. For example, `useQuery` exports `useQuery.Options` and `useQuery.Result` types. As such, the old hook types have been deprecated and will be removed in v5.
|
package/.changeset/pre.json
CHANGED
|
@@ -16,10 +16,13 @@
|
|
|
16
16
|
"cuddly-spiders-tie",
|
|
17
17
|
"curvy-pianos-count",
|
|
18
18
|
"dirty-trees-pump",
|
|
19
|
+
"eighty-squids-fix",
|
|
19
20
|
"empty-rabbits-move",
|
|
20
21
|
"fluffy-shoes-applaud",
|
|
21
22
|
"forty-hairs-occur",
|
|
23
|
+
"four-ghosts-watch",
|
|
22
24
|
"fresh-moose-hope",
|
|
25
|
+
"funny-jeans-invent",
|
|
23
26
|
"good-dolphins-peel",
|
|
24
27
|
"gorgeous-chefs-tap",
|
|
25
28
|
"healthy-apes-sneeze",
|
|
@@ -27,8 +30,10 @@
|
|
|
27
30
|
"hot-cycles-notice",
|
|
28
31
|
"itchy-drinks-refuse",
|
|
29
32
|
"itchy-roses-accept",
|
|
33
|
+
"khaki-spies-work",
|
|
30
34
|
"kind-fishes-develop",
|
|
31
35
|
"late-trainers-peel",
|
|
36
|
+
"light-apes-rescue",
|
|
32
37
|
"light-dolphins-taste",
|
|
33
38
|
"light-sloths-end",
|
|
34
39
|
"lucky-hats-push",
|
|
@@ -40,6 +45,7 @@
|
|
|
40
45
|
"nervous-goats-allow",
|
|
41
46
|
"nice-donkeys-reflect",
|
|
42
47
|
"nice-waves-work",
|
|
48
|
+
"odd-lemons-relax",
|
|
43
49
|
"polite-bees-care",
|
|
44
50
|
"popular-games-sleep",
|
|
45
51
|
"purple-lions-cough",
|
|
@@ -70,6 +76,7 @@
|
|
|
70
76
|
"tough-taxis-smoke",
|
|
71
77
|
"tough-tips-drop",
|
|
72
78
|
"twenty-snakes-sort",
|
|
79
|
+
"unlucky-kiwis-sell",
|
|
73
80
|
"unlucky-sheep-change",
|
|
74
81
|
"yellow-cats-judge",
|
|
75
82
|
"young-phones-fold",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.0.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.setOptions` has been removed as it was an alias of `reobserve`. Prefer using `reobserve` directly instead.
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
const observable = client.watchQuery(options);
|
|
11
|
+
|
|
12
|
+
// Use reobserve to set new options and reevaluate the query
|
|
13
|
+
- observable.setOptions(newOptions);
|
|
14
|
+
+ observable.reobserve(newOptions);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
As a result of this change, `reobserve` has been marked for public use and is no longer considered an internal API. The `newNetworkStatus` argument has been removed to facilitate this change.
|
|
18
|
+
|
|
19
|
+
- [#12470](https://github.com/apollographql/apollo-client/pull/12470) [`d32902f`](https://github.com/apollographql/apollo-client/commit/d32902f26a4c5dea30421ee52aeea52df3e5334e) Thanks [@phryneas](https://github.com/phryneas)! - `ssrMode`, `ssrForceFetchDelay` and `disableNetworkFetches` have been reworked:
|
|
20
|
+
|
|
21
|
+
Previously, a `ObservableQuery` created by `client.query` or `client.watchQuery`
|
|
22
|
+
while one of those were active would permanently be changed from a `fetchPolicy`
|
|
23
|
+
of `"network-only"` or `"cache-and-network"` to `"cache-first"`, and stay that way
|
|
24
|
+
even long after `disableNetworkFetches` would have been deactivated.
|
|
25
|
+
|
|
26
|
+
Now, the `ObservableQuery` will keep their original `fetchPolicy`, but queries
|
|
27
|
+
made during `disableNetworkFetches` will just apply the `fetchPolicy` replacement
|
|
28
|
+
at request time, just for that one request.
|
|
29
|
+
|
|
30
|
+
`ApolloClient.disableNetworkFetches` has been renamed to `ApolloClient.prioritizeCacheValues` to better reflect this behaviour.
|
|
31
|
+
|
|
32
|
+
- [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Flatten out React hook types. As a result, the base types have been removed. Prefer using the hook types instead. Removed types include:
|
|
33
|
+
|
|
34
|
+
- `BaseMutationOptions`
|
|
35
|
+
- `BaseQueryOptions`
|
|
36
|
+
- `BaseSubscriptionOptions`
|
|
37
|
+
- `ObservableQueryFields`
|
|
38
|
+
- `MutationSharedOptions`
|
|
39
|
+
- `QueryFunctionOptions`
|
|
40
|
+
|
|
41
|
+
- [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useQuery` no longer returns `reobserve` as part of its result. It was possible to use `reobserve` to set new options on the underlying `ObservableQuery` instance which differed from the options passed to the hook. This could result in unexpected results. Instead prefer to rerender the hook with new options.
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename all React hook result types and options. These types have all moved under a namespace that matches the hook name. For example, `useQuery` exports `useQuery.Options` and `useQuery.Result` types. As such, the old hook types have been deprecated and will be removed in v5.
|
|
46
|
+
|
|
47
|
+
## 4.0.0-alpha.3
|
|
48
|
+
|
|
49
|
+
### Major Changes
|
|
50
|
+
|
|
51
|
+
- [#12457](https://github.com/apollographql/apollo-client/pull/12457) [`32e85ea`](https://github.com/apollographql/apollo-client/commit/32e85ea9eb93c1ffb10d6f70e9e2775e1326e9aa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Network errors triggered by queries now adhere to the `errorPolicy`. This means that GraphQL errors and network errors now behave the same way. Previously promise-based APIs, such as `client.query`, would reject the promise with the network error even if `errorPolicy` was set to `ignore`. The promise is now resolved with the `error` property set to the network error instead.
|
|
52
|
+
|
|
53
|
+
- [#12464](https://github.com/apollographql/apollo-client/pull/12464) [`0595f39`](https://github.com/apollographql/apollo-client/commit/0595f39deba52ac43fa0780b742564134ec7ab89) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `called` property from `useQuery`.
|
|
54
|
+
|
|
3
55
|
## 4.0.0-alpha.2
|
|
4
56
|
|
|
5
57
|
### Major Changes
|
|
@@ -471,6 +523,12 @@
|
|
|
471
523
|
|
|
472
524
|
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't emit a partial cache result from `cache-only` queries when `returnPartialData` is `false`.
|
|
473
525
|
|
|
526
|
+
## 3.13.5
|
|
527
|
+
|
|
528
|
+
### Patch Changes
|
|
529
|
+
|
|
530
|
+
- [#12461](https://github.com/apollographql/apollo-client/pull/12461) [`12c8d06`](https://github.com/apollographql/apollo-client/commit/12c8d06f1ef7cfbece8e3a63b7ad09d91334f663) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where a `cache-first` query would return the result for previous variables when a cache update is issued after simultaneously changing variables and skipping the query.
|
|
531
|
+
|
|
474
532
|
## 3.13.4
|
|
475
533
|
|
|
476
534
|
### Patch Changes
|
|
@@ -26,7 +26,23 @@ let hasSuggestedDevtools = false;
|
|
|
26
26
|
class ApolloClient {
|
|
27
27
|
link;
|
|
28
28
|
cache;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated `disableNetworkFetches` has been renamed to `prioritizeCacheValues`.
|
|
31
|
+
*/
|
|
29
32
|
disableNetworkFetches;
|
|
33
|
+
set prioritizeCacheValues(value) {
|
|
34
|
+
this.queryManager.prioritizeCacheValues = value;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether to prioritize cache values over network results when `query` or `watchQuery` is called.
|
|
38
|
+
* This will essentially turn a `"network-only"` or `"cache-and-network"` fetchPolicy into a `"cache-first"` fetchPolicy,
|
|
39
|
+
* but without influencing the `fetchPolicy` of the created `ObservableQuery` long-term.
|
|
40
|
+
*
|
|
41
|
+
* This can e.g. be used to prioritize the cache during the first render after SSR.
|
|
42
|
+
*/
|
|
43
|
+
get prioritizeCacheValues() {
|
|
44
|
+
return this.queryManager.prioritizeCacheValues;
|
|
45
|
+
}
|
|
30
46
|
version;
|
|
31
47
|
queryDeduplication;
|
|
32
48
|
defaultOptions;
|
|
@@ -79,7 +95,6 @@ class ApolloClient {
|
|
|
79
95
|
}
|
|
80
96
|
this.link = link;
|
|
81
97
|
this.cache = cache;
|
|
82
|
-
this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;
|
|
83
98
|
this.queryDeduplication = queryDeduplication;
|
|
84
99
|
this.defaultOptions = defaultOptions || {};
|
|
85
100
|
this.typeDefs = typeDefs;
|
|
@@ -90,9 +105,6 @@ class ApolloClient {
|
|
|
90
105
|
if (this.devtoolsConfig.enabled === undefined) {
|
|
91
106
|
this.devtoolsConfig.enabled = environment_1.__DEV__;
|
|
92
107
|
}
|
|
93
|
-
if (ssrForceFetchDelay) {
|
|
94
|
-
setTimeout(() => (this.disableNetworkFetches = false), ssrForceFetchDelay);
|
|
95
|
-
}
|
|
96
108
|
this.watchQuery = this.watchQuery.bind(this);
|
|
97
109
|
this.query = this.query.bind(this);
|
|
98
110
|
this.mutate = this.mutate.bind(this);
|
|
@@ -129,6 +141,12 @@ class ApolloClient {
|
|
|
129
141
|
}
|
|
130
142
|
: void 0,
|
|
131
143
|
});
|
|
144
|
+
this.prioritizeCacheValues = ssrMode || ssrForceFetchDelay > 0;
|
|
145
|
+
if (ssrForceFetchDelay) {
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
this.prioritizeCacheValues = false;
|
|
148
|
+
}, ssrForceFetchDelay);
|
|
149
|
+
}
|
|
132
150
|
if (this.devtoolsConfig.enabled)
|
|
133
151
|
this.connectToDevTools();
|
|
134
152
|
}
|
|
@@ -212,12 +230,6 @@ class ApolloClient {
|
|
|
212
230
|
if (this.defaultOptions.watchQuery) {
|
|
213
231
|
options = (0, utilities_1.mergeOptions)(this.defaultOptions.watchQuery, options);
|
|
214
232
|
}
|
|
215
|
-
// XXX Overwriting options is probably not the best way to do this long term...
|
|
216
|
-
if (this.disableNetworkFetches &&
|
|
217
|
-
(options.fetchPolicy === "network-only" ||
|
|
218
|
-
options.fetchPolicy === "cache-and-network")) {
|
|
219
|
-
options = { ...options, fetchPolicy: "cache-first" };
|
|
220
|
-
}
|
|
221
233
|
return this.queryManager.watchQuery(options);
|
|
222
234
|
}
|
|
223
235
|
/**
|
|
@@ -234,9 +246,6 @@ class ApolloClient {
|
|
|
234
246
|
options = (0, utilities_1.mergeOptions)(this.defaultOptions.query, options);
|
|
235
247
|
}
|
|
236
248
|
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 63);
|
|
237
|
-
if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
|
|
238
|
-
options = { ...options, fetchPolicy: "cache-first" };
|
|
239
|
-
}
|
|
240
249
|
return this.queryManager.query(options);
|
|
241
250
|
}
|
|
242
251
|
/**
|