@apollo/client 3.4.9 → 3.4.13
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/README.md +2 -2
- package/apollo-client.cjs.js +58 -67
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -0
- package/cache/cache.cjs.js +20 -22
- package/cache/cache.cjs.js.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/index.d.ts +1 -0
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +1 -2
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +1 -1
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts +1 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +1 -0
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +1 -1
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +1 -1
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +1 -1
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +18 -5
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +47 -34
- package/core/core.cjs.js.map +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -2
- package/core/index.js.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/errors.cjs.js +1 -1
- package/errors/errors.cjs.js.map +1 -1
- package/errors/index.d.ts +1 -0
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +1 -2
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/core/ApolloLink.js +1 -1
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs.js +4 -6
- package/link/core/core.cjs.js.map +1 -1
- package/link/core/index.d.ts +1 -0
- package/link/core/index.d.ts.map +1 -1
- package/link/core/index.js +1 -2
- package/link/core/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +1 -0
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +1 -0
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs.js +4 -6
- package/link/http/http.cjs.js.map +1 -1
- package/link/http/index.d.ts +1 -0
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +1 -2
- package/link/http/index.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +2 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.js +8 -6
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -2
- package/link/utils/index.js.map +1 -1
- package/link/utils/toPromise.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/utils.cjs.js +3 -5
- package/link/utils/utils.cjs.js.map +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/link/utils/validateOperation.js.map +1 -1
- package/package.json +11 -11
- package/react/context/ApolloConsumer.d.ts.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +2 -1
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +11 -5
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs.js +16 -12
- package/react/context/context.cjs.js.map +1 -1
- package/react/context/index.d.ts +1 -0
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +1 -2
- package/react/context/index.js.map +1 -1
- package/react/data/OperationData.d.ts.map +1 -1
- package/react/data/OperationData.js +1 -1
- package/react/data/OperationData.js.map +1 -1
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js +1 -3
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +6 -11
- package/react/data/data.cjs.js.map +1 -1
- package/react/data/index.d.ts +1 -0
- package/react/data/index.d.ts.map +1 -1
- package/react/data/index.js +1 -2
- package/react/data/index.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs.js +13 -13
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/index.d.ts +1 -0
- package/react/hoc/index.d.ts.map +1 -1
- package/react/hoc/index.js +1 -2
- package/react/hoc/index.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -5
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.d.ts.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs.js +3 -6
- package/react/hooks/hooks.cjs.js.map +1 -1
- package/react/hooks/index.d.ts +1 -0
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +1 -2
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -0
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +1 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
- package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
- package/react/hooks/utils/useAfterFastRefresh.js +1 -0
- package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
- package/react/hooks/utils/useBaseQuery.d.ts +1 -0
- package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
- package/react/hooks/utils/useBaseQuery.js +1 -0
- package/react/hooks/utils/useBaseQuery.js.map +1 -1
- package/react/index.d.ts +1 -0
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -2
- package/react/index.js.map +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +1 -3
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs.js +9 -11
- package/react/parser/parser.cjs.js.map +1 -1
- package/react/react.cjs.js +2 -2
- package/react/react.cjs.js.map +1 -1
- package/testing/index.d.ts +1 -0
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +1 -2
- package/testing/index.js.map +1 -1
- package/testing/testing.cjs.js +3 -5
- package/testing/testing.cjs.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +2 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +14 -3
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.js +1 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/DEV.js +2 -2
- package/utilities/globals/DEV.js.map +1 -1
- package/utilities/{common → globals}/global.d.ts +0 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/{common → globals}/global.js +0 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs.js +57 -0
- package/utilities/globals/globals.cjs.js.map +1 -0
- package/utilities/globals/index.d.ts +4 -2
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +5 -2
- package/utilities/globals/index.js.map +1 -1
- package/utilities/{common → globals}/maybe.d.ts +0 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/{common → globals}/maybe.js +0 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +7 -0
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +1 -1
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +2 -2
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +1 -1
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +1 -3
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -4
- package/utilities/index.js.map +1 -1
- package/utilities/observables/subclassing.d.ts.map +1 -1
- package/utilities/observables/subclassing.js +2 -1
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/package.json +1 -3
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -4
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/testing/mocking/mockFetch.js +1 -1
- package/utilities/testing/mocking/mockFetch.js.map +1 -1
- package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
- package/utilities/testing/mocking/mockLink.js +1 -1
- package/utilities/testing/mocking/mockLink.js.map +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
- package/utilities/testing/observableToPromise.js +1 -1
- package/utilities/testing/observableToPromise.js.map +1 -1
- package/utilities/utilities.cjs.js +57 -83
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/apollo-core.cjs.js +0 -5772
- package/apollo-core.cjs.js.map +0 -1
- package/apollo-core.cjs.min.js +0 -1
- package/utilities/common/global.d.ts.map +0 -1
- package/utilities/common/global.js.map +0 -1
- package/utilities/common/maybe.d.ts.map +0 -1
- package/utilities/common/maybe.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/client",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.13",
|
|
4
4
|
"description": "A fully-featured caching GraphQL client.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -53,22 +53,22 @@
|
|
|
53
53
|
"symbol-observable": "^4.0.0",
|
|
54
54
|
"ts-invariant": "^0.9.0",
|
|
55
55
|
"tslib": "^2.3.0",
|
|
56
|
-
"zen-observable-ts": "
|
|
56
|
+
"zen-observable-ts": "~1.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/parser": "7.15.
|
|
60
|
-
"@graphql-tools/schema": "8.
|
|
59
|
+
"@babel/parser": "7.15.7",
|
|
60
|
+
"@graphql-tools/schema": "8.2.0",
|
|
61
61
|
"@rollup/plugin-node-resolve": "11.2.1",
|
|
62
62
|
"@testing-library/react": "9.5.0",
|
|
63
|
-
"@testing-library/react-hooks": "7.0.
|
|
63
|
+
"@testing-library/react-hooks": "7.0.2",
|
|
64
64
|
"@types/fast-json-stable-stringify": "2.0.0",
|
|
65
65
|
"@types/fetch-mock": "7.3.5",
|
|
66
66
|
"@types/glob": "7.1.4",
|
|
67
67
|
"@types/hoist-non-react-statics": "3.3.1",
|
|
68
68
|
"@types/jest": "26.0.24",
|
|
69
|
-
"@types/lodash": "4.14.
|
|
70
|
-
"@types/node": "16.
|
|
71
|
-
"@types/react": "17.0.
|
|
69
|
+
"@types/lodash": "4.14.173",
|
|
70
|
+
"@types/node": "16.9.4",
|
|
71
|
+
"@types/react": "17.0.21",
|
|
72
72
|
"@types/react-dom": "17.0.2",
|
|
73
73
|
"@types/recompose": "0.30.8",
|
|
74
74
|
"bundlesize": "0.18.1",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"crypto-hash": "1.3.0",
|
|
77
77
|
"fetch-mock": "9.11.0",
|
|
78
78
|
"glob": "7.1.7",
|
|
79
|
-
"graphql": "15.5.
|
|
79
|
+
"graphql": "15.5.3",
|
|
80
80
|
"jest": "26.6.3",
|
|
81
81
|
"jest-fetch-mock": "3.0.3",
|
|
82
82
|
"jest-junit": "12.2.0",
|
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
"rollup-plugin-terser": "7.0.2",
|
|
92
92
|
"rxjs": "6.6.7",
|
|
93
93
|
"subscriptions-transport-ws": "0.9.19",
|
|
94
|
-
"terser": "5.
|
|
94
|
+
"terser": "5.8.0",
|
|
95
95
|
"ts-jest": "26.5.6",
|
|
96
96
|
"ts-node": "10.2.1",
|
|
97
|
-
"typescript": "4.3
|
|
97
|
+
"typescript": "4.4.3",
|
|
98
98
|
"wait-for-observables": "1.0.3"
|
|
99
99
|
},
|
|
100
100
|
"publishConfig": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloConsumer.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloConsumer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ApolloConsumer.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloConsumer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;CACrE;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAcxD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { invariant } from 'ts-invariant';
|
|
3
3
|
import { getApolloContext } from "./ApolloContext.js";
|
|
4
4
|
export var ApolloConsumer = function (props) {
|
|
5
5
|
var ApolloContext = getApolloContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloConsumer.js","sourceRoot":"","sources":["../../../src/react/context/ApolloConsumer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ApolloConsumer.js","sourceRoot":"","sources":["../../../src/react/context/ApolloConsumer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMnD,MAAM,CAAC,IAAM,cAAc,GAAkC,UAAA,KAAK;IAChE,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,QACpB,UAAC,OAAY;QACZ,SAAS,CACP,OAAO,IAAI,OAAO,CAAC,MAAM,EACzB,4DAA4D;YAC1D,iDAAiD,CACpD,CAAC;QACF,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC,CACsB,CAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport * as React from 'react';\n\nimport { ApolloClient } from '../../core';\nimport { getApolloContext } from './ApolloContext';\n\nexport interface ApolloConsumerProps {\n children: (client: ApolloClient<object>) => React.ReactChild | null;\n}\n\nexport const ApolloConsumer: React.FC<ApolloConsumerProps> = props => {\n const ApolloContext = getApolloContext();\n return (\n <ApolloContext.Consumer>\n {(context: any) => {\n invariant(\n context && context.client,\n 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.'\n );\n return props.children(context.client);\n }}\n </ApolloContext.Consumer>\n );\n};\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ApolloClient } from '../../core';
|
|
3
|
+
import type { RenderPromises } from '../ssr';
|
|
3
4
|
export interface ApolloContextValue {
|
|
4
5
|
client?: ApolloClient<object>;
|
|
5
|
-
renderPromises?:
|
|
6
|
+
renderPromises?: RenderPromises;
|
|
6
7
|
}
|
|
7
8
|
export declare function getApolloContext(): React.Context<ApolloContextValue>;
|
|
8
9
|
export { getApolloContext as resetApolloContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloContext.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ApolloContext.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAUD,wBAAgB,gBAAgB,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAYpE;AAED,OAAO,EAAE,gBAAgB,IAAI,kBAAkB,EAAE,CAAA"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
var
|
|
2
|
+
import { canUseSymbol } from "../../utilities/index.js";
|
|
3
|
+
var contextKey = canUseSymbol
|
|
4
|
+
? Symbol.for('__APOLLO_CONTEXT__')
|
|
5
|
+
: '__APOLLO_CONTEXT__';
|
|
4
6
|
export function getApolloContext() {
|
|
5
|
-
var context =
|
|
7
|
+
var context = React.createContext[contextKey];
|
|
6
8
|
if (!context) {
|
|
7
|
-
|
|
9
|
+
Object.defineProperty(React.createContext, contextKey, {
|
|
10
|
+
value: context = React.createContext({}),
|
|
11
|
+
enumerable: false,
|
|
12
|
+
writable: false,
|
|
13
|
+
configurable: true,
|
|
14
|
+
});
|
|
8
15
|
context.displayName = 'ApolloContext';
|
|
9
|
-
cache.set(React.createContext, context);
|
|
10
16
|
}
|
|
11
17
|
return context;
|
|
12
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloContext.js","sourceRoot":"","sources":["../../../src/react/context/ApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ApolloContext.js","sourceRoot":"","sources":["../../../src/react/context/ApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAY/C,IAAM,UAAU,GAAG,YAAY;IAC7B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAClC,CAAC,CAAC,oBAAoB,CAAC;AAEzB,MAAM,UAAU,gBAAgB;IAC9B,IAAI,OAAO,GAAI,KAAK,CAAC,aAAqB,CAAC,UAAU,CAAsC,CAAC;IAC5F,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,EAAE;YACrD,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,aAAa,CAAqB,EAAE,CAAC;YAC5D,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;KACvC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,OAAO,EAAE,gBAAgB,IAAI,kBAAkB,EAAE,CAAA","sourcesContent":["import * as React from 'react';\nimport { ApolloClient } from '../../core';\nimport { canUseSymbol } from '../../utilities';\nimport type { RenderPromises } from '../ssr';\n\nexport interface ApolloContextValue {\n client?: ApolloClient<object>;\n renderPromises?: RenderPromises;\n}\n\n// To make sure Apollo Client doesn't create more than one React context\n// (which can lead to problems like having an Apollo Client instance added\n// in one context, then attempting to retrieve it from another different\n// context), a single Apollo context is created and tracked in global state.\nconst contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\n\nexport function getApolloContext(): React.Context<ApolloContextValue> {\n let context = (React.createContext as any)[contextKey] as React.Context<ApolloContextValue>;\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext<ApolloContextValue>({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\n\nexport { getApolloContext as resetApolloContext }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloProvider.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ApolloProvider.d.ts","sourceRoot":"","sources":["../../../src/react/context/ApolloProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACzC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC;CACtD;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CA0B7D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import { invariant } from 'ts-invariant';
|
|
3
3
|
import { getApolloContext } from "./ApolloContext.js";
|
|
4
4
|
export var ApolloProvider = function (_a) {
|
|
5
5
|
var client = _a.client, children = _a.children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloProvider.js","sourceRoot":"","sources":["../../../src/react/context/ApolloProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ApolloProvider.js","sourceRoot":"","sources":["../../../src/react/context/ApolloProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAOnD,MAAM,CAAC,IAAM,cAAc,GAAuC,UAAC,EAGlE;QAFC,MAAM,YAAA,EACN,QAAQ,cAAA;IAER,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,QACpB,UAAC,OAAiB;QAAjB,wBAAA,EAAA,YAAiB;QACjB,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;YACvC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;SAClD;QAED,SAAS,CACP,OAAO,CAAC,MAAM,EACd,wDAAwD;YACtD,qDAAqD,CACxD,CAAC;QAEF,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IACnC,QAAQ,CACc,CAC1B,CAAC;IACJ,CAAC,CACsB,CAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport * as React from 'react';\n\nimport { ApolloClient } from '../../core';\nimport { getApolloContext } from './ApolloContext';\n\nexport interface ApolloProviderProps<TCache> {\n client: ApolloClient<TCache>;\n children: React.ReactNode | React.ReactNode[] | null;\n}\n\nexport const ApolloProvider: React.FC<ApolloProviderProps<any>> = ({\n client,\n children\n}) => {\n const ApolloContext = getApolloContext();\n return (\n <ApolloContext.Consumer>\n {(context: any = {}) => {\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client });\n }\n\n invariant(\n context.client,\n 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.'\n );\n\n return (\n <ApolloContext.Provider value={context}>\n {children}\n </ApolloContext.Provider>\n );\n }}\n </ApolloContext.Consumer>\n );\n};\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var globals = require('../../utilities/globals');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var utilities = require('../../utilities');
|
|
8
8
|
|
|
9
9
|
function _interopNamespace(e) {
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
@@ -20,13 +20,19 @@ function _interopNamespace(e) {
|
|
|
20
20
|
|
|
21
21
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var contextKey = utilities.canUseSymbol
|
|
24
|
+
? Symbol.for('__APOLLO_CONTEXT__')
|
|
25
|
+
: '__APOLLO_CONTEXT__';
|
|
24
26
|
function getApolloContext() {
|
|
25
|
-
var context =
|
|
27
|
+
var context = React__namespace.createContext[contextKey];
|
|
26
28
|
if (!context) {
|
|
27
|
-
|
|
29
|
+
Object.defineProperty(React__namespace.createContext, contextKey, {
|
|
30
|
+
value: context = React__namespace.createContext({}),
|
|
31
|
+
enumerable: false,
|
|
32
|
+
writable: false,
|
|
33
|
+
configurable: true,
|
|
34
|
+
});
|
|
28
35
|
context.displayName = 'ApolloContext';
|
|
29
|
-
cache.set(React__namespace.createContext, context);
|
|
30
36
|
}
|
|
31
37
|
return context;
|
|
32
38
|
}
|
|
@@ -34,8 +40,8 @@ function getApolloContext() {
|
|
|
34
40
|
var ApolloConsumer = function (props) {
|
|
35
41
|
var ApolloContext = getApolloContext();
|
|
36
42
|
return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
37
|
-
__DEV__ ?
|
|
38
|
-
'Wrap the root component in an <ApolloProvider>.') :
|
|
43
|
+
__DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
|
|
44
|
+
'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 27);
|
|
39
45
|
return props.children(context.client);
|
|
40
46
|
});
|
|
41
47
|
};
|
|
@@ -48,14 +54,12 @@ var ApolloProvider = function (_a) {
|
|
|
48
54
|
if (client && context.client !== client) {
|
|
49
55
|
context = Object.assign({}, context, { client: client });
|
|
50
56
|
}
|
|
51
|
-
__DEV__ ?
|
|
52
|
-
'sure you pass in your client via the "client" prop.') :
|
|
57
|
+
__DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
58
|
+
'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 28);
|
|
53
59
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
54
60
|
});
|
|
55
61
|
};
|
|
56
62
|
|
|
57
|
-
utilities.checkDEV();
|
|
58
|
-
|
|
59
63
|
exports.ApolloConsumer = ApolloConsumer;
|
|
60
64
|
exports.ApolloProvider = ApolloProvider;
|
|
61
65
|
exports.getApolloContext = getApolloContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.cjs.js","sources":["ApolloContext.js","ApolloConsumer.js","ApolloProvider.js"
|
|
1
|
+
{"version":3,"file":"context.cjs.js","sources":["ApolloContext.js","ApolloConsumer.js","ApolloProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseSymbol } from '../../utilities';\nvar contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\nexport function getApolloContext() {\n var context = React.createContext[contextKey];\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\nexport { getApolloContext as resetApolloContext };\n//# sourceMappingURL=ApolloContext.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloConsumer = function (props) {\n var ApolloContext = getApolloContext();\n return React.createElement(ApolloContext.Consumer, null, function (context) {\n __DEV__ ? invariant(context && context.client, 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 27);\n return props.children(context.client);\n });\n};\n//# sourceMappingURL=ApolloConsumer.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloProvider = function (_a) {\n var client = _a.client, children = _a.children;\n var ApolloContext = getApolloContext();\n return React.createElement(ApolloContext.Consumer, null, function (context) {\n if (context === void 0) { context = {}; }\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client: client });\n }\n __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.') : invariant(context.client, 28);\n return (React.createElement(ApolloContext.Provider, { value: context }, children));\n });\n};\n//# sourceMappingURL=ApolloProvider.js.map"],"names":["canUseSymbol","React","invariant"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,IAAI,UAAU,GAAGA,sBAAY;AAC7B,MAAM,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACtC,MAAM,oBAAoB,CAAC;AACpB,SAAS,gBAAgB,GAAG;AACnC,IAAI,IAAI,OAAO,GAAGC,gBAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAClD,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,MAAM,CAAC,cAAc,CAACA,gBAAK,CAAC,aAAa,EAAE,UAAU,EAAE;AAC/D,YAAY,KAAK,EAAE,OAAO,GAAGA,gBAAK,CAAC,aAAa,CAAC,EAAE,CAAC;AACpD,YAAY,UAAU,EAAE,KAAK;AAC7B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;AAC9C,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB;;ACdU,IAAC,cAAc,GAAG,UAAU,KAAK,EAAE;AAC7C,IAAI,IAAI,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC3C,IAAI,OAAOA,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE;AACh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1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/context/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
package/react/context/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport * from './ApolloConsumer';\nexport * from './ApolloContext';\nexport * from './ApolloProvider';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationData.d.ts","sourceRoot":"","sources":["../../../src/react/data/OperationData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperationData.d.ts","sourceRoot":"","sources":["../../../src/react/data/OperationData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAyB,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,8BAAsB,aAAa,CAAC,QAAQ,GAAG,GAAG;IACzC,SAAS,EAAE,OAAO,CAAS;IAC3B,eAAe,EAAE,aAAa,CAAC,QAAQ,CAAC,CAE7C;IACK,OAAO,EAAE,GAAG,CAAM;IAClB,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAEpC,OAAO,CAAC,OAAO,CAA0D;gBAE7D,OAAO,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG;IAKrD,UAAU,IAAI,aAAa,CAAC,QAAQ,CAAC;IAIrC,UAAU,CACf,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,EACnC,aAAa,GAAE,OAAe;aAQhB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,GAAG;aAC1B,YAAY,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC;aAC/C,OAAO,IAAI,IAAI;IAE/B,SAAS,CAAC,OAAO;IAIjB,SAAS,CAAC,aAAa;;;;IAwBvB,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;CAUxE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
1
2
|
import { equal } from '@wry/equality';
|
|
2
|
-
import { invariant } from 'ts-invariant';
|
|
3
3
|
import { parser, operationName } from "../parser/index.js";
|
|
4
4
|
var OperationData = (function () {
|
|
5
5
|
function OperationData(options, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationData.js","sourceRoot":"","sources":["../../../src/react/data/OperationData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OperationData.js","sourceRoot":"","sources":["../../../src/react/data/OperationData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAgB,MAAM,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGhE;IAUE,uBAAY,OAAiC,EAAE,OAAa;QATrD,cAAS,GAAY,KAAK,CAAC;QAC3B,oBAAe,GA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B;QACrE,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAM,qBAAqB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAClD,IAAM,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxD,SAAS,CACP,SAAS,CAAC,IAAI,KAAK,IAAI,EACvB,eAAa,qBAAqB,yBAAsB;aACnD,qBAAqB,gBAAW,iBAAiB,uBAAoB,CAAA,CAC3E,CAAC;IACJ,CAAC;IACH,oBAAC;AAAD,CAAC,AAvED,IAuEC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport { DocumentNode } from 'graphql';\nimport { equal } from '@wry/equality';\n\nimport { ApolloClient } from '../../core';\nimport { DocumentType, parser, operationName } from '../parser';\nimport { CommonOptions } from '../types/types';\n\nexport abstract class OperationData<TOptions = any> {\n public isMounted: boolean = false;\n public previousOptions: CommonOptions<TOptions> = {} as CommonOptions<\n TOptions\n >;\n public context: any = {};\n public client: ApolloClient<object>;\n\n private options: CommonOptions<TOptions> = {} as CommonOptions<TOptions>;\n\n constructor(options?: CommonOptions<TOptions>, context?: any) {\n this.options = options || ({} as CommonOptions<TOptions>);\n this.context = context || {};\n }\n\n public getOptions(): CommonOptions<TOptions> {\n return this.options;\n }\n\n public setOptions(\n newOptions: CommonOptions<TOptions>,\n storePrevious: boolean = false\n ) {\n if (storePrevious && !equal(this.options, newOptions)) {\n this.previousOptions = this.options;\n }\n this.options = newOptions;\n }\n\n public abstract execute(...args: any): any;\n public abstract afterExecute(...args: any): void | (() => void);\n public abstract cleanup(): void;\n\n protected unmount() {\n this.isMounted = false;\n }\n\n protected refreshClient() {\n const client =\n (this.options && this.options.client) ||\n (this.context && this.context.client);\n\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider>, or pass an ' +\n 'ApolloClient instance in via options.'\n );\n\n let isNew = false;\n if (client !== this.client) {\n isNew = true;\n this.client = client;\n this.cleanup();\n }\n return {\n client: this.client as ApolloClient<object>,\n isNew\n };\n }\n\n protected verifyDocumentType(document: DocumentNode, type: DocumentType) {\n const operation = parser(document);\n const requiredOperationName = operationName(type);\n const usedOperationName = operationName(operation.type);\n invariant(\n operation.type === type,\n `Running a ${requiredOperationName} requires a graphql ` +\n `${requiredOperationName}, but a ${usedOperationName} was used instead.`\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryData.d.ts","sourceRoot":"","sources":["../../../src/react/data/QueryData.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,UAAU,EAGX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qBAAa,SAAS,CAAC,KAAK,EAAE,UAAU,CAAE,SAAQ,aAAa,CAC7D,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,CACpC;IACQ,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC9D,OAAO,CAAC,mBAAmB,CAAC,CAAyB;IACrD,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,WAAW,CAAC,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAQQ;gBAEZ,EACV,OAAO,EACP,OAAO,EACP,SAAS,EACV,EAAE;QACD,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC7C,OAAO,EAAE,GAAG,CAAC;QACb,SAAS,EAAE,MAAM,IAAI,CAAC;KACvB;IAKM,OAAO,IAAI,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;IAezC,WAAW,IAAI,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC;IAe5C,SAAS,IAAI,OAAO,CAAC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CAKlB;IAEF,OAAO,CAAC,mBAAmB;IA+B3B,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,qBAAqB;IAqC7B,OAAO,CAAC,sBAAsB;IAmC9B,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,gBAAgB;IA0GxB,OAAO,CAAC,sBAAsB;IAgC9B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,UAAU,CAC2B;IAE7C,OAAO,CAAC,YAAY,CAGqC;IAEzD,OAAO,CAAC,cAAc,CAK0B;IAEhD,OAAO,CAAC,eAAe,CAErB;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,kBAAkB,CAS4B;IAEtD,OAAO,CAAC,qBAAqB;CAW9B"}
|
package/react/data/QueryData.js
CHANGED
|
@@ -67,9 +67,7 @@ var QueryData = (function (_super) {
|
|
|
67
67
|
var _b = _a === void 0 ? {} : _a, _c = _b.lazy, lazy = _c === void 0 ? false : _c;
|
|
68
68
|
this.isMounted = true;
|
|
69
69
|
var options = this.getOptions();
|
|
70
|
-
if (this.currentObservable &&
|
|
71
|
-
!this.ssrInitiated() &&
|
|
72
|
-
!this.client.disableNetworkFetches) {
|
|
70
|
+
if (this.currentObservable && !this.ssrInitiated()) {
|
|
73
71
|
this.startQuerySubscription();
|
|
74
72
|
}
|
|
75
73
|
if (!lazy || this.runLazy) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryData.js","sourceRoot":"","sources":["../../../src/react/data/QueryData.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAEL,aAAa,GAQd,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,EAAE,aAA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C,iBAAiB,EAAE;YAC1B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1C,IAAI,SAAS,EAAE;gBACb,OAAO,IAAI,CAAC,iBAAiB,CAAC;aAC/B;SACF;IACH,CAAC;IAoCO,yCAAqB,GAA7B;;QACE,OAAO;YACL,SAAS,EAAE,MAAA,IAAI,CAAC,iBAAiB,0CAAE,SAAS;YAC5C,OAAO,EAAE,IAAI,CAAC,UAAU;YACxB,SAAS,EAAE,IAAI,CAAC,YAAY;YAC5B,WAAW,EAAE,IAAI,CAAC,cAAc;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe;YAClC,WAAW,EAAE,IAAI,CAAC,cAAc;YAChC,eAAe,EAAE,IAAI,CAAC,kBAAkB;SACG,CAAC;IAChD,CAAC;IACH,gBAAC;AAAD,CAAC,AArfD,CAAkD,aAAa,GAqf9D","sourcesContent":["import { equal } from '@wry/equality';\n\nimport { ApolloError } from '../../errors';\n\nimport {\n ApolloClient,\n NetworkStatus,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n ObservableQuery,\n FetchMoreOptions,\n UpdateQueryOptions,\n DocumentNode,\n TypedDocumentNode,\n} from '../../core';\n\nimport {\n ObservableSubscription\n} from '../../utilities';\n\nimport { DocumentType } from '../parser';\nimport {\n QueryResult,\n QueryDataOptions,\n QueryTuple,\n QueryLazyOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { OperationData } from './OperationData';\n\ntype ObservableQueryOptions<TData, TVars> =\n ReturnType<QueryData<TData, TVars>[\"prepareObservableQueryOptions\"]>;\n\nexport class QueryData<TData, TVariables> extends OperationData<\n QueryDataOptions<TData, TVariables>\n> {\n public onNewData: () => void;\n public currentObservable?: ObservableQuery<TData, TVariables>;\n private currentSubscription?: ObservableSubscription;\n private runLazy: boolean = false;\n private lazyOptions?: QueryLazyOptions<TVariables>;\n private previous: {\n client?: ApolloClient<object>;\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n observableQueryOptions?: ObservableQueryOptions<TData, TVariables>;\n result?: QueryResult<TData, TVariables>;\n loading?: boolean;\n options?: QueryDataOptions<TData, TVariables>;\n error?: ApolloError;\n } = Object.create(null);\n\n constructor({\n options,\n context,\n onNewData\n }: {\n options: QueryDataOptions<TData, TVariables>;\n context: any;\n onNewData: () => void;\n }) {\n super(options, context);\n this.onNewData = onNewData;\n }\n\n public execute(): QueryResult<TData, TVariables> {\n this.refreshClient();\n\n const { skip, query } = this.getOptions();\n if (skip || query !== this.previous.query) {\n this.removeQuerySubscription();\n this.removeObservable(!skip);\n this.previous.query = query;\n }\n\n this.updateObservableQuery();\n\n return this.getExecuteSsrResult() || this.getExecuteResult();\n }\n\n public executeLazy(): QueryTuple<TData, TVariables> {\n return !this.runLazy\n ? [\n this.runLazyQuery,\n {\n loading: false,\n networkStatus: NetworkStatus.ready,\n called: false,\n data: undefined\n }\n ]\n : [this.runLazyQuery, this.execute()];\n }\n\n // For server-side rendering\n public fetchData(): Promise<void> | boolean {\n const options = this.getOptions();\n if (options.skip || options.ssr === false) return false;\n return new Promise(resolve => this.startQuerySubscription(resolve));\n }\n\n public afterExecute({ lazy = false }: { lazy?: boolean } = {}) {\n this.isMounted = true;\n const options = this.getOptions();\n if (\n this.currentObservable &&\n !this.ssrInitiated() &&\n !this.client.disableNetworkFetches\n ) {\n this.startQuerySubscription();\n }\n\n if (!lazy || this.runLazy) {\n this.handleErrorOrCompleted();\n }\n\n this.previousOptions = options;\n return this.unmount.bind(this);\n }\n\n public cleanup() {\n this.removeQuerySubscription();\n this.removeObservable(true);\n delete this.previous.result;\n }\n\n public getOptions() {\n const options = super.getOptions();\n\n if (this.lazyOptions) {\n options.variables = {\n ...options.variables,\n ...this.lazyOptions.variables\n } as TVariables;\n options.context = {\n ...options.context,\n ...this.lazyOptions.context\n };\n }\n\n // skip is not supported when using lazy query execution.\n if (this.runLazy) {\n delete options.skip;\n }\n\n return options;\n }\n\n public ssrInitiated() {\n return this.context && this.context.renderPromises;\n }\n\n private runLazyQuery = (options?: QueryLazyOptions<TVariables>) => {\n this.cleanup();\n this.runLazy = true;\n this.lazyOptions = options;\n this.onNewData();\n };\n\n private getExecuteSsrResult() {\n const { ssr, skip } = this.getOptions();\n const ssrDisabled = ssr === false;\n const fetchDisabled = this.refreshClient().client.disableNetworkFetches;\n\n const ssrLoading = {\n loading: true,\n networkStatus: NetworkStatus.loading,\n called: true,\n data: undefined,\n stale: false,\n client: this.client,\n ...this.observableQueryFields(),\n } as QueryResult<TData, TVariables>;\n\n // If SSR has been explicitly disabled, and this function has been called\n // on the server side, return the default loading state.\n if (ssrDisabled && (this.ssrInitiated() || fetchDisabled)) {\n this.previous.result = ssrLoading;\n return ssrLoading;\n }\n\n if (this.ssrInitiated()) {\n const result = this.getExecuteResult() || ssrLoading;\n if (result.loading && !skip) {\n this.context.renderPromises!.addQueryPromise(this, () => null);\n }\n return result;\n }\n }\n\n private prepareObservableQueryOptions() {\n const options = this.getOptions();\n this.verifyDocumentType(options.query, DocumentType.Query);\n const displayName = options.displayName || 'Query';\n\n // Set the fetchPolicy to cache-first for network-only and cache-and-network\n // fetches for server side renders.\n if (\n this.ssrInitiated() &&\n (options.fetchPolicy === 'network-only' ||\n options.fetchPolicy === 'cache-and-network')\n ) {\n options.fetchPolicy = 'cache-first';\n }\n\n return {\n ...options,\n displayName,\n context: options.context,\n };\n }\n\n private initializeObservableQuery() {\n // See if there is an existing observable that was used to fetch the same\n // data and if so, use it instead since it will contain the proper queryId\n // to fetch the result set. This is used during SSR.\n if (this.ssrInitiated()) {\n this.currentObservable = this.context!.renderPromises!.getSSRObservable(\n this.getOptions()\n );\n }\n\n if (!this.currentObservable) {\n const observableQueryOptions = this.prepareObservableQueryOptions();\n\n this.previous.observableQueryOptions = {\n ...observableQueryOptions,\n children: void 0,\n };\n this.currentObservable = this.refreshClient().client.watchQuery({\n ...observableQueryOptions\n });\n\n if (this.ssrInitiated()) {\n this.context!.renderPromises!.registerSSRObservable(\n this.currentObservable,\n observableQueryOptions\n );\n }\n }\n }\n\n private updateObservableQuery() {\n // If we skipped initially, we may not have yet created the observable\n if (!this.currentObservable) {\n this.initializeObservableQuery();\n return;\n }\n\n const newObservableQueryOptions = {\n ...this.prepareObservableQueryOptions(),\n children: void 0,\n };\n\n if (this.getOptions().skip) {\n this.previous.observableQueryOptions = newObservableQueryOptions;\n return;\n }\n\n if (\n !equal(newObservableQueryOptions, this.previous.observableQueryOptions)\n ) {\n this.previous.observableQueryOptions = newObservableQueryOptions;\n this.currentObservable\n .setOptions(newObservableQueryOptions)\n // The error will be passed to the child container, so we don't\n // need to log it here. We could conceivably log something if\n // an option was set. OTOH we don't log errors w/ the original\n // query. See https://github.com/apollostack/react-apollo/issues/404\n .catch(() => {});\n }\n }\n\n // Setup a subscription to watch for Apollo Client `ObservableQuery` changes.\n // When new data is received, and it doesn't match the data that was used\n // during the last `QueryData.execute` call (and ultimately the last query\n // component render), trigger the `onNewData` callback. If not specified,\n // `onNewData` will fallback to the default `QueryData.onNewData` function\n // (which usually leads to a query component re-render).\n private startQuerySubscription(onNewData: () => void = this.onNewData) {\n if (this.currentSubscription || this.getOptions().skip) return;\n\n this.currentSubscription = this.currentObservable!.subscribe({\n next: ({ loading, networkStatus, data }) => {\n const previousResult = this.previous.result;\n\n // Make sure we're not attempting to re-render similar results\n if (\n previousResult &&\n previousResult.loading === loading &&\n previousResult.networkStatus === networkStatus &&\n equal(previousResult.data, data)\n ) {\n return;\n }\n\n onNewData();\n },\n error: error => {\n this.resubscribeToQuery();\n if (!error.hasOwnProperty('graphQLErrors')) throw error;\n\n const previousResult = this.previous.result;\n if (\n (previousResult && previousResult.loading) ||\n !equal(error, this.previous.error)\n ) {\n this.previous.error = error;\n onNewData();\n }\n }\n });\n }\n\n private resubscribeToQuery() {\n this.removeQuerySubscription();\n\n // Unfortunately, if `lastError` is set in the current\n // `observableQuery` when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore it afterwards (so the subscription\n // has a chance to stay open).\n const { currentObservable } = this;\n if (currentObservable) {\n const last = currentObservable[\"last\"];\n try {\n currentObservable.resetLastResults();\n this.startQuerySubscription();\n } finally {\n currentObservable[\"last\"] = last;\n }\n }\n }\n\n private getExecuteResult(): QueryResult<TData, TVariables> {\n let result = this.observableQueryFields() as QueryResult<TData, TVariables>;\n const options = this.getOptions();\n\n // When skipping a query (ie. we're not querying for data but still want\n // to render children), make sure the `data` is cleared out and\n // `loading` is set to `false` (since we aren't loading anything).\n //\n // NOTE: We no longer think this is the correct behavior. Skipping should\n // not automatically set `data` to `undefined`, but instead leave the\n // previous data in place. In other words, skipping should not mandate\n // that previously received data is all of a sudden removed. Unfortunately,\n // changing this is breaking, so we'll have to wait until Apollo Client\n // 4.0 to address this.\n if (options.skip) {\n result = {\n ...result,\n data: undefined,\n error: undefined,\n loading: false,\n networkStatus: NetworkStatus.ready,\n called: true,\n };\n } else if (this.currentObservable) {\n // Fetch the current result (if any) from the store.\n const currentResult = this.currentObservable.getCurrentResult();\n const { data, loading, partial, networkStatus, errors } = currentResult;\n let { error } = currentResult;\n\n // Until a set naming convention for networkError and graphQLErrors is\n // decided upon, we map errors (graphQLErrors) to the error options.\n if (errors && errors.length > 0) {\n error = new ApolloError({ graphQLErrors: errors });\n }\n\n result = {\n ...result,\n data,\n loading,\n networkStatus,\n error,\n called: true\n };\n\n if (loading) {\n // Fall through without modifying result...\n } else if (error) {\n Object.assign(result, {\n data: (this.currentObservable.getLastResult() || ({} as any))\n .data\n });\n } else {\n const { fetchPolicy } = this.currentObservable.options;\n const { partialRefetch } = options;\n if (\n partialRefetch &&\n partial &&\n (!data || Object.keys(data).length === 0) &&\n fetchPolicy !== 'cache-only'\n ) {\n // When a `Query` component is mounted, and a mutation is executed\n // that returns the same ID as the mounted `Query`, but has less\n // fields in its result, Apollo Client's `QueryManager` returns the\n // data as `undefined` since a hit can't be found in the cache.\n // This can lead to application errors when the UI elements rendered by\n // the original `Query` component are expecting certain data values to\n // exist, and they're all of a sudden stripped away. To help avoid\n // this we'll attempt to refetch the `Query` data.\n Object.assign(result, {\n loading: true,\n networkStatus: NetworkStatus.loading\n });\n result.refetch();\n return result;\n }\n }\n }\n\n result.client = this.client;\n // Store options as this.previousOptions.\n this.setOptions(options, true);\n\n const previousResult = this.previous.result;\n\n this.previous.loading =\n previousResult && previousResult.loading || false;\n\n // Ensure the returned result contains previousData as a separate\n // property, to give developers the flexibility of leveraging outdated\n // data while new data is loading from the network. Falling back to\n // previousResult.previousData when previousResult.data is falsy here\n // allows result.previousData to persist across multiple results.\n result.previousData = previousResult &&\n (previousResult.data || previousResult.previousData);\n\n this.previous.result = result;\n\n // Any query errors that exist are now available in `result`, so we'll\n // remove the original errors from the `ObservableQuery` query store to\n // make sure they aren't re-displayed on subsequent (potentially error\n // free) requests/responses.\n this.currentObservable && this.currentObservable.resetQueryStoreErrors();\n\n return result;\n }\n\n private handleErrorOrCompleted() {\n if (!this.currentObservable || !this.previous.result) return;\n\n const { data, loading, error } = this.previous.result;\n\n if (!loading) {\n const {\n query,\n variables,\n onCompleted,\n onError,\n skip\n } = this.getOptions();\n\n // No changes, so we won't call onError/onCompleted.\n if (\n this.previousOptions &&\n !this.previous.loading &&\n equal(this.previousOptions.query, query) &&\n equal(this.previousOptions.variables, variables)\n ) {\n return;\n }\n\n if (onCompleted && !error && !skip) {\n onCompleted(data as TData);\n } else if (onError && error) {\n onError(error);\n }\n }\n }\n\n private removeQuerySubscription() {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n delete this.currentSubscription;\n }\n }\n\n private removeObservable(andDelete: boolean) {\n if (this.currentObservable) {\n this.currentObservable[\"tearDownQuery\"]();\n if (andDelete) {\n delete this.currentObservable;\n }\n }\n }\n\n private obsRefetch = (variables?: Partial<TVariables>) =>\n this.currentObservable?.refetch(variables);\n\n private obsFetchMore = (\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> &\n FetchMoreOptions<TData, TVariables>\n ) => this.currentObservable?.fetchMore(fetchMoreOptions);\n\n private obsUpdateQuery = <TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: UpdateQueryOptions<TVars>\n ) => TData\n ) => this.currentObservable?.updateQuery(mapFn);\n\n private obsStartPolling = (pollInterval: number) => {\n this.currentObservable?.startPolling(pollInterval);\n };\n\n private obsStopPolling = () => {\n this.currentObservable?.stopPolling();\n };\n\n private obsSubscribeToMore = <\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) => this.currentObservable?.subscribeToMore(options);\n\n private observableQueryFields() {\n return {\n variables: this.currentObservable?.variables,\n refetch: this.obsRefetch,\n fetchMore: this.obsFetchMore,\n updateQuery: this.obsUpdateQuery,\n startPolling: this.obsStartPolling,\n stopPolling: this.obsStopPolling,\n subscribeToMore: this.obsSubscribeToMore\n } as ObservableQueryFields<TData, TVariables>;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QueryData.js","sourceRoot":"","sources":["../../../src/react/data/QueryData.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAEL,aAAa,GAQd,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD;IAAkD,6BAEjD;IAgBC,mBAAY,EAQX;YAPC,OAAO,aAAA,EACP,OAAO,aAAA,EACP,SAAS,eAAA;QAHX,YASE,kBAAM,OAAO,EAAE,OAAO,CAAC,SAExB;QAvBO,aAAO,GAAY,KAAK,CAAC;QAEzB,cAAQ,GAQZ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAkGhB,kBAAY,GAAG,UA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WAAW,EAAE,IAAI,CAAC,cAAc;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe;YAClC,WAAW,EAAE,IAAI,CAAC,cAAc;YAChC,eAAe,EAAE,IAAI,CAAC,kBAAkB;SACG,CAAC;IAChD,CAAC;IACH,gBAAC;AAAD,CAAC,AAjfD,CAAkD,aAAa,GAif9D","sourcesContent":["import { equal } from '@wry/equality';\n\nimport { ApolloError } from '../../errors';\n\nimport {\n ApolloClient,\n NetworkStatus,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n ObservableQuery,\n FetchMoreOptions,\n UpdateQueryOptions,\n DocumentNode,\n TypedDocumentNode,\n} from '../../core';\n\nimport {\n ObservableSubscription\n} from '../../utilities';\n\nimport { DocumentType } from '../parser';\nimport {\n QueryResult,\n QueryDataOptions,\n QueryTuple,\n QueryLazyOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { OperationData } from './OperationData';\n\ntype ObservableQueryOptions<TData, TVars> =\n ReturnType<QueryData<TData, TVars>[\"prepareObservableQueryOptions\"]>;\n\nexport class QueryData<TData, TVariables> extends OperationData<\n QueryDataOptions<TData, TVariables>\n> {\n public onNewData: () => void;\n public currentObservable?: ObservableQuery<TData, TVariables>;\n private currentSubscription?: ObservableSubscription;\n private runLazy: boolean = false;\n private lazyOptions?: QueryLazyOptions<TVariables>;\n private previous: {\n client?: ApolloClient<object>;\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n observableQueryOptions?: ObservableQueryOptions<TData, TVariables>;\n result?: QueryResult<TData, TVariables>;\n loading?: boolean;\n options?: QueryDataOptions<TData, TVariables>;\n error?: ApolloError;\n } = Object.create(null);\n\n constructor({\n options,\n context,\n onNewData\n }: {\n options: QueryDataOptions<TData, TVariables>;\n context: any;\n onNewData: () => void;\n }) {\n super(options, context);\n this.onNewData = onNewData;\n }\n\n public execute(): QueryResult<TData, TVariables> {\n this.refreshClient();\n\n const { skip, query } = this.getOptions();\n if (skip || query !== this.previous.query) {\n this.removeQuerySubscription();\n this.removeObservable(!skip);\n this.previous.query = query;\n }\n\n this.updateObservableQuery();\n\n return this.getExecuteSsrResult() || this.getExecuteResult();\n }\n\n public executeLazy(): QueryTuple<TData, TVariables> {\n return !this.runLazy\n ? [\n this.runLazyQuery,\n {\n loading: false,\n networkStatus: NetworkStatus.ready,\n called: false,\n data: undefined\n }\n ]\n : [this.runLazyQuery, this.execute()];\n }\n\n // For server-side rendering\n public fetchData(): Promise<void> | boolean {\n const options = this.getOptions();\n if (options.skip || options.ssr === false) return false;\n return new Promise(resolve => this.startQuerySubscription(resolve));\n }\n\n public afterExecute({ lazy = false }: { lazy?: boolean } = {}) {\n this.isMounted = true;\n const options = this.getOptions();\n if (this.currentObservable && !this.ssrInitiated()) {\n this.startQuerySubscription();\n }\n\n if (!lazy || this.runLazy) {\n this.handleErrorOrCompleted();\n }\n\n this.previousOptions = options;\n return this.unmount.bind(this);\n }\n\n public cleanup() {\n this.removeQuerySubscription();\n this.removeObservable(true);\n delete this.previous.result;\n }\n\n public getOptions() {\n const options = super.getOptions();\n\n if (this.lazyOptions) {\n options.variables = {\n ...options.variables,\n ...this.lazyOptions.variables\n } as TVariables;\n options.context = {\n ...options.context,\n ...this.lazyOptions.context\n };\n }\n\n // skip is not supported when using lazy query execution.\n if (this.runLazy) {\n delete options.skip;\n }\n\n return options;\n }\n\n public ssrInitiated() {\n return this.context && this.context.renderPromises;\n }\n\n private runLazyQuery = (options?: QueryLazyOptions<TVariables>) => {\n this.cleanup();\n this.runLazy = true;\n this.lazyOptions = options;\n this.onNewData();\n };\n\n private getExecuteSsrResult() {\n const { ssr, skip } = this.getOptions();\n const ssrDisabled = ssr === false;\n const fetchDisabled = this.refreshClient().client.disableNetworkFetches;\n\n const ssrLoading = {\n loading: true,\n networkStatus: NetworkStatus.loading,\n called: true,\n data: undefined,\n stale: false,\n client: this.client,\n ...this.observableQueryFields(),\n } as QueryResult<TData, TVariables>;\n\n // If SSR has been explicitly disabled, and this function has been called\n // on the server side, return the default loading state.\n if (ssrDisabled && (this.ssrInitiated() || fetchDisabled)) {\n this.previous.result = ssrLoading;\n return ssrLoading;\n }\n\n if (this.ssrInitiated()) {\n const result = this.getExecuteResult() || ssrLoading;\n if (result.loading && !skip) {\n this.context.renderPromises!.addQueryPromise(this, () => null);\n }\n return result;\n }\n }\n\n private prepareObservableQueryOptions() {\n const options = this.getOptions();\n this.verifyDocumentType(options.query, DocumentType.Query);\n const displayName = options.displayName || 'Query';\n\n // Set the fetchPolicy to cache-first for network-only and cache-and-network\n // fetches for server side renders.\n if (\n this.ssrInitiated() &&\n (options.fetchPolicy === 'network-only' ||\n options.fetchPolicy === 'cache-and-network')\n ) {\n options.fetchPolicy = 'cache-first';\n }\n\n return {\n ...options,\n displayName,\n context: options.context,\n };\n }\n\n private initializeObservableQuery() {\n // See if there is an existing observable that was used to fetch the same\n // data and if so, use it instead since it will contain the proper queryId\n // to fetch the result set. This is used during SSR.\n if (this.ssrInitiated()) {\n this.currentObservable = this.context!.renderPromises!.getSSRObservable(\n this.getOptions()\n );\n }\n\n if (!this.currentObservable) {\n const observableQueryOptions = this.prepareObservableQueryOptions();\n\n this.previous.observableQueryOptions = {\n ...observableQueryOptions,\n children: void 0,\n };\n this.currentObservable = this.refreshClient().client.watchQuery({\n ...observableQueryOptions\n });\n\n if (this.ssrInitiated()) {\n this.context!.renderPromises!.registerSSRObservable(\n this.currentObservable,\n observableQueryOptions\n );\n }\n }\n }\n\n private updateObservableQuery() {\n // If we skipped initially, we may not have yet created the observable\n if (!this.currentObservable) {\n this.initializeObservableQuery();\n return;\n }\n\n const newObservableQueryOptions = {\n ...this.prepareObservableQueryOptions(),\n children: void 0,\n };\n\n if (this.getOptions().skip) {\n this.previous.observableQueryOptions = newObservableQueryOptions;\n return;\n }\n\n if (\n !equal(newObservableQueryOptions, this.previous.observableQueryOptions)\n ) {\n this.previous.observableQueryOptions = newObservableQueryOptions;\n this.currentObservable\n .setOptions(newObservableQueryOptions)\n // The error will be passed to the child container, so we don't\n // need to log it here. We could conceivably log something if\n // an option was set. OTOH we don't log errors w/ the original\n // query. See https://github.com/apollostack/react-apollo/issues/404\n .catch(() => {});\n }\n }\n\n // Setup a subscription to watch for Apollo Client `ObservableQuery` changes.\n // When new data is received, and it doesn't match the data that was used\n // during the last `QueryData.execute` call (and ultimately the last query\n // component render), trigger the `onNewData` callback. If not specified,\n // `onNewData` will fallback to the default `QueryData.onNewData` function\n // (which usually leads to a query component re-render).\n private startQuerySubscription(onNewData: () => void = this.onNewData) {\n if (this.currentSubscription || this.getOptions().skip) return;\n\n this.currentSubscription = this.currentObservable!.subscribe({\n next: ({ loading, networkStatus, data }) => {\n const previousResult = this.previous.result;\n\n // Make sure we're not attempting to re-render similar results\n if (\n previousResult &&\n previousResult.loading === loading &&\n previousResult.networkStatus === networkStatus &&\n equal(previousResult.data, data)\n ) {\n return;\n }\n\n onNewData();\n },\n error: error => {\n this.resubscribeToQuery();\n if (!error.hasOwnProperty('graphQLErrors')) throw error;\n\n const previousResult = this.previous.result;\n if (\n (previousResult && previousResult.loading) ||\n !equal(error, this.previous.error)\n ) {\n this.previous.error = error;\n onNewData();\n }\n }\n });\n }\n\n private resubscribeToQuery() {\n this.removeQuerySubscription();\n\n // Unfortunately, if `lastError` is set in the current\n // `observableQuery` when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore it afterwards (so the subscription\n // has a chance to stay open).\n const { currentObservable } = this;\n if (currentObservable) {\n const last = currentObservable[\"last\"];\n try {\n currentObservable.resetLastResults();\n this.startQuerySubscription();\n } finally {\n currentObservable[\"last\"] = last;\n }\n }\n }\n\n private getExecuteResult(): QueryResult<TData, TVariables> {\n let result = this.observableQueryFields() as QueryResult<TData, TVariables>;\n const options = this.getOptions();\n\n // When skipping a query (ie. we're not querying for data but still want\n // to render children), make sure the `data` is cleared out and\n // `loading` is set to `false` (since we aren't loading anything).\n //\n // NOTE: We no longer think this is the correct behavior. Skipping should\n // not automatically set `data` to `undefined`, but instead leave the\n // previous data in place. In other words, skipping should not mandate\n // that previously received data is all of a sudden removed. Unfortunately,\n // changing this is breaking, so we'll have to wait until Apollo Client\n // 4.0 to address this.\n if (options.skip) {\n result = {\n ...result,\n data: undefined,\n error: undefined,\n loading: false,\n networkStatus: NetworkStatus.ready,\n called: true,\n };\n } else if (this.currentObservable) {\n // Fetch the current result (if any) from the store.\n const currentResult = this.currentObservable.getCurrentResult();\n const { data, loading, partial, networkStatus, errors } = currentResult;\n let { error } = currentResult;\n\n // Until a set naming convention for networkError and graphQLErrors is\n // decided upon, we map errors (graphQLErrors) to the error options.\n if (errors && errors.length > 0) {\n error = new ApolloError({ graphQLErrors: errors });\n }\n\n result = {\n ...result,\n data,\n loading,\n networkStatus,\n error,\n called: true\n };\n\n if (loading) {\n // Fall through without modifying result...\n } else if (error) {\n Object.assign(result, {\n data: (this.currentObservable.getLastResult() || ({} as any))\n .data\n });\n } else {\n const { fetchPolicy } = this.currentObservable.options;\n const { partialRefetch } = options;\n if (\n partialRefetch &&\n partial &&\n (!data || Object.keys(data).length === 0) &&\n fetchPolicy !== 'cache-only'\n ) {\n // When a `Query` component is mounted, and a mutation is executed\n // that returns the same ID as the mounted `Query`, but has less\n // fields in its result, Apollo Client's `QueryManager` returns the\n // data as `undefined` since a hit can't be found in the cache.\n // This can lead to application errors when the UI elements rendered by\n // the original `Query` component are expecting certain data values to\n // exist, and they're all of a sudden stripped away. To help avoid\n // this we'll attempt to refetch the `Query` data.\n Object.assign(result, {\n loading: true,\n networkStatus: NetworkStatus.loading\n });\n result.refetch();\n return result;\n }\n }\n }\n\n result.client = this.client;\n // Store options as this.previousOptions.\n this.setOptions(options, true);\n\n const previousResult = this.previous.result;\n\n this.previous.loading =\n previousResult && previousResult.loading || false;\n\n // Ensure the returned result contains previousData as a separate\n // property, to give developers the flexibility of leveraging outdated\n // data while new data is loading from the network. Falling back to\n // previousResult.previousData when previousResult.data is falsy here\n // allows result.previousData to persist across multiple results.\n result.previousData = previousResult &&\n (previousResult.data || previousResult.previousData);\n\n this.previous.result = result;\n\n // Any query errors that exist are now available in `result`, so we'll\n // remove the original errors from the `ObservableQuery` query store to\n // make sure they aren't re-displayed on subsequent (potentially error\n // free) requests/responses.\n this.currentObservable && this.currentObservable.resetQueryStoreErrors();\n\n return result;\n }\n\n private handleErrorOrCompleted() {\n if (!this.currentObservable || !this.previous.result) return;\n\n const { data, loading, error } = this.previous.result;\n\n if (!loading) {\n const {\n query,\n variables,\n onCompleted,\n onError,\n skip\n } = this.getOptions();\n\n // No changes, so we won't call onError/onCompleted.\n if (\n this.previousOptions &&\n !this.previous.loading &&\n equal(this.previousOptions.query, query) &&\n equal(this.previousOptions.variables, variables)\n ) {\n return;\n }\n\n if (onCompleted && !error && !skip) {\n onCompleted(data as TData);\n } else if (onError && error) {\n onError(error);\n }\n }\n }\n\n private removeQuerySubscription() {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n delete this.currentSubscription;\n }\n }\n\n private removeObservable(andDelete: boolean) {\n if (this.currentObservable) {\n this.currentObservable[\"tearDownQuery\"]();\n if (andDelete) {\n delete this.currentObservable;\n }\n }\n }\n\n private obsRefetch = (variables?: Partial<TVariables>) =>\n this.currentObservable?.refetch(variables);\n\n private obsFetchMore = (\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> &\n FetchMoreOptions<TData, TVariables>\n ) => this.currentObservable?.fetchMore(fetchMoreOptions);\n\n private obsUpdateQuery = <TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: UpdateQueryOptions<TVars>\n ) => TData\n ) => this.currentObservable?.updateQuery(mapFn);\n\n private obsStartPolling = (pollInterval: number) => {\n this.currentObservable?.startPolling(pollInterval);\n };\n\n private obsStopPolling = () => {\n this.currentObservable?.stopPolling();\n };\n\n private obsSubscribeToMore = <\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) => this.currentObservable?.subscribeToMore(options);\n\n private observableQueryFields() {\n return {\n variables: this.currentObservable?.variables,\n refetch: this.obsRefetch,\n fetchMore: this.obsFetchMore,\n updateQuery: this.obsUpdateQuery,\n startPolling: this.obsStartPolling,\n stopPolling: this.obsStopPolling,\n subscribeToMore: this.obsSubscribeToMore\n } as ObservableQueryFields<TData, TVariables>;\n }\n}\n"]}
|
package/react/data/data.cjs.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var globals = require('../../utilities/globals');
|
|
6
6
|
var tslib = require('tslib');
|
|
7
7
|
var equality = require('@wry/equality');
|
|
8
|
-
var tsInvariant = require('ts-invariant');
|
|
9
8
|
var parser = require('../parser');
|
|
10
9
|
var errors = require('../../errors');
|
|
11
10
|
var core = require('../../core');
|
|
@@ -35,9 +34,9 @@ var OperationData = (function () {
|
|
|
35
34
|
OperationData.prototype.refreshClient = function () {
|
|
36
35
|
var client = (this.options && this.options.client) ||
|
|
37
36
|
(this.context && this.context.client);
|
|
38
|
-
__DEV__ ?
|
|
37
|
+
__DEV__ ? globals.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
39
38
|
'Wrap the root component in an <ApolloProvider>, or pass an ' +
|
|
40
|
-
'ApolloClient instance in via options.') :
|
|
39
|
+
'ApolloClient instance in via options.') : globals.invariant(!!client, 29);
|
|
41
40
|
var isNew = false;
|
|
42
41
|
if (client !== this.client) {
|
|
43
42
|
isNew = true;
|
|
@@ -53,8 +52,8 @@ var OperationData = (function () {
|
|
|
53
52
|
var operation = parser.parser(document);
|
|
54
53
|
var requiredOperationName = parser.operationName(type);
|
|
55
54
|
var usedOperationName = parser.operationName(operation.type);
|
|
56
|
-
__DEV__ ?
|
|
57
|
-
(requiredOperationName + ", but a " + usedOperationName + " was used instead.")) :
|
|
55
|
+
__DEV__ ? globals.invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
|
|
56
|
+
(requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : globals.invariant(operation.type === type, 30);
|
|
58
57
|
};
|
|
59
58
|
return OperationData;
|
|
60
59
|
}());
|
|
@@ -348,9 +347,7 @@ var QueryData = (function (_super) {
|
|
|
348
347
|
var _b = _a === void 0 ? {} : _a, _c = _b.lazy, lazy = _c === void 0 ? false : _c;
|
|
349
348
|
this.isMounted = true;
|
|
350
349
|
var options = this.getOptions();
|
|
351
|
-
if (this.currentObservable &&
|
|
352
|
-
!this.ssrInitiated() &&
|
|
353
|
-
!this.client.disableNetworkFetches) {
|
|
350
|
+
if (this.currentObservable && !this.ssrInitiated()) {
|
|
354
351
|
this.startQuerySubscription();
|
|
355
352
|
}
|
|
356
353
|
if (!lazy || this.runLazy) {
|
|
@@ -577,8 +574,6 @@ var QueryData = (function (_super) {
|
|
|
577
574
|
return QueryData;
|
|
578
575
|
}(OperationData));
|
|
579
576
|
|
|
580
|
-
utilities.checkDEV();
|
|
581
|
-
|
|
582
577
|
exports.MutationData = MutationData;
|
|
583
578
|
exports.OperationData = OperationData;
|
|
584
579
|
exports.QueryData = QueryData;
|