@apollo/client 3.7.2 → 3.8.0-alpha.0
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/apollo-client.cjs +250 -30
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/config/jest/setup.d.ts +1 -1
- package/config/jest/setup.d.ts.map +1 -1
- package/config/jest/setup.js +1 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +3 -2
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +6 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/core.cjs +10 -5
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +10 -5
- package/core/watchQueryOptions.d.ts +1 -0
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +35 -23
- package/package.json +17 -3
- package/react/cache/SuspenseCache.d.ts +18 -0
- package/react/cache/SuspenseCache.d.ts.map +1 -0
- package/react/cache/SuspenseCache.js +49 -0
- package/react/cache/SuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +2 -0
- package/react/cache/index.d.ts.map +1 -0
- package/react/cache/index.js +2 -0
- package/react/cache/index.js.map +1 -0
- package/react/context/ApolloContext.d.ts +2 -0
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +2 -0
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +4 -1
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +4 -1
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +4 -1
- package/react/hooks/compareResults.d.ts +3 -0
- package/react/hooks/compareResults.d.ts.map +1 -0
- package/react/hooks/compareResults.js +63 -0
- package/react/hooks/compareResults.js.map +1 -0
- package/react/hooks/hooks.cjs +167 -3
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +167 -3
- package/react/hooks/index.d.ts +1 -0
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/index.d.ts +2 -0
- package/react/hooks/internal/index.d.ts.map +1 -0
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -0
- package/react/hooks/internal/useDeepMemo.d.ts +3 -0
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
- package/react/hooks/internal/useDeepMemo.js +10 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -0
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +5 -3
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +2 -0
- package/react/hooks/useSuspenseCache.d.ts.map +1 -0
- package/react/hooks/useSuspenseCache.js +10 -0
- package/react/hooks/useSuspenseCache.js.map +1 -0
- package/react/hooks/useSuspenseQuery.d.ts +10 -0
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
- package/react/hooks/useSuspenseQuery.js +157 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -0
- package/react/index.d.ts +1 -0
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/react.cjs +49 -2
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +49 -2
- package/react/types/types.d.ts +9 -1
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.js +1 -1
- package/testing/react/MockedProvider.d.ts +3 -0
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +8 -3
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +54 -3
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +54 -3
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/utilities.cjs +16 -16
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +16 -16
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGrF,OAAO,EACL,YAAY,EACZ,iBAAiB,EAGjB,YAAY,EACZ,iBAAiB,EAElB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,wBAAgB,QAAQ,CACtB,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAE/B,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,GAAE,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAuB,GACjE,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,CAKhC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAChD,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,EACzB,KAAK,EAAE,YAA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AC;IAgHrD,OAAO,CAAC,cAAc,CAAuC;IAC7D,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,OAAO,CAAC,iBAAiB,CAAuC;IAEhE,OAAO,CAAC,UAAU;IA0FlB,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,iBAAiB,CAKtB;IAEH,OAAO,CAAC,iBAAiB,CAKtB;IAGH,OAAO,CAAC,uBAAuB;IAsD/B,qBAAqB,IAAI,qBAAqB;IAW9C,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,OAAO;IAEf,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,cAAc,CAGpB;IAEF,OAAO,CAAC,kBAAkB;IAuC1B,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,YAAY,CAAoB;IAExC,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,sBAAsB;IAsB9B,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,kBAAkB,CAGtB;IAEJ,aAAa,CACX,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAC/B,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;IA2BjC,OAAO,CAAC,0BAA0B;CAoBnC"}
|
package/react/hooks/useQuery.js
CHANGED
|
@@ -234,16 +234,18 @@ var InternalState = (function () {
|
|
|
234
234
|
}
|
|
235
235
|
this.result = nextResult;
|
|
236
236
|
this.forceUpdate();
|
|
237
|
-
this.handleErrorOrCompleted(nextResult);
|
|
237
|
+
this.handleErrorOrCompleted(nextResult, previousResult);
|
|
238
238
|
};
|
|
239
|
-
InternalState.prototype.handleErrorOrCompleted = function (result) {
|
|
239
|
+
InternalState.prototype.handleErrorOrCompleted = function (result, previousResult) {
|
|
240
240
|
var _this = this;
|
|
241
241
|
if (!result.loading) {
|
|
242
242
|
Promise.resolve().then(function () {
|
|
243
243
|
if (result.error) {
|
|
244
244
|
_this.onError(result.error);
|
|
245
245
|
}
|
|
246
|
-
else if (result.data
|
|
246
|
+
else if (result.data &&
|
|
247
|
+
(previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus) !== result.networkStatus &&
|
|
248
|
+
result.networkStatus === NetworkStatus.ready) {
|
|
247
249
|
_this.onCompleted(result.data);
|
|
248
250
|
}
|
|
249
251
|
}).catch(function (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAA6C,MAAM,YAAY,CAAC;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,aAAa,GAKd,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAItG,IAAA,cAAc,GAEd,MAAM,yBAFQ,CAEP;AAEX,MAAM,UAAU,QAAQ,CAItB,KAA0D,EAC1D,OAAkE;IAAlE,wBAAA,EAAA,UAA+C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAElE,OAAO,gBAAgB,CACrB,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAC/B,KAAK,CACN,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtB,C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MjE,IACE,MAAM,CAAC,OAAO;YACd,IAAI,CAAC,gBAAgB,CAAC,cAAc;YACpC,CAAC,MAAM,CAAC,OAAO;YACf,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;YACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,KAAK,YAAY,EACpD;YACA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;gBACpB,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,aAAa,CAAC,OAAO;aACrC,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC3B;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AA1fD,IA0fC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useSyncExternalStore } from './useSyncExternalStore';\nimport { equal } from '@wry/equality';\n\nimport { mergeOptions, OperationVariables, WatchQueryFetchPolicy } from '../../core';\nimport { ApolloContextValue, getApolloContext } from '../context';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloClient,\n ApolloQueryResult,\n NetworkStatus,\n ObservableQuery,\n DocumentNode,\n TypedDocumentNode,\n WatchQueryOptions,\n} from '../../core';\nimport {\n QueryHookOptions,\n QueryResult,\n ObservableQueryFields,\n} from '../types/types';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { useApolloClient } from './useApolloClient';\nimport { canUseWeakMap, canUseWeakSet, compact, isNonEmptyArray, maybeDeepFreeze } from '../../utilities';\n\nconst {\n prototype: {\n hasOwnProperty,\n },\n} = Object;\n\nexport function useQuery<\n TData = any,\n TVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<TData, TVariables> = Object.create(null),\n): QueryResult<TData, TVariables> {\n return useInternalState(\n useApolloClient(options.client),\n query,\n ).useQuery(options);\n}\n\nexport function useInternalState<TData, TVariables>(\n client: ApolloClient<any>,\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n): InternalState<TData, TVariables> {\n const stateRef = useRef<InternalState<TData, TVariables>>();\n if (\n !stateRef.current ||\n client !== stateRef.current.client ||\n query !== stateRef.current.query\n ) {\n stateRef.current = new InternalState(client, query, stateRef.current);\n }\n const state = stateRef.current;\n\n // By default, InternalState.prototype.forceUpdate is an empty function, but\n // we replace it here (before anyone has had a chance to see this state yet)\n // with a function that unconditionally forces an update, using the latest\n // setTick function. Updating this state by calling state.forceUpdate is the\n // only way we trigger React component updates (no other useState calls within\n // the InternalState class).\n const [_tick, setTick] = useState(0);\n state.forceUpdate = () => {\n setTick(tick => tick + 1);\n };\n\n return state;\n}\n\nclass InternalState<TData, TVariables> {\n constructor(\n public readonly client: ReturnType<typeof useApolloClient>,\n public readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n previous?: InternalState<TData, TVariables>,\n ) {\n verifyDocumentType(query, DocumentType.Query);\n\n // Reuse previousData from previous InternalState (if any) to provide\n // continuity of previousData even if/when the query or client changes.\n const previousResult = previous && previous.result;\n const previousData = previousResult && previousResult.data;\n if (previousData) {\n this.previousData = previousData;\n }\n }\n\n forceUpdate() {\n // Replaced (in useInternalState) with a method that triggers an update.\n invariant.warn(\"Calling default no-op implementation of InternalState#forceUpdate\");\n }\n\n asyncUpdate() {\n return new Promise<QueryResult<TData, TVariables>>(resolve => {\n this.asyncResolveFns.add(resolve);\n this.optionsToIgnoreOnce.add(this.watchQueryOptions);\n this.forceUpdate();\n });\n }\n\n private asyncResolveFns = new Set<\n (result: QueryResult<TData, TVariables>) => void\n >();\n\n private optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)<\n WatchQueryOptions<TVariables, TData>\n >();\n\n // Methods beginning with use- should be called according to the standard\n // rules of React hooks: only at the top level of the calling function, and\n // without any dynamic conditional logic.\n useQuery(options: QueryHookOptions<TData, TVariables>) {\n // The renderPromises field gets initialized here in the useQuery method, at\n // the beginning of everything (for a given component rendering, at least),\n // so we can safely use this.renderPromises in other/later InternalState\n // methods without worrying it might be uninitialized. Even after\n // initialization, this.renderPromises is usually undefined (unless SSR is\n // happening), but that's fine as long as it has been initialized that way,\n // rather than left uninitialized.\n this.renderPromises = useContext(getApolloContext()).renderPromises;\n\n this.useOptions(options);\n\n const obsQuery = this.useObservableQuery();\n\n const result = useSyncExternalStore(\n useCallback(() => {\n if (this.renderPromises) {\n return () => {};\n }\n\n const onNext = () => {\n const previousResult = this.result;\n // We use `getCurrentResult()` instead of the onNext argument because\n // the values differ slightly. Specifically, loading results will have\n // an empty object for data instead of `undefined` for some reason.\n const result = obsQuery.getCurrentResult();\n // Make sure we're not attempting to re-render similar results\n if (\n previousResult &&\n previousResult.loading === result.loading &&\n previousResult.networkStatus === result.networkStatus &&\n equal(previousResult.data, result.data)\n ) {\n return;\n }\n\n this.setResult(result);\n };\n\n const onError = (error: Error) => {\n const last = obsQuery[\"last\"];\n subscription.unsubscribe();\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 try {\n obsQuery.resetLastResults();\n subscription = obsQuery.subscribe(onNext, onError);\n } finally {\n obsQuery[\"last\"] = last;\n }\n\n if (!hasOwnProperty.call(error, 'graphQLErrors')) {\n // The error is not a GraphQL error\n throw error;\n }\n\n const previousResult = this.result;\n if (\n !previousResult ||\n (previousResult && previousResult.loading) ||\n !equal(error, previousResult.error)\n ) {\n this.setResult({\n data: (previousResult && previousResult.data) as TData,\n error: error as ApolloError,\n loading: false,\n networkStatus: NetworkStatus.error,\n });\n }\n };\n\n let subscription = obsQuery.subscribe(onNext, onError);\n\n return () => subscription.unsubscribe();\n }, [\n // We memoize the subscribe function using useCallback and the following\n // dependency keys, because the subscribe function reference is all that\n // useSyncExternalStore uses internally as a dependency key for the\n // useEffect ultimately responsible for the subscription, so we are\n // effectively passing this dependency array to that useEffect buried\n // inside useSyncExternalStore, as desired.\n obsQuery,\n this.renderPromises,\n this.client.disableNetworkFetches,\n ]),\n\n () => this.getCurrentResult(),\n () => this.getCurrentResult(),\n );\n\n // TODO Remove this method when we remove support for options.partialRefetch.\n this.unsafeHandlePartialRefetch(result);\n\n const queryResult = this.toQueryResult(result);\n\n if (!queryResult.loading && this.asyncResolveFns.size) {\n this.asyncResolveFns.forEach(resolve => resolve(queryResult));\n this.asyncResolveFns.clear();\n }\n\n return queryResult;\n }\n\n // These members (except for renderPromises) are all populated by the\n // useOptions method, which is called unconditionally at the beginning of the\n // useQuery method, so we can safely use these members in other/later methods\n // without worrying they might be uninitialized.\n private renderPromises: ApolloContextValue[\"renderPromises\"];\n private queryHookOptions: QueryHookOptions<TData, TVariables>;\n private watchQueryOptions: WatchQueryOptions<TVariables, TData>;\n\n private useOptions(\n options: QueryHookOptions<TData, TVariables>,\n ) {\n const watchQueryOptions = this.createWatchQueryOptions(\n this.queryHookOptions = options,\n );\n\n // Update this.watchQueryOptions, but only when they have changed, which\n // allows us to depend on the referential stability of\n // this.watchQueryOptions elsewhere.\n const currentWatchQueryOptions = this.watchQueryOptions;\n\n // To force this equality test to \"fail,\" thereby reliably triggering\n // observable.reobserve, add any current WatchQueryOptions object(s) you\n // want to be ignored to this.optionsToIgnoreOnce. A similar effect could be\n // achieved by nullifying this.watchQueryOptions so the equality test\n // immediately fails because currentWatchQueryOptions is null, but this way\n // we can promise a truthy this.watchQueryOptions at all times.\n if (\n this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||\n !equal(watchQueryOptions, currentWatchQueryOptions)\n ) {\n this.watchQueryOptions = watchQueryOptions;\n\n if (currentWatchQueryOptions && this.observable) {\n // As advertised in the -Once of this.optionsToIgnoreOnce, this trick is\n // only good for one forced execution of observable.reobserve per\n // ignored WatchQueryOptions object, though it is unlikely we will ever\n // see this exact currentWatchQueryOptions object again here, since we\n // just replaced this.watchQueryOptions with watchQueryOptions.\n this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);\n\n // Though it might be tempting to postpone this reobserve call to the\n // useEffect block, we need getCurrentResult to return an appropriate\n // loading:true result synchronously (later within the same call to\n // useQuery). Since we already have this.observable here (not true for\n // the very first call to useQuery), we are not initiating any new\n // subscriptions, though it does feel less than ideal that reobserve\n // (potentially) kicks off a network request (for example, when the\n // variables have changed), which is technically a side-effect.\n this.observable.reobserve(this.getObsQueryOptions());\n\n // Make sure getCurrentResult returns a fresh ApolloQueryResult<TData>,\n // but save the current data as this.previousData, just like setResult\n // usually does.\n this.previousData = this.result?.data || this.previousData;\n this.result = void 0;\n }\n }\n\n // Make sure state.onCompleted and state.onError always reflect the latest\n // options.onCompleted and options.onError callbacks provided to useQuery,\n // since those functions are often recreated every time useQuery is called.\n // Like the forceUpdate method, the versions of these methods inherited from\n // InternalState.prototype are empty no-ops, but we can override them on the\n // base state object (without modifying the prototype).\n this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;\n this.onError = options.onError || InternalState.prototype.onError;\n\n if (\n (this.renderPromises || this.client.disableNetworkFetches) &&\n this.queryHookOptions.ssr === false &&\n !this.queryHookOptions.skip\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 this.result = this.ssrDisabledResult;\n } else if (\n this.queryHookOptions.skip ||\n this.watchQueryOptions.fetchPolicy === 'standby'\n ) {\n // When skipping a query (ie. we're not querying for data but still want to\n // render children), make sure the `data` is cleared out and `loading` is\n // 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 that\n // previously received data is all of a sudden removed. Unfortunately,\n // changing this is breaking, so we'll have to wait until Apollo Client 4.0\n // to address this.\n this.result = this.skipStandbyResult;\n } else if (\n this.result === this.ssrDisabledResult ||\n this.result === this.skipStandbyResult\n ) {\n this.result = void 0;\n }\n }\n\n private getObsQueryOptions(): WatchQueryOptions<TVariables, TData> {\n const toMerge: Array<\n Partial<WatchQueryOptions<TVariables, TData>>\n > = [];\n\n const globalDefaults = this.client.defaultOptions.watchQuery;\n if (globalDefaults) toMerge.push(globalDefaults);\n\n if (this.queryHookOptions.defaultOptions) {\n toMerge.push(this.queryHookOptions.defaultOptions);\n }\n\n // We use compact rather than mergeOptions for this part of the merge,\n // because we want watchQueryOptions.variables (if defined) to replace\n // this.observable.options.variables whole. This replacement allows\n // removing variables by removing them from the variables input to\n // useQuery. If the variables were always merged together (rather than\n // replaced), there would be no way to remove existing variables.\n // However, the variables from options.defaultOptions and globalDefaults\n // (if provided) should be merged, to ensure individual defaulted\n // variables always have values, if not otherwise defined in\n // observable.options or watchQueryOptions.\n toMerge.push(compact(\n this.observable && this.observable.options,\n this.watchQueryOptions,\n ));\n\n return toMerge.reduce(\n mergeOptions\n ) as WatchQueryOptions<TVariables, TData>;\n }\n\n private ssrDisabledResult = maybeDeepFreeze({\n loading: true,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.loading,\n });\n\n private skipStandbyResult = maybeDeepFreeze({\n loading: false,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.ready,\n });\n\n // A function to massage options before passing them to ObservableQuery.\n private createWatchQueryOptions({\n skip,\n ssr,\n onCompleted,\n onError,\n defaultOptions,\n // The above options are useQuery-specific, so this ...otherOptions spread\n // makes otherOptions almost a WatchQueryOptions object, except for the\n // query property that we add below.\n ...otherOptions\n }: QueryHookOptions<TData, TVariables> = {}): WatchQueryOptions<TVariables, TData> {\n // This Object.assign is safe because otherOptions is a fresh ...rest object\n // that did not exist until just now, so modifications are still allowed.\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> =\n Object.assign(otherOptions, { query: this.query });\n\n if (\n this.renderPromises &&\n (\n watchQueryOptions.fetchPolicy === 'network-only' ||\n watchQueryOptions.fetchPolicy === 'cache-and-network'\n )\n ) {\n // this behavior was added to react-apollo without explanation in this PR\n // https://github.com/apollographql/react-apollo/pull/1579\n watchQueryOptions.fetchPolicy = 'cache-first';\n }\n\n if (!watchQueryOptions.variables) {\n watchQueryOptions.variables = {} as TVariables;\n }\n\n if (skip) {\n const {\n fetchPolicy = this.getDefaultFetchPolicy(),\n initialFetchPolicy = fetchPolicy,\n } = watchQueryOptions;\n\n // When skipping, we set watchQueryOptions.fetchPolicy initially to\n // \"standby\", but we also need/want to preserve the initial non-standby\n // fetchPolicy that would have been used if not skipping.\n Object.assign(watchQueryOptions, {\n initialFetchPolicy,\n fetchPolicy: 'standby',\n });\n } else if (!watchQueryOptions.fetchPolicy) {\n watchQueryOptions.fetchPolicy =\n this.observable?.options.initialFetchPolicy ||\n this.getDefaultFetchPolicy();\n }\n\n return watchQueryOptions;\n }\n\n getDefaultFetchPolicy(): WatchQueryFetchPolicy {\n return (\n this.queryHookOptions.defaultOptions?.fetchPolicy ||\n this.client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\"\n );\n }\n\n // Defining these methods as no-ops on the prototype allows us to call\n // state.onCompleted and/or state.onError without worrying about whether a\n // callback was provided.\n private onCompleted(data: TData) {}\n private onError(error: ApolloError) {}\n\n private observable: ObservableQuery<TData, TVariables>;\n private obsQueryFields: Omit<\n ObservableQueryFields<TData, TVariables>,\n \"variables\"\n >;\n\n private useObservableQuery() {\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 const obsQuery = this.observable =\n this.renderPromises\n && this.renderPromises.getSSRObservable(this.watchQueryOptions)\n || this.observable // Reuse this.observable if possible (and not SSR)\n || this.client.watchQuery(this.getObsQueryOptions());\n\n this.obsQueryFields = useMemo(() => ({\n refetch: obsQuery.refetch.bind(obsQuery),\n reobserve: obsQuery.reobserve.bind(obsQuery),\n fetchMore: obsQuery.fetchMore.bind(obsQuery),\n updateQuery: obsQuery.updateQuery.bind(obsQuery),\n startPolling: obsQuery.startPolling.bind(obsQuery),\n stopPolling: obsQuery.stopPolling.bind(obsQuery),\n subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),\n }), [obsQuery]);\n\n const ssrAllowed = !(\n this.queryHookOptions.ssr === false ||\n this.queryHookOptions.skip\n );\n\n if (this.renderPromises && ssrAllowed) {\n this.renderPromises.registerSSRObservable(obsQuery);\n\n if (obsQuery.getCurrentResult().loading) {\n // TODO: This is a legacy API which could probably be cleaned up\n this.renderPromises.addObservableQueryPromise(obsQuery);\n }\n }\n\n return obsQuery;\n }\n\n // These members are populated by getCurrentResult and setResult, and it's\n // okay/normal for them to be initially undefined.\n private result: undefined | ApolloQueryResult<TData>;\n private previousData: undefined | TData;\n\n private setResult(nextResult: ApolloQueryResult<TData>) {\n const previousResult = this.result;\n if (previousResult && previousResult.data) {\n this.previousData = previousResult.data;\n }\n this.result = nextResult;\n // Calling state.setResult always triggers an update, though some call sites\n // perform additional equality checks before committing to an update.\n this.forceUpdate();\n this.handleErrorOrCompleted(nextResult);\n }\n\n private handleErrorOrCompleted(result: ApolloQueryResult<TData>) {\n if (!result.loading) {\n // wait a tick in case we are in the middle of rendering a component\n Promise.resolve().then(() => {\n if (result.error) {\n this.onError(result.error);\n } else if (result.data) {\n this.onCompleted(result.data);\n }\n }).catch(error => {\n invariant.warn(error);\n });\n }\n }\n\n private getCurrentResult(): ApolloQueryResult<TData> {\n // Using this.result as a cache ensures getCurrentResult continues returning\n // the same (===) result object, unless state.setResult has been called, or\n // we're doing server rendering and therefore override the result below.\n if (!this.result) {\n this.handleErrorOrCompleted(\n this.result = this.observable.getCurrentResult()\n );\n }\n return this.result;\n }\n\n // This cache allows the referential stability of this.result (as returned by\n // getCurrentResult) to translate into referential stability of the resulting\n // QueryResult object returned by toQueryResult.\n private toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)<\n ApolloQueryResult<TData>,\n QueryResult<TData, TVariables>\n >();\n\n toQueryResult(\n result: ApolloQueryResult<TData>,\n ): QueryResult<TData, TVariables> {\n let queryResult = this.toQueryResultCache.get(result);\n if (queryResult) return queryResult;\n\n const { data, partial, ...resultWithoutPartial } = result;\n this.toQueryResultCache.set(result, queryResult = {\n data, // Ensure always defined, even if result.data is missing.\n ...resultWithoutPartial,\n ...this.obsQueryFields,\n client: this.client,\n observable: this.observable,\n variables: this.observable.variables,\n called: !this.queryHookOptions.skip,\n previousData: this.previousData,\n });\n\n if (!queryResult.error && isNonEmptyArray(result.errors)) {\n // Until a set naming convention for networkError and graphQLErrors is\n // decided upon, we map errors (graphQLErrors) to the error options.\n // TODO: Is it possible for both result.error and result.errors to be\n // defined here?\n queryResult.error = new ApolloError({ graphQLErrors: result.errors });\n }\n\n return queryResult;\n }\n\n private unsafeHandlePartialRefetch(result: ApolloQueryResult<TData>) {\n // WARNING: SIDE-EFFECTS IN THE RENDER FUNCTION\n //\n // TODO: This code should be removed when the partialRefetch option is\n // removed. I was unable to get this hook to behave reasonably in certain\n // edge cases when this block was put in an effect.\n if (\n result.partial &&\n this.queryHookOptions.partialRefetch &&\n !result.loading &&\n (!result.data || Object.keys(result.data).length === 0) &&\n this.observable.options.fetchPolicy !== 'cache-only'\n ) {\n Object.assign(result, {\n loading: true,\n networkStatus: NetworkStatus.refetch,\n });\n this.observable.refetch();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAA6C,MAAM,YAAY,CAAC;AACrF,OAAO,EAA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C;SAC3B;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AAjgBD,IAigBC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useSyncExternalStore } from './useSyncExternalStore';\nimport { equal } from '@wry/equality';\n\nimport { mergeOptions, OperationVariables, WatchQueryFetchPolicy } from '../../core';\nimport { ApolloContextValue, getApolloContext } from '../context';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloClient,\n ApolloQueryResult,\n NetworkStatus,\n ObservableQuery,\n DocumentNode,\n TypedDocumentNode,\n WatchQueryOptions,\n} from '../../core';\nimport {\n QueryHookOptions,\n QueryResult,\n ObservableQueryFields,\n} from '../types/types';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { useApolloClient } from './useApolloClient';\nimport { canUseWeakMap, canUseWeakSet, compact, isNonEmptyArray, maybeDeepFreeze } from '../../utilities';\n\nconst {\n prototype: {\n hasOwnProperty,\n },\n} = Object;\n\nexport function useQuery<\n TData = any,\n TVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<TData, TVariables> = Object.create(null),\n): QueryResult<TData, TVariables> {\n return useInternalState(\n useApolloClient(options.client),\n query,\n ).useQuery(options);\n}\n\nexport function useInternalState<TData, TVariables>(\n client: ApolloClient<any>,\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n): InternalState<TData, TVariables> {\n const stateRef = useRef<InternalState<TData, TVariables>>();\n if (\n !stateRef.current ||\n client !== stateRef.current.client ||\n query !== stateRef.current.query\n ) {\n stateRef.current = new InternalState(client, query, stateRef.current);\n }\n const state = stateRef.current;\n\n // By default, InternalState.prototype.forceUpdate is an empty function, but\n // we replace it here (before anyone has had a chance to see this state yet)\n // with a function that unconditionally forces an update, using the latest\n // setTick function. Updating this state by calling state.forceUpdate is the\n // only way we trigger React component updates (no other useState calls within\n // the InternalState class).\n const [_tick, setTick] = useState(0);\n state.forceUpdate = () => {\n setTick(tick => tick + 1);\n };\n\n return state;\n}\n\nclass InternalState<TData, TVariables> {\n constructor(\n public readonly client: ReturnType<typeof useApolloClient>,\n public readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n previous?: InternalState<TData, TVariables>,\n ) {\n verifyDocumentType(query, DocumentType.Query);\n\n // Reuse previousData from previous InternalState (if any) to provide\n // continuity of previousData even if/when the query or client changes.\n const previousResult = previous && previous.result;\n const previousData = previousResult && previousResult.data;\n if (previousData) {\n this.previousData = previousData;\n }\n }\n\n forceUpdate() {\n // Replaced (in useInternalState) with a method that triggers an update.\n invariant.warn(\"Calling default no-op implementation of InternalState#forceUpdate\");\n }\n\n asyncUpdate() {\n return new Promise<QueryResult<TData, TVariables>>(resolve => {\n this.asyncResolveFns.add(resolve);\n this.optionsToIgnoreOnce.add(this.watchQueryOptions);\n this.forceUpdate();\n });\n }\n\n private asyncResolveFns = new Set<\n (result: QueryResult<TData, TVariables>) => void\n >();\n\n private optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)<\n WatchQueryOptions<TVariables, TData>\n >();\n\n // Methods beginning with use- should be called according to the standard\n // rules of React hooks: only at the top level of the calling function, and\n // without any dynamic conditional logic.\n useQuery(options: QueryHookOptions<TData, TVariables>) {\n // The renderPromises field gets initialized here in the useQuery method, at\n // the beginning of everything (for a given component rendering, at least),\n // so we can safely use this.renderPromises in other/later InternalState\n // methods without worrying it might be uninitialized. Even after\n // initialization, this.renderPromises is usually undefined (unless SSR is\n // happening), but that's fine as long as it has been initialized that way,\n // rather than left uninitialized.\n this.renderPromises = useContext(getApolloContext()).renderPromises;\n\n this.useOptions(options);\n\n const obsQuery = this.useObservableQuery();\n\n const result = useSyncExternalStore(\n useCallback(() => {\n if (this.renderPromises) {\n return () => {};\n }\n\n const onNext = () => {\n const previousResult = this.result;\n // We use `getCurrentResult()` instead of the onNext argument because\n // the values differ slightly. Specifically, loading results will have\n // an empty object for data instead of `undefined` for some reason.\n const result = obsQuery.getCurrentResult();\n // Make sure we're not attempting to re-render similar results\n if (\n previousResult &&\n previousResult.loading === result.loading &&\n previousResult.networkStatus === result.networkStatus &&\n equal(previousResult.data, result.data)\n ) {\n return;\n }\n\n this.setResult(result);\n };\n\n const onError = (error: Error) => {\n const last = obsQuery[\"last\"];\n subscription.unsubscribe();\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 try {\n obsQuery.resetLastResults();\n subscription = obsQuery.subscribe(onNext, onError);\n } finally {\n obsQuery[\"last\"] = last;\n }\n\n if (!hasOwnProperty.call(error, 'graphQLErrors')) {\n // The error is not a GraphQL error\n throw error;\n }\n\n const previousResult = this.result;\n if (\n !previousResult ||\n (previousResult && previousResult.loading) ||\n !equal(error, previousResult.error)\n ) {\n this.setResult({\n data: (previousResult && previousResult.data) as TData,\n error: error as ApolloError,\n loading: false,\n networkStatus: NetworkStatus.error,\n });\n }\n };\n\n let subscription = obsQuery.subscribe(onNext, onError);\n\n return () => subscription.unsubscribe();\n }, [\n // We memoize the subscribe function using useCallback and the following\n // dependency keys, because the subscribe function reference is all that\n // useSyncExternalStore uses internally as a dependency key for the\n // useEffect ultimately responsible for the subscription, so we are\n // effectively passing this dependency array to that useEffect buried\n // inside useSyncExternalStore, as desired.\n obsQuery,\n this.renderPromises,\n this.client.disableNetworkFetches,\n ]),\n\n () => this.getCurrentResult(),\n () => this.getCurrentResult(),\n );\n\n // TODO Remove this method when we remove support for options.partialRefetch.\n this.unsafeHandlePartialRefetch(result);\n\n const queryResult = this.toQueryResult(result);\n\n if (!queryResult.loading && this.asyncResolveFns.size) {\n this.asyncResolveFns.forEach(resolve => resolve(queryResult));\n this.asyncResolveFns.clear();\n }\n\n return queryResult;\n }\n\n // These members (except for renderPromises) are all populated by the\n // useOptions method, which is called unconditionally at the beginning of the\n // useQuery method, so we can safely use these members in other/later methods\n // without worrying they might be uninitialized.\n private renderPromises: ApolloContextValue[\"renderPromises\"];\n private queryHookOptions: QueryHookOptions<TData, TVariables>;\n private watchQueryOptions: WatchQueryOptions<TVariables, TData>;\n\n private useOptions(\n options: QueryHookOptions<TData, TVariables>,\n ) {\n const watchQueryOptions = this.createWatchQueryOptions(\n this.queryHookOptions = options,\n );\n\n // Update this.watchQueryOptions, but only when they have changed, which\n // allows us to depend on the referential stability of\n // this.watchQueryOptions elsewhere.\n const currentWatchQueryOptions = this.watchQueryOptions;\n\n // To force this equality test to \"fail,\" thereby reliably triggering\n // observable.reobserve, add any current WatchQueryOptions object(s) you\n // want to be ignored to this.optionsToIgnoreOnce. A similar effect could be\n // achieved by nullifying this.watchQueryOptions so the equality test\n // immediately fails because currentWatchQueryOptions is null, but this way\n // we can promise a truthy this.watchQueryOptions at all times.\n if (\n this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||\n !equal(watchQueryOptions, currentWatchQueryOptions)\n ) {\n this.watchQueryOptions = watchQueryOptions;\n\n if (currentWatchQueryOptions && this.observable) {\n // As advertised in the -Once of this.optionsToIgnoreOnce, this trick is\n // only good for one forced execution of observable.reobserve per\n // ignored WatchQueryOptions object, though it is unlikely we will ever\n // see this exact currentWatchQueryOptions object again here, since we\n // just replaced this.watchQueryOptions with watchQueryOptions.\n this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);\n\n // Though it might be tempting to postpone this reobserve call to the\n // useEffect block, we need getCurrentResult to return an appropriate\n // loading:true result synchronously (later within the same call to\n // useQuery). Since we already have this.observable here (not true for\n // the very first call to useQuery), we are not initiating any new\n // subscriptions, though it does feel less than ideal that reobserve\n // (potentially) kicks off a network request (for example, when the\n // variables have changed), which is technically a side-effect.\n this.observable.reobserve(this.getObsQueryOptions());\n\n // Make sure getCurrentResult returns a fresh ApolloQueryResult<TData>,\n // but save the current data as this.previousData, just like setResult\n // usually does.\n this.previousData = this.result?.data || this.previousData;\n this.result = void 0;\n }\n }\n\n // Make sure state.onCompleted and state.onError always reflect the latest\n // options.onCompleted and options.onError callbacks provided to useQuery,\n // since those functions are often recreated every time useQuery is called.\n // Like the forceUpdate method, the versions of these methods inherited from\n // InternalState.prototype are empty no-ops, but we can override them on the\n // base state object (without modifying the prototype).\n this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;\n this.onError = options.onError || InternalState.prototype.onError;\n\n if (\n (this.renderPromises || this.client.disableNetworkFetches) &&\n this.queryHookOptions.ssr === false &&\n !this.queryHookOptions.skip\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 this.result = this.ssrDisabledResult;\n } else if (\n this.queryHookOptions.skip ||\n this.watchQueryOptions.fetchPolicy === 'standby'\n ) {\n // When skipping a query (ie. we're not querying for data but still want to\n // render children), make sure the `data` is cleared out and `loading` is\n // 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 that\n // previously received data is all of a sudden removed. Unfortunately,\n // changing this is breaking, so we'll have to wait until Apollo Client 4.0\n // to address this.\n this.result = this.skipStandbyResult;\n } else if (\n this.result === this.ssrDisabledResult ||\n this.result === this.skipStandbyResult\n ) {\n this.result = void 0;\n }\n }\n\n private getObsQueryOptions(): WatchQueryOptions<TVariables, TData> {\n const toMerge: Array<\n Partial<WatchQueryOptions<TVariables, TData>>\n > = [];\n\n const globalDefaults = this.client.defaultOptions.watchQuery;\n if (globalDefaults) toMerge.push(globalDefaults);\n\n if (this.queryHookOptions.defaultOptions) {\n toMerge.push(this.queryHookOptions.defaultOptions);\n }\n\n // We use compact rather than mergeOptions for this part of the merge,\n // because we want watchQueryOptions.variables (if defined) to replace\n // this.observable.options.variables whole. This replacement allows\n // removing variables by removing them from the variables input to\n // useQuery. If the variables were always merged together (rather than\n // replaced), there would be no way to remove existing variables.\n // However, the variables from options.defaultOptions and globalDefaults\n // (if provided) should be merged, to ensure individual defaulted\n // variables always have values, if not otherwise defined in\n // observable.options or watchQueryOptions.\n toMerge.push(compact(\n this.observable && this.observable.options,\n this.watchQueryOptions,\n ));\n\n return toMerge.reduce(\n mergeOptions\n ) as WatchQueryOptions<TVariables, TData>;\n }\n\n private ssrDisabledResult = maybeDeepFreeze({\n loading: true,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.loading,\n });\n\n private skipStandbyResult = maybeDeepFreeze({\n loading: false,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.ready,\n });\n\n // A function to massage options before passing them to ObservableQuery.\n private createWatchQueryOptions({\n skip,\n ssr,\n onCompleted,\n onError,\n defaultOptions,\n // The above options are useQuery-specific, so this ...otherOptions spread\n // makes otherOptions almost a WatchQueryOptions object, except for the\n // query property that we add below.\n ...otherOptions\n }: QueryHookOptions<TData, TVariables> = {}): WatchQueryOptions<TVariables, TData> {\n // This Object.assign is safe because otherOptions is a fresh ...rest object\n // that did not exist until just now, so modifications are still allowed.\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> =\n Object.assign(otherOptions, { query: this.query });\n\n if (\n this.renderPromises &&\n (\n watchQueryOptions.fetchPolicy === 'network-only' ||\n watchQueryOptions.fetchPolicy === 'cache-and-network'\n )\n ) {\n // this behavior was added to react-apollo without explanation in this PR\n // https://github.com/apollographql/react-apollo/pull/1579\n watchQueryOptions.fetchPolicy = 'cache-first';\n }\n\n if (!watchQueryOptions.variables) {\n watchQueryOptions.variables = {} as TVariables;\n }\n\n if (skip) {\n const {\n fetchPolicy = this.getDefaultFetchPolicy(),\n initialFetchPolicy = fetchPolicy,\n } = watchQueryOptions;\n\n // When skipping, we set watchQueryOptions.fetchPolicy initially to\n // \"standby\", but we also need/want to preserve the initial non-standby\n // fetchPolicy that would have been used if not skipping.\n Object.assign(watchQueryOptions, {\n initialFetchPolicy,\n fetchPolicy: 'standby',\n });\n } else if (!watchQueryOptions.fetchPolicy) {\n watchQueryOptions.fetchPolicy =\n this.observable?.options.initialFetchPolicy ||\n this.getDefaultFetchPolicy();\n }\n\n return watchQueryOptions;\n }\n\n getDefaultFetchPolicy(): WatchQueryFetchPolicy {\n return (\n this.queryHookOptions.defaultOptions?.fetchPolicy ||\n this.client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\"\n );\n }\n\n // Defining these methods as no-ops on the prototype allows us to call\n // state.onCompleted and/or state.onError without worrying about whether a\n // callback was provided.\n private onCompleted(data: TData) {}\n private onError(error: ApolloError) {}\n\n private observable: ObservableQuery<TData, TVariables>;\n private obsQueryFields: Omit<\n ObservableQueryFields<TData, TVariables>,\n \"variables\"\n >;\n\n private useObservableQuery() {\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 const obsQuery = this.observable =\n this.renderPromises\n && this.renderPromises.getSSRObservable(this.watchQueryOptions)\n || this.observable // Reuse this.observable if possible (and not SSR)\n || this.client.watchQuery(this.getObsQueryOptions());\n\n this.obsQueryFields = useMemo(() => ({\n refetch: obsQuery.refetch.bind(obsQuery),\n reobserve: obsQuery.reobserve.bind(obsQuery),\n fetchMore: obsQuery.fetchMore.bind(obsQuery),\n updateQuery: obsQuery.updateQuery.bind(obsQuery),\n startPolling: obsQuery.startPolling.bind(obsQuery),\n stopPolling: obsQuery.stopPolling.bind(obsQuery),\n subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),\n }), [obsQuery]);\n\n const ssrAllowed = !(\n this.queryHookOptions.ssr === false ||\n this.queryHookOptions.skip\n );\n\n if (this.renderPromises && ssrAllowed) {\n this.renderPromises.registerSSRObservable(obsQuery);\n\n if (obsQuery.getCurrentResult().loading) {\n // TODO: This is a legacy API which could probably be cleaned up\n this.renderPromises.addObservableQueryPromise(obsQuery);\n }\n }\n\n return obsQuery;\n }\n\n // These members are populated by getCurrentResult and setResult, and it's\n // okay/normal for them to be initially undefined.\n private result: undefined | ApolloQueryResult<TData>;\n private previousData: undefined | TData;\n\n private setResult(nextResult: ApolloQueryResult<TData>) {\n const previousResult = this.result;\n if (previousResult && previousResult.data) {\n this.previousData = previousResult.data;\n }\n this.result = nextResult;\n // Calling state.setResult always triggers an update, though some call sites\n // perform additional equality checks before committing to an update.\n this.forceUpdate();\n this.handleErrorOrCompleted(nextResult, previousResult);\n }\n\n private handleErrorOrCompleted(\n result: ApolloQueryResult<TData>,\n previousResult?: ApolloQueryResult<TData>\n ) {\n if (!result.loading) {\n // wait a tick in case we are in the middle of rendering a component\n Promise.resolve().then(() => {\n if (result.error) {\n this.onError(result.error);\n } else if (\n result.data &&\n previousResult?.networkStatus !== result.networkStatus &&\n result.networkStatus === NetworkStatus.ready\n ) {\n this.onCompleted(result.data);\n }\n }).catch(error => {\n invariant.warn(error);\n });\n }\n }\n\n private getCurrentResult(): ApolloQueryResult<TData> {\n // Using this.result as a cache ensures getCurrentResult continues returning\n // the same (===) result object, unless state.setResult has been called, or\n // we're doing server rendering and therefore override the result below.\n if (!this.result) {\n this.handleErrorOrCompleted(\n this.result = this.observable.getCurrentResult()\n );\n }\n return this.result;\n }\n\n // This cache allows the referential stability of this.result (as returned by\n // getCurrentResult) to translate into referential stability of the resulting\n // QueryResult object returned by toQueryResult.\n private toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)<\n ApolloQueryResult<TData>,\n QueryResult<TData, TVariables>\n >();\n\n toQueryResult(\n result: ApolloQueryResult<TData>,\n ): QueryResult<TData, TVariables> {\n let queryResult = this.toQueryResultCache.get(result);\n if (queryResult) return queryResult;\n\n const { data, partial, ...resultWithoutPartial } = result;\n this.toQueryResultCache.set(result, queryResult = {\n data, // Ensure always defined, even if result.data is missing.\n ...resultWithoutPartial,\n ...this.obsQueryFields,\n client: this.client,\n observable: this.observable,\n variables: this.observable.variables,\n called: !this.queryHookOptions.skip,\n previousData: this.previousData,\n });\n\n if (!queryResult.error && isNonEmptyArray(result.errors)) {\n // Until a set naming convention for networkError and graphQLErrors is\n // decided upon, we map errors (graphQLErrors) to the error options.\n // TODO: Is it possible for both result.error and result.errors to be\n // defined here?\n queryResult.error = new ApolloError({ graphQLErrors: result.errors });\n }\n\n return queryResult;\n }\n\n private unsafeHandlePartialRefetch(result: ApolloQueryResult<TData>) {\n // WARNING: SIDE-EFFECTS IN THE RENDER FUNCTION\n //\n // TODO: This code should be removed when the partialRefetch option is\n // removed. I was unable to get this hook to behave reasonably in certain\n // edge cases when this block was put in an effect.\n if (\n result.partial &&\n this.queryHookOptions.partialRefetch &&\n !result.loading &&\n (!result.data || Object.keys(result.data).length === 0) &&\n this.observable.options.fetchPolicy !== 'cache-only'\n ) {\n Object.assign(result, {\n loading: true,\n networkStatus: NetworkStatus.refetch,\n });\n this.observable.refetch();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseCache.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,+BAU/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { getApolloContext } from "../context/index.js";
|
|
3
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
4
|
+
export function useSuspenseCache() {
|
|
5
|
+
var suspenseCache = useContext(getApolloContext()).suspenseCache;
|
|
6
|
+
__DEV__ ? invariant(suspenseCache, 'Could not find a "suspenseCache" in the context. Wrap the root component ' +
|
|
7
|
+
'in an <ApolloProvider> and provide a suspenseCache.') : invariant(suspenseCache, 32);
|
|
8
|
+
return suspenseCache;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=useSuspenseCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseCache.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,UAAU,gBAAgB;IACtB,IAAA,aAAa,GAAK,UAAU,CAAC,gBAAgB,EAAE,CAAC,cAAnC,CAAoC;IAEzD,SAAS,CACP,aAAa,EACb,2EAA2E;QACzE,qDAAqD,CACxD,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { getApolloContext } from '../context';\nimport { invariant } from '../../utilities/globals';\n\nexport function useSuspenseCache() {\n const { suspenseCache } = useContext(getApolloContext());\n\n invariant(\n suspenseCache,\n 'Could not find a \"suspenseCache\" in the context. Wrap the root component ' +\n 'in an <ApolloProvider> and provide a suspenseCache.'\n );\n\n return suspenseCache;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApolloError, DocumentNode, OperationVariables, TypedDocumentNode } from '../../core';
|
|
2
|
+
import { SuspenseQueryHookOptions, ObservableQueryFields } from '../types/types';
|
|
3
|
+
export interface UseSuspenseQueryResult<TData = any, TVariables = OperationVariables> {
|
|
4
|
+
data: TData;
|
|
5
|
+
error: ApolloError | undefined;
|
|
6
|
+
fetchMore: ObservableQueryFields<TData, TVariables>['fetchMore'];
|
|
7
|
+
refetch: ObservableQueryFields<TData, TVariables>['refetch'];
|
|
8
|
+
}
|
|
9
|
+
export declare function useSuspenseQuery_experimental<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SuspenseQueryHookOptions<TData, TVariables>): UseSuspenseQueryResult<TData, TVariables>;
|
|
10
|
+
//# sourceMappingURL=useSuspenseQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,WAAW,EAEX,YAAY,EAEZ,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,sBAAsB,CACrC,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB;IAE/B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACjE,OAAO,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAC9D;AAaD,wBAAgB,6BAA6B,CAC3C,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAE1D,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,GAAE,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAuB,GACzE,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,CAkG3C"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import { useRef, useEffect, useCallback, useMemo, useState, useLayoutEffect, } from 'react';
|
|
3
|
+
import { equal } from '@wry/equality';
|
|
4
|
+
import { ApolloError, } from "../../core/index.js";
|
|
5
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
6
|
+
import { compact, isNonEmptyArray } from "../../utilities/index.js";
|
|
7
|
+
import { useApolloClient } from "./useApolloClient.js";
|
|
8
|
+
import { DocumentType, verifyDocumentType } from "../parser/index.js";
|
|
9
|
+
import { useDeepMemo } from "./internal/index.js";
|
|
10
|
+
import { useSuspenseCache } from "./useSuspenseCache.js";
|
|
11
|
+
import { useSyncExternalStore } from "./useSyncExternalStore.js";
|
|
12
|
+
var SUPPORTED_FETCH_POLICIES = [
|
|
13
|
+
'cache-first',
|
|
14
|
+
'network-only',
|
|
15
|
+
'no-cache',
|
|
16
|
+
'cache-and-network',
|
|
17
|
+
];
|
|
18
|
+
var DEFAULT_FETCH_POLICY = 'cache-first';
|
|
19
|
+
var DEFAULT_SUSPENSE_POLICY = 'always';
|
|
20
|
+
var DEFAULT_ERROR_POLICY = 'none';
|
|
21
|
+
export function useSuspenseQuery_experimental(query, options) {
|
|
22
|
+
if (options === void 0) { options = Object.create(null); }
|
|
23
|
+
var suspenseCache = useSuspenseCache();
|
|
24
|
+
var client = useApolloClient(options.client);
|
|
25
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options, client: client });
|
|
26
|
+
var previousWatchQueryOptionsRef = useRef(watchQueryOptions);
|
|
27
|
+
var fetchPolicy = watchQueryOptions.fetchPolicy, errorPolicy = watchQueryOptions.errorPolicy, returnPartialData = watchQueryOptions.returnPartialData, variables = watchQueryOptions.variables;
|
|
28
|
+
var cacheEntry = suspenseCache.lookup(query, variables);
|
|
29
|
+
var observable = useState(function () {
|
|
30
|
+
return (cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.observable) || client.watchQuery(watchQueryOptions);
|
|
31
|
+
})[0];
|
|
32
|
+
var result = useObservableQueryResult(observable);
|
|
33
|
+
if (result.error && errorPolicy === 'none') {
|
|
34
|
+
throw result.error;
|
|
35
|
+
}
|
|
36
|
+
if (result.loading) {
|
|
37
|
+
if (!cacheEntry) {
|
|
38
|
+
cacheEntry = suspenseCache.add(query, variables, {
|
|
39
|
+
promise: observable.reobserve(watchQueryOptions),
|
|
40
|
+
observable: observable,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
var hasFullResult = result.data && !result.partial;
|
|
44
|
+
var usePartialResult = returnPartialData && result.partial && result.data;
|
|
45
|
+
var hasUsableResult = usePartialResult ||
|
|
46
|
+
(fetchPolicy === 'cache-and-network' && hasFullResult);
|
|
47
|
+
if (!hasUsableResult && !cacheEntry.fulfilled) {
|
|
48
|
+
throw cacheEntry.promise;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
var variables = watchQueryOptions.variables, query = watchQueryOptions.query;
|
|
53
|
+
var previousOpts = previousWatchQueryOptionsRef.current;
|
|
54
|
+
if (variables !== previousOpts.variables || query !== previousOpts.query) {
|
|
55
|
+
suspenseCache.remove(previousOpts.query, previousOpts.variables);
|
|
56
|
+
suspenseCache.add(query, variables, {
|
|
57
|
+
promise: observable.reobserve({ query: query, variables: variables }),
|
|
58
|
+
observable: observable,
|
|
59
|
+
});
|
|
60
|
+
previousWatchQueryOptionsRef.current = watchQueryOptions;
|
|
61
|
+
}
|
|
62
|
+
}, [watchQueryOptions]);
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
return function () {
|
|
65
|
+
suspenseCache.remove(query, variables);
|
|
66
|
+
};
|
|
67
|
+
}, []);
|
|
68
|
+
return useMemo(function () {
|
|
69
|
+
return {
|
|
70
|
+
data: result.data,
|
|
71
|
+
error: errorPolicy === 'all' ? toApolloError(result) : void 0,
|
|
72
|
+
fetchMore: function (options) {
|
|
73
|
+
var promise = observable.fetchMore(options);
|
|
74
|
+
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
75
|
+
promise: promise,
|
|
76
|
+
observable: observable,
|
|
77
|
+
});
|
|
78
|
+
return promise;
|
|
79
|
+
},
|
|
80
|
+
refetch: function (variables) {
|
|
81
|
+
var promise = observable.refetch(variables);
|
|
82
|
+
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
83
|
+
promise: promise,
|
|
84
|
+
observable: observable,
|
|
85
|
+
});
|
|
86
|
+
return promise;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}, [result, observable, errorPolicy]);
|
|
90
|
+
}
|
|
91
|
+
function validateOptions(options) {
|
|
92
|
+
var query = options.query, _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? DEFAULT_FETCH_POLICY : _a, returnPartialData = options.returnPartialData;
|
|
93
|
+
verifyDocumentType(query, DocumentType.Query);
|
|
94
|
+
validateFetchPolicy(fetchPolicy);
|
|
95
|
+
validatePartialDataReturn(fetchPolicy, returnPartialData);
|
|
96
|
+
}
|
|
97
|
+
function validateFetchPolicy(fetchPolicy) {
|
|
98
|
+
__DEV__ ? invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), 33);
|
|
99
|
+
}
|
|
100
|
+
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
101
|
+
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
102
|
+
__DEV__ && invariant.warn('Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function toApolloError(result) {
|
|
106
|
+
return isNonEmptyArray(result.errors)
|
|
107
|
+
? new ApolloError({ graphQLErrors: result.errors })
|
|
108
|
+
: result.error;
|
|
109
|
+
}
|
|
110
|
+
function useWatchQueryOptions(_a) {
|
|
111
|
+
var query = _a.query, options = _a.options, client = _a.client;
|
|
112
|
+
var defaultOptions = client.defaultOptions.watchQuery;
|
|
113
|
+
var watchQueryOptions = useDeepMemo(function () {
|
|
114
|
+
var errorPolicy = options.errorPolicy, fetchPolicy = options.fetchPolicy, _a = options.suspensePolicy, suspensePolicy = _a === void 0 ? DEFAULT_SUSPENSE_POLICY : _a, variables = options.variables, watchQueryOptions = __rest(options, ["errorPolicy", "fetchPolicy", "suspensePolicy", "variables"]);
|
|
115
|
+
return __assign(__assign({}, watchQueryOptions), { query: query, errorPolicy: errorPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.errorPolicy) || DEFAULT_ERROR_POLICY, fetchPolicy: fetchPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.fetchPolicy) || DEFAULT_FETCH_POLICY, notifyOnNetworkStatusChange: suspensePolicy === 'always', fetchOnFirstSubscribe: false, variables: compact(__assign(__assign({}, defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.variables), variables)) });
|
|
116
|
+
}, [options, query, defaultOptions]);
|
|
117
|
+
if (__DEV__) {
|
|
118
|
+
validateOptions(watchQueryOptions);
|
|
119
|
+
}
|
|
120
|
+
return watchQueryOptions;
|
|
121
|
+
}
|
|
122
|
+
function useObservableQueryResult(observable) {
|
|
123
|
+
var resultRef = useRef();
|
|
124
|
+
var isMountedRef = useRef(false);
|
|
125
|
+
if (!resultRef.current) {
|
|
126
|
+
resultRef.current = observable.getCurrentResult();
|
|
127
|
+
}
|
|
128
|
+
useLayoutEffect(function () {
|
|
129
|
+
isMountedRef.current = true;
|
|
130
|
+
return function () {
|
|
131
|
+
isMountedRef.current = false;
|
|
132
|
+
};
|
|
133
|
+
}, []);
|
|
134
|
+
return useSyncExternalStore(useCallback(function (forceUpdate) {
|
|
135
|
+
function handleUpdate() {
|
|
136
|
+
var previousResult = resultRef.current;
|
|
137
|
+
var result = observable.getCurrentResult();
|
|
138
|
+
if (previousResult.loading === result.loading &&
|
|
139
|
+
previousResult.networkStatus === result.networkStatus &&
|
|
140
|
+
equal(previousResult.data, result.data)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
resultRef.current = result;
|
|
144
|
+
if (isMountedRef.current) {
|
|
145
|
+
forceUpdate();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
var subscription = observable.subscribe({
|
|
149
|
+
next: handleUpdate,
|
|
150
|
+
error: handleUpdate,
|
|
151
|
+
});
|
|
152
|
+
return function () {
|
|
153
|
+
subscription.unsubscribe();
|
|
154
|
+
};
|
|
155
|
+
}, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=useSuspenseQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AC/B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,oBAAoB,CACzB,WAAW,CACT,UAAC,WAAW;QACV,SAAS,YAAY;YACnB,IAAM,cAAc,GAAG,SAAS,CAAC,OAAQ,CAAC;YAC1C,IAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;YAE7C,IACE,cAAc,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;gBACzC,cAAc,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa;gBACrD,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EACvC;gBACA,OAAO;aACR;YAED,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;YAE3B,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,WAAW,EAAE,CAAC;aACf;QACH,CAAC;QAED,IAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC;YACxC,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QAEH,OAAO;YACL,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,UAAU,CAAC,CACb,EACD,cAAM,OAAA,SAAS,CAAC,OAAQ,EAAlB,CAAkB,EACxB,cAAM,OAAA,SAAS,CAAC,OAAQ,EAAlB,CAAkB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import {\n useRef,\n useEffect,\n useCallback,\n useMemo,\n useState,\n useLayoutEffect,\n} from 'react';\nimport { equal } from '@wry/equality';\nimport {\n ApolloClient,\n ApolloError,\n ApolloQueryResult,\n DocumentNode,\n ObservableQuery,\n OperationVariables,\n TypedDocumentNode,\n WatchQueryOptions,\n WatchQueryFetchPolicy,\n} from '../../core';\nimport { invariant } from '../../utilities/globals';\nimport { compact, isNonEmptyArray } from '../../utilities';\nimport { useApolloClient } from './useApolloClient';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { useDeepMemo } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport { useSyncExternalStore } from './useSyncExternalStore';\n\nexport interface UseSuspenseQueryResult<\n TData = any,\n TVariables = OperationVariables\n> {\n data: TData;\n error: ApolloError | undefined;\n fetchMore: ObservableQueryFields<TData, TVariables>['fetchMore'];\n refetch: ObservableQueryFields<TData, TVariables>['refetch'];\n}\n\nconst SUPPORTED_FETCH_POLICIES: WatchQueryFetchPolicy[] = [\n 'cache-first',\n 'network-only',\n 'no-cache',\n 'cache-and-network',\n];\n\nconst DEFAULT_FETCH_POLICY = 'cache-first';\nconst DEFAULT_SUSPENSE_POLICY = 'always';\nconst DEFAULT_ERROR_POLICY = 'none';\n\nexport function useSuspenseQuery_experimental<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<TData, TVariables> = Object.create(null)\n): UseSuspenseQueryResult<TData, TVariables> {\n const suspenseCache = useSuspenseCache();\n const client = useApolloClient(options.client);\n const watchQueryOptions = useWatchQueryOptions({ query, options, client });\n const previousWatchQueryOptionsRef = useRef(watchQueryOptions);\n\n const { fetchPolicy, errorPolicy, returnPartialData, variables } =\n watchQueryOptions;\n\n let cacheEntry = suspenseCache.lookup(query, variables);\n\n const [observable] = useState(() => {\n return cacheEntry?.observable || client.watchQuery(watchQueryOptions);\n });\n\n const result = useObservableQueryResult(observable);\n\n if (result.error && errorPolicy === 'none') {\n throw result.error;\n }\n\n if (result.loading) {\n // If we don't have a cache entry, but we are in a loading state, we are on\n // the first run of the hook. Kick off a network request so we can suspend\n // immediately\n if (!cacheEntry) {\n cacheEntry = suspenseCache.add(query, variables, {\n promise: observable.reobserve(watchQueryOptions),\n observable,\n });\n }\n\n const hasFullResult = result.data && !result.partial;\n const usePartialResult = returnPartialData && result.partial && result.data;\n\n const hasUsableResult =\n // When we have partial data in the cache, a network request will be kicked\n // off to load the full set of data. Avoid suspending when the request is\n // in flight to return the partial data immediately.\n usePartialResult ||\n // `cache-and-network` kicks off a network request even with a full set of\n // data in the cache, which means the loading state will be set to `true`.\n // Avoid suspending in this case.\n (fetchPolicy === 'cache-and-network' && hasFullResult);\n\n if (!hasUsableResult && !cacheEntry.fulfilled) {\n throw cacheEntry.promise;\n }\n }\n\n useEffect(() => {\n const { variables, query } = watchQueryOptions;\n const previousOpts = previousWatchQueryOptionsRef.current;\n\n if (variables !== previousOpts.variables || query !== previousOpts.query) {\n suspenseCache.remove(previousOpts.query, previousOpts.variables);\n\n suspenseCache.add(query, variables, {\n promise: observable.reobserve({ query, variables }),\n observable,\n });\n\n previousWatchQueryOptionsRef.current = watchQueryOptions;\n }\n }, [watchQueryOptions]);\n\n useEffect(() => {\n return () => {\n suspenseCache.remove(query, variables);\n };\n }, []);\n\n return useMemo(() => {\n return {\n data: result.data,\n error: errorPolicy === 'all' ? toApolloError(result) : void 0,\n fetchMore: (options) => {\n const promise = observable.fetchMore(options);\n\n suspenseCache.add(query, watchQueryOptions.variables, {\n promise,\n observable,\n });\n\n return promise;\n },\n refetch: (variables?: Partial<TVariables>) => {\n const promise = observable.refetch(variables);\n\n suspenseCache.add(query, watchQueryOptions.variables, {\n promise,\n observable,\n });\n\n return promise;\n },\n };\n }, [result, observable, errorPolicy]);\n}\n\nfunction validateOptions(options: WatchQueryOptions) {\n const {\n query,\n fetchPolicy = DEFAULT_FETCH_POLICY,\n returnPartialData,\n } = options;\n\n verifyDocumentType(query, DocumentType.Query);\n validateFetchPolicy(fetchPolicy);\n validatePartialDataReturn(fetchPolicy, returnPartialData);\n}\n\nfunction validateFetchPolicy(fetchPolicy: WatchQueryFetchPolicy) {\n invariant(\n SUPPORTED_FETCH_POLICIES.includes(fetchPolicy),\n `The fetch policy \\`${fetchPolicy}\\` is not supported with suspense.`\n );\n}\n\nfunction validatePartialDataReturn(\n fetchPolicy: WatchQueryFetchPolicy,\n returnPartialData: boolean | undefined\n) {\n if (fetchPolicy === 'no-cache' && returnPartialData) {\n invariant.warn(\n 'Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.'\n );\n }\n}\n\nfunction toApolloError(result: ApolloQueryResult<any>) {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error;\n}\n\ninterface UseWatchQueryOptionsHookOptions<TData, TVariables> {\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SuspenseQueryHookOptions<TData, TVariables>;\n client: ApolloClient<any>;\n}\n\nfunction useWatchQueryOptions<TData, TVariables>({\n query,\n options,\n client,\n}: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<\n TVariables,\n TData\n> {\n const { watchQuery: defaultOptions } = client.defaultOptions;\n\n const watchQueryOptions = useDeepMemo<\n WatchQueryOptions<TVariables, TData>\n >(() => {\n const {\n errorPolicy,\n fetchPolicy,\n suspensePolicy = DEFAULT_SUSPENSE_POLICY,\n variables,\n ...watchQueryOptions\n } = options;\n\n return {\n ...watchQueryOptions,\n query,\n errorPolicy:\n errorPolicy || defaultOptions?.errorPolicy || DEFAULT_ERROR_POLICY,\n fetchPolicy:\n fetchPolicy || defaultOptions?.fetchPolicy || DEFAULT_FETCH_POLICY,\n notifyOnNetworkStatusChange: suspensePolicy === 'always',\n // By default, `ObservableQuery` will run `reobserve` the first time\n // something `subscribe`s to the observable, which kicks off a network\n // request. This creates a problem for suspense because we need to begin\n // fetching the data immediately so we can throw the promise on the first\n // render. Since we don't subscribe until after we've unsuspended, we need\n // to avoid kicking off another network request for the same data we just\n // fetched. This option toggles that behavior off to avoid the `reobserve`\n // when the observable is first subscribed to.\n fetchOnFirstSubscribe: false,\n variables: compact({ ...defaultOptions?.variables, ...variables }),\n };\n }, [options, query, defaultOptions]);\n\n if (__DEV__) {\n validateOptions(watchQueryOptions);\n }\n\n return watchQueryOptions;\n}\n\nfunction useObservableQueryResult<TData>(observable: ObservableQuery<TData>) {\n const resultRef = useRef<ApolloQueryResult<TData>>();\n const isMountedRef = useRef(false);\n\n if (!resultRef.current) {\n resultRef.current = observable.getCurrentResult();\n }\n\n // React keeps refs and effects from useSyncExternalStore around after the\n // component initially mounts even if the component re-suspends. We need to\n // track when the component suspends/unsuspends to ensure we don't try and\n // update the component while its suspended since the observable's\n // `next` function is called before the promise resolved.\n //\n // Unlike useEffect, useLayoutEffect will run its cleanup and initialization\n // functions each time a component is suspended.\n useLayoutEffect(() => {\n isMountedRef.current = true;\n\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n return useSyncExternalStore(\n useCallback(\n (forceUpdate) => {\n function handleUpdate() {\n const previousResult = resultRef.current!;\n const result = observable.getCurrentResult();\n\n if (\n previousResult.loading === result.loading &&\n previousResult.networkStatus === result.networkStatus &&\n equal(previousResult.data, result.data)\n ) {\n return;\n }\n\n resultRef.current = result;\n\n if (isMountedRef.current) {\n forceUpdate();\n }\n }\n\n const subscription = observable.subscribe({\n next: handleUpdate,\n error: handleUpdate,\n });\n\n return () => {\n subscription.unsubscribe();\n };\n },\n [observable]\n ),\n () => resultRef.current!,\n () => resultRef.current!\n );\n}\n"]}
|
package/react/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '../utilities/globals';
|
|
2
2
|
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext, ApolloContextValue } from './context';
|
|
3
3
|
export * from './hooks';
|
|
4
|
+
export * from './cache';
|
|
4
5
|
export { DocumentType, IDocumentDefinition, operationName, parser } from './parser';
|
|
5
6
|
export * from './types/types';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/react/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,WAAW,CAAC;AAEnB,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,WAAW,CAAC;AAEnB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,cAAc,eAAe,CAAC"}
|
package/react/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../utilities/globals/index.js";
|
|
2
2
|
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext } from "./context/index.js";
|
|
3
3
|
export * from "./hooks/index.js";
|
|
4
|
+
export * from "./cache/index.js";
|
|
4
5
|
export { DocumentType, operationName, parser } from "./parser/index.js";
|
|
5
6
|
export * from "./types/types.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,WAAW,CAAC;AAEnB,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,cAAc,eAAe,CAAC","sourcesContent":["import '../utilities/globals';\n\nexport {\n ApolloProvider,\n ApolloConsumer,\n getApolloContext,\n resetApolloContext,\n ApolloContextValue\n} from './context';\n\nexport * from './hooks';\n\nexport {\n DocumentType,\n IDocumentDefinition,\n operationName,\n parser\n} from './parser';\n\nexport * from './types/types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,WAAW,CAAC;AAEnB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,cAAc,eAAe,CAAC","sourcesContent":["import '../utilities/globals';\n\nexport {\n ApolloProvider,\n ApolloConsumer,\n getApolloContext,\n resetApolloContext,\n ApolloContextValue\n} from './context';\n\nexport * from './hooks';\nexport * from './cache';\n\nexport {\n DocumentType,\n IDocumentDefinition,\n operationName,\n parser\n} from './parser';\n\nexport * from './types/types';\n"]}
|
package/react/parser/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export function parser(document) {
|
|
|
28
28
|
var variables, type, name;
|
|
29
29
|
__DEV__ ? invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
30
30
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
31
|
-
"to convert your operation into a document") : invariant(!!document && !!document.kind,
|
|
31
|
+
"to convert your operation into a document") : invariant(!!document && !!document.kind, 34);
|
|
32
32
|
var fragments = [];
|
|
33
33
|
var queries = [];
|
|
34
34
|
var mutations = [];
|
|
@@ -56,11 +56,11 @@ export function parser(document) {
|
|
|
56
56
|
__DEV__ ? invariant(!fragments.length ||
|
|
57
57
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
58
58
|
"You must include a query, subscription or mutation as well") : invariant(!fragments.length ||
|
|
59
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
59
|
+
(queries.length || mutations.length || subscriptions.length), 35);
|
|
60
60
|
__DEV__ ? invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
61
61
|
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
62
62
|
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
63
|
-
"You can use 'compose' to join multiple operation types to a component") : invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
63
|
+
"You can use 'compose' to join multiple operation types to a component") : invariant(queries.length + mutations.length + subscriptions.length <= 1, 36);
|
|
64
64
|
type = queries.length ? DocumentType.Query : DocumentType.Mutation;
|
|
65
65
|
if (!queries.length && !mutations.length)
|
|
66
66
|
type = DocumentType.Subscription;
|
|
@@ -71,7 +71,7 @@ export function parser(document) {
|
|
|
71
71
|
: subscriptions;
|
|
72
72
|
__DEV__ ? invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
73
73
|
"".concat(definitions.length, " definitions. ") +
|
|
74
|
-
"You can use 'compose' to join multiple operation types to a component") : invariant(definitions.length === 1,
|
|
74
|
+
"You can use 'compose' to join multiple operation types to a component") : invariant(definitions.length === 1, 37);
|
|
75
75
|
var definition = definitions[0];
|
|
76
76
|
variables = definition.variableDefinitions || [];
|
|
77
77
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -89,6 +89,6 @@ export function verifyDocumentType(document, type) {
|
|
|
89
89
|
var requiredOperationName = operationName(type);
|
|
90
90
|
var usedOperationName = operationName(operation.type);
|
|
91
91
|
__DEV__ ? invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
92
|
-
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : invariant(operation.type === type,
|
|
92
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : invariant(operation.type === type, 38);
|
|
93
93
|
}
|
|
94
94
|
//# sourceMappingURL=index.js.map
|
package/react/parser/parser.cjs
CHANGED
|
@@ -33,7 +33,7 @@ function parser(document) {
|
|
|
33
33
|
var variables, type, name;
|
|
34
34
|
__DEV__ ? globals.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
35
35
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
36
|
-
"to convert your operation into a document") : globals.invariant(!!document && !!document.kind,
|
|
36
|
+
"to convert your operation into a document") : globals.invariant(!!document && !!document.kind, 34);
|
|
37
37
|
var fragments = [];
|
|
38
38
|
var queries = [];
|
|
39
39
|
var mutations = [];
|
|
@@ -61,11 +61,11 @@ function parser(document) {
|
|
|
61
61
|
__DEV__ ? globals.invariant(!fragments.length ||
|
|
62
62
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
63
63
|
"You must include a query, subscription or mutation as well") : globals.invariant(!fragments.length ||
|
|
64
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
64
|
+
(queries.length || mutations.length || subscriptions.length), 35);
|
|
65
65
|
__DEV__ ? globals.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
66
66
|
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
67
67
|
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
68
|
-
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(queries.length + mutations.length + subscriptions.length <= 1,
|
|
68
|
+
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(queries.length + mutations.length + subscriptions.length <= 1, 36);
|
|
69
69
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
70
70
|
if (!queries.length && !mutations.length)
|
|
71
71
|
type = exports.DocumentType.Subscription;
|
|
@@ -76,7 +76,7 @@ function parser(document) {
|
|
|
76
76
|
: subscriptions;
|
|
77
77
|
__DEV__ ? globals.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
78
78
|
"".concat(definitions.length, " definitions. ") +
|
|
79
|
-
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(definitions.length === 1,
|
|
79
|
+
"You can use 'compose' to join multiple operation types to a component") : globals.invariant(definitions.length === 1, 37);
|
|
80
80
|
var definition = definitions[0];
|
|
81
81
|
variables = definition.variableDefinitions || [];
|
|
82
82
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -94,7 +94,7 @@ function verifyDocumentType(document, type) {
|
|
|
94
94
|
var requiredOperationName = operationName(type);
|
|
95
95
|
var usedOperationName = operationName(operation.type);
|
|
96
96
|
__DEV__ ? globals.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
97
|
-
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : globals.invariant(operation.type === type,
|
|
97
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : globals.invariant(operation.type === type, 38);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
exports.operationName = operationName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n __DEV__ ? invariant(!!document && !!document.kind, \"Argument of \".concat(document, \" passed to parser was not a valid GraphQL \") +\n \"DocumentNode. You may need to use 'graphql-tag' or another method \" +\n \"to convert your operation into a document\") : invariant(!!document && !!document.kind,
|
|
1
|
+
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n __DEV__ ? invariant(!!document && !!document.kind, \"Argument of \".concat(document, \" passed to parser was not a valid GraphQL \") +\n \"DocumentNode. You may need to use 'graphql-tag' or another method \" +\n \"to convert your operation into a document\") : invariant(!!document && !!document.kind, 34);\n var fragments = [];\n var queries = [];\n var mutations = [];\n var subscriptions = [];\n for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {\n var x = _a[_i];\n if (x.kind === 'FragmentDefinition') {\n fragments.push(x);\n continue;\n }\n if (x.kind === 'OperationDefinition') {\n switch (x.operation) {\n case 'query':\n queries.push(x);\n break;\n case 'mutation':\n mutations.push(x);\n break;\n case 'subscription':\n subscriptions.push(x);\n break;\n }\n }\n }\n __DEV__ ? invariant(!fragments.length ||\n (queries.length || mutations.length || subscriptions.length), \"Passing only a fragment to 'graphql' is not yet supported. \" +\n \"You must include a query, subscription or mutation as well\") : invariant(!fragments.length ||\n (queries.length || mutations.length || subscriptions.length), 35);\n __DEV__ ? invariant(queries.length + mutations.length + subscriptions.length <= 1, \"react-apollo only supports a query, subscription, or a mutation per HOC. \" +\n \"\".concat(document, \" had \").concat(queries.length, \" queries, \").concat(subscriptions.length, \" \") +\n \"subscriptions and \".concat(mutations.length, \" mutations. \") +\n \"You can use 'compose' to join multiple operation types to a component\") : invariant(queries.length + mutations.length + subscriptions.length <= 1, 36);\n type = queries.length ? DocumentType.Query : DocumentType.Mutation;\n if (!queries.length && !mutations.length)\n type = DocumentType.Subscription;\n var definitions = queries.length\n ? queries\n : mutations.length\n ? mutations\n : subscriptions;\n __DEV__ ? invariant(definitions.length === 1, \"react-apollo only supports one definition per HOC. \".concat(document, \" had \") +\n \"\".concat(definitions.length, \" definitions. \") +\n \"You can use 'compose' to join multiple operation types to a component\") : invariant(definitions.length === 1, 37);\n var definition = definitions[0];\n variables = definition.variableDefinitions || [];\n if (definition.name && definition.name.kind === 'Name') {\n name = definition.name.value;\n }\n else {\n name = 'data';\n }\n var payload = { name: name, type: type, variables: variables };\n cache.set(document, payload);\n return payload;\n}\nexport function verifyDocumentType(document, type) {\n var operation = parser(document);\n var requiredOperationName = operationName(type);\n var usedOperationName = operationName(operation.type);\n __DEV__ ? invariant(operation.type === type, \"Running a \".concat(requiredOperationName, \" requires a graphql \") +\n \"\".concat(requiredOperationName, \", but a \").concat(usedOperationName, \" was used instead.\")) : invariant(operation.type === type, 38);\n}\n//# sourceMappingURL=index.js.map"],"names":["DocumentType","invariant"],"mappings":";;;;;;AACWA,8BAAa;AACxB,CAAC,UAAU,YAAY,EAAE;AACzB,IAAI,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;AACtD,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,YAAY,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC;AACpE,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAA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