@apollo/client 3.8.0-alpha.7 → 3.8.0-alpha.9

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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/apollo-client.cjs +219 -183
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs +34 -24
  6. package/cache/cache.cjs.map +1 -1
  7. package/cache/cache.cjs.native.js +34 -24
  8. package/cache/core/types/DataProxy.d.ts +3 -2
  9. package/cache/core/types/DataProxy.d.ts.map +1 -1
  10. package/cache/core/types/DataProxy.js.map +1 -1
  11. package/cache/inmemory/helpers.d.ts +2 -2
  12. package/cache/inmemory/helpers.d.ts.map +1 -1
  13. package/cache/inmemory/helpers.js +2 -2
  14. package/cache/inmemory/helpers.js.map +1 -1
  15. package/cache/inmemory/policies.d.ts.map +1 -1
  16. package/cache/inmemory/policies.js +14 -3
  17. package/cache/inmemory/policies.js.map +1 -1
  18. package/core/ApolloClient.d.ts +3 -3
  19. package/core/ApolloClient.d.ts.map +1 -1
  20. package/core/ApolloClient.js +10 -4
  21. package/core/ApolloClient.js.map +1 -1
  22. package/core/core.cjs +11 -5
  23. package/core/core.cjs.map +1 -1
  24. package/core/core.cjs.native.js +11 -5
  25. package/invariantErrorCodes.js +4 -3
  26. package/link/core/types.d.ts +3 -4
  27. package/link/core/types.d.ts.map +1 -1
  28. package/link/core/types.js.map +1 -1
  29. package/package.json +16 -17
  30. package/react/hooks/hooks.cjs +19 -11
  31. package/react/hooks/hooks.cjs.map +1 -1
  32. package/react/hooks/hooks.cjs.native.js +19 -11
  33. package/react/hooks/useMutation.d.ts.map +1 -1
  34. package/react/hooks/useMutation.js +2 -1
  35. package/react/hooks/useMutation.js.map +1 -1
  36. package/react/hooks/useQuery.d.ts.map +1 -1
  37. package/react/hooks/useQuery.js +1 -1
  38. package/react/hooks/useQuery.js.map +1 -1
  39. package/react/hooks/useSuspenseCache.d.ts +2 -1
  40. package/react/hooks/useSuspenseCache.d.ts.map +1 -1
  41. package/react/hooks/useSuspenseCache.js +6 -4
  42. package/react/hooks/useSuspenseCache.js.map +1 -1
  43. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  44. package/react/hooks/useSuspenseQuery.js +10 -5
  45. package/react/hooks/useSuspenseQuery.js.map +1 -1
  46. package/react/types/types.d.ts +2 -0
  47. package/react/types/types.d.ts.map +1 -1
  48. package/react/types/types.js.map +1 -1
  49. package/testing/core/itAsync.js.map +1 -1
  50. package/utilities/common/arrays.d.ts +1 -0
  51. package/utilities/common/arrays.d.ts.map +1 -1
  52. package/utilities/common/arrays.js +1 -0
  53. package/utilities/common/arrays.js.map +1 -1
  54. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  55. package/utilities/graphql/getFromAST.js +7 -3
  56. package/utilities/graphql/getFromAST.js.map +1 -1
  57. package/utilities/graphql/transform.d.ts.map +1 -1
  58. package/utilities/graphql/transform.js +167 -90
  59. package/utilities/graphql/transform.js.map +1 -1
  60. package/utilities/observables/Concast.d.ts.map +1 -1
  61. package/utilities/observables/Concast.js +2 -2
  62. package/utilities/observables/Concast.js.map +1 -1
  63. package/utilities/utilities.cjs +177 -105
  64. package/utilities/utilities.cjs.map +1 -1
  65. package/utilities/utilities.cjs.native.js +177 -105
  66. package/version.js +1 -1
@@ -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;AAC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W,CAAC,KAAK,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YAKxD,WAAW,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SACvE;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,kDAA0B,GAAlC,UAAmC,MAAgC;QAMjE,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,AAnhBD,IAmhBC","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 NoInfer,\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 extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<NoInfer<TData>, NoInfer<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 extends OperationVariables>(\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 extends OperationVariables> {\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(signal: AbortSignal) {\n return new Promise<QueryResult<TData, TVariables>>((resolve, reject) => {\n const watchQueryOptions = this.watchQueryOptions;\n\n const handleAborted = () => {\n this.asyncResolveFns.delete(resolve)\n this.optionsToIgnoreOnce.delete(watchQueryOptions);\n signal.removeEventListener('abort', handleAborted)\n reject(signal.reason);\n };\n\n this.asyncResolveFns.add(resolve);\n this.optionsToIgnoreOnce.add(watchQueryOptions);\n signal.addEventListener('abort', handleAborted)\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 const error = this.toApolloError(result);\n\n // wait a tick in case we are in the middle of rendering a component\n Promise.resolve().then(() => {\n if (error) {\n this.onError(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 toApolloError(result: ApolloQueryResult<TData>): ApolloError | undefined {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error\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,EAAsB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,aAAa,GAKd,MAAM,YAAY,CAAC;AAQpB,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,OAAoF;IAApF,wBAAA,EAAA,UAAiE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAEpF,OAAO,gBAAg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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,AAvhBD,IAuhBC","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 NoInfer,\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 extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<NoInfer<TData>, NoInfer<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 extends OperationVariables>(\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 extends OperationVariables> {\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(signal: AbortSignal) {\n return new Promise<QueryResult<TData, TVariables>>((resolve, reject) => {\n const watchQueryOptions = this.watchQueryOptions;\n\n const handleAborted = () => {\n this.asyncResolveFns.delete(resolve)\n this.optionsToIgnoreOnce.delete(watchQueryOptions);\n signal.removeEventListener('abort', handleAborted)\n reject(signal.reason);\n };\n\n this.asyncResolveFns.add(resolve);\n this.optionsToIgnoreOnce.add(watchQueryOptions);\n signal.addEventListener('abort', handleAborted)\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 // Do the \"unsubscribe\" with a short delay.\n // This way, an existing subscription can be reused without an additional\n // request if \"unsubscribe\" and \"resubscribe\" to the same ObservableQuery \n // happen in very fast succession.\n return () => setTimeout(() => 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 const error = this.toApolloError(result);\n\n // wait a tick in case we are in the middle of rendering a component\n Promise.resolve().then(() => {\n if (error) {\n this.onError(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 toApolloError(result: ApolloQueryResult<TData>): ApolloError | undefined {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error\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,2 +1,3 @@
1
- export declare function useSuspenseCache(): import("..").SuspenseCache;
1
+ import { SuspenseCache } from '../cache';
2
+ export declare function useSuspenseCache(override?: SuspenseCache): SuspenseCache;
2
3
  //# sourceMappingURL=useSuspenseCache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSuspenseCache.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,+BAU/B"}
1
+ {"version":3,"file":"useSuspenseCache.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,aAAa,iBAYxD"}
@@ -1,10 +1,12 @@
1
1
  import { useContext } from 'react';
2
2
  import { getApolloContext } from "../context/index.js";
3
3
  import { invariant, __DEV__ } 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, 33);
4
+ export function useSuspenseCache(override) {
5
+ var context = useContext(getApolloContext());
6
+ var suspenseCache = override || context.suspenseCache;
7
+ __DEV__ ? invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
8
+ 'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
9
+ 'or pass a SuspenseCache instance in via options.') : invariant(suspenseCache, 33);
8
10
  return suspenseCache;
9
11
  }
10
12
  //# sourceMappingURL=useSuspenseCache.js.map
@@ -1 +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"]}
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;AAGpD,MAAM,UAAU,gBAAgB,CAAC,QAAwB;IACvD,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/C,IAAM,aAAa,GAAG,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAExD,SAAS,CACP,aAAa,EACb,6EAA6E;QAC3E,8EAA8E;QAC9E,kDAAkD,CACrD,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { getApolloContext } from '../context';\nimport { invariant } from '../../utilities/globals';\nimport { SuspenseCache } from '../cache';\n\nexport function useSuspenseCache(override?: SuspenseCache) {\n const context = useContext(getApolloContext());\n const suspenseCache = override || context.suspenseCache;\n\n invariant(\n suspenseCache,\n 'Could not find a \"suspenseCache\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +\n 'or pass a SuspenseCache instance in via options.'\n );\n\n return suspenseCache;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,YAAY,EAEZ,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,sBAAsB,CACrC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB;IAE1D,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,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;IAC7D,eAAe,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAAC;CAC9E;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,CAoH3C"}
1
+ {"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,YAAY,EAEZ,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,sBAAsB,CACrC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB;IAE1D,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,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;IAC7D,eAAe,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAAC;CAC9E;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,CAoH3C"}
@@ -20,7 +20,7 @@ var DEFAULT_SUSPENSE_POLICY = 'always';
20
20
  var DEFAULT_ERROR_POLICY = 'none';
21
21
  export function useSuspenseQuery_experimental(query, options) {
22
22
  if (options === void 0) { options = Object.create(null); }
23
- var suspenseCache = useSuspenseCache();
23
+ var suspenseCache = useSuspenseCache(options.suspenseCache);
24
24
  var client = useApolloClient(options.client);
25
25
  var watchQueryOptions = useWatchQueryOptions({ query: query, options: options, client: client });
26
26
  var previousWatchQueryOptionsRef = useRef(watchQueryOptions);
@@ -146,6 +146,7 @@ function useIsDeferred(query) {
146
146
  function useObservableQueryResult(observable) {
147
147
  var resultRef = useRef();
148
148
  var isMountedRef = useRef(false);
149
+ var subscribeTimeoutRef = useRef();
149
150
  if (!resultRef.current) {
150
151
  resultRef.current = observable.getCurrentResult();
151
152
  }
@@ -156,6 +157,7 @@ function useObservableQueryResult(observable) {
156
157
  };
157
158
  }, []);
158
159
  return useSyncExternalStore(useCallback(function (forceUpdate) {
160
+ clearTimeout(subscribeTimeoutRef.current);
159
161
  function handleUpdate() {
160
162
  var previousResult = resultRef.current;
161
163
  var result = observable.getCurrentResult();
@@ -169,12 +171,15 @@ function useObservableQueryResult(observable) {
169
171
  forceUpdate();
170
172
  }
171
173
  }
172
- var subscription = observable.subscribe({
173
- next: handleUpdate,
174
- error: handleUpdate,
174
+ var subscription;
175
+ subscribeTimeoutRef.current = setTimeout(function () {
176
+ subscription = observable.subscribe({
177
+ next: handleUpdate,
178
+ error: handleUpdate,
179
+ });
175
180
  });
176
181
  return function () {
177
- subscription.unsubscribe();
182
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
178
183
  };
179
184
  }, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
180
185
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAEL,WAAW,GAQZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,OAAO,EAEP,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAA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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 { invariant, __DEV__ } from '../../utilities/globals';\nimport { useRef, useEffect, useCallback, useMemo, useState } 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 {\n compact,\n Concast,\n isNonEmptyArray,\n hasDirectives,\n} from '../../utilities';\nimport { useApolloClient } from './useApolloClient';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { useDeepMemo, useIsomorphicLayoutEffect } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport { useSyncExternalStore } from './useSyncExternalStore';\n\nexport interface UseSuspenseQueryResult<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> {\n client: ApolloClient<any>;\n data: TData;\n error: ApolloError | undefined;\n fetchMore: ObservableQueryFields<TData, TVariables>['fetchMore'];\n refetch: ObservableQueryFields<TData, TVariables>['refetch'];\n subscribeToMore: ObservableQueryFields<TData, TVariables>['subscribeToMore'];\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 const deferred = useIsDeferred(query);\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 const hasFullResult = result.data && !result.partial;\n const hasPartialResult = result.data && result.partial;\n const usePartialResult = returnPartialData && hasPartialResult;\n\n const allowsThrownErrors =\n // If we've got a deferred query that errors on an incremental chunk, we\n // will have a partial result before the error is collected. We do not want\n // to throw errors that have been returned from incremental chunks. Instead\n // we offload those errors to the `error` property.\n errorPolicy === 'none' && (!deferred || !hasPartialResult);\n\n if (\n result.error &&\n // Always throw network errors regardless of the error policy\n (result.error.networkError || allowsThrownErrors)\n ) {\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: maybeWrapConcastWithCustomPromise(\n observable.reobserveAsConcast(watchQueryOptions),\n { deferred }\n ),\n observable,\n });\n }\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 client,\n data: result.data,\n error: errorPolicy === 'ignore' ? void 0 : toApolloError(result),\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 subscribeToMore: (options) => observable.subscribeToMore(options),\n };\n }, [client, 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\nfunction maybeWrapConcastWithCustomPromise<TData>(\n concast: Concast<ApolloQueryResult<TData>>,\n { deferred }: { deferred: boolean }\n): Promise<ApolloQueryResult<TData>> {\n if (deferred) {\n return new Promise((resolve, reject) => {\n // Unlike `concast.promise`, we want to resolve the promise on the initial\n // chunk of the deferred query. This allows the component to unsuspend\n // when we get the initial set of data, rather than waiting until all\n // chunks have been loaded.\n const subscription = concast.subscribe({\n next: (value) => {\n resolve(value);\n subscription.unsubscribe();\n },\n error: reject,\n });\n });\n }\n\n return concast.promise;\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables\n> {\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SuspenseQueryHookOptions<TData, TVariables>;\n client: ApolloClient<any>;\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\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 useIsDeferred(query: DocumentNode) {\n return useMemo(() => hasDirectives(['defer'], query), [query]);\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 useIsomorphicLayoutEffect(() => {\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"]}
1
+ {"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,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Aa;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,IAAI,YAA0B,CAAC;QAsB/B,mBAAmB,CAAC,OAAO,GAAG,UAAU,CAAC;YACvC,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC;gBAClC,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,YAAY;aACpB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,WAAW,EAAE,CAAC;QAC9B,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 { invariant, __DEV__ } from '../../utilities/globals';\nimport { useRef, useEffect, useCallback, useMemo, useState } 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 {\n compact,\n Concast,\n isNonEmptyArray,\n hasDirectives,\n} from '../../utilities';\nimport { useApolloClient } from './useApolloClient';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { useDeepMemo, useIsomorphicLayoutEffect } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport { useSyncExternalStore } from './useSyncExternalStore';\nimport { Subscription } from 'zen-observable-ts';\n\nexport interface UseSuspenseQueryResult<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> {\n client: ApolloClient<any>;\n data: TData;\n error: ApolloError | undefined;\n fetchMore: ObservableQueryFields<TData, TVariables>['fetchMore'];\n refetch: ObservableQueryFields<TData, TVariables>['refetch'];\n subscribeToMore: ObservableQueryFields<TData, TVariables>['subscribeToMore'];\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(options.suspenseCache);\n const client = useApolloClient(options.client);\n const watchQueryOptions = useWatchQueryOptions({ query, options, client });\n const previousWatchQueryOptionsRef = useRef(watchQueryOptions);\n const deferred = useIsDeferred(query);\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 const hasFullResult = result.data && !result.partial;\n const hasPartialResult = result.data && result.partial;\n const usePartialResult = returnPartialData && hasPartialResult;\n\n const allowsThrownErrors =\n // If we've got a deferred query that errors on an incremental chunk, we\n // will have a partial result before the error is collected. We do not want\n // to throw errors that have been returned from incremental chunks. Instead\n // we offload those errors to the `error` property.\n errorPolicy === 'none' && (!deferred || !hasPartialResult);\n\n if (\n result.error &&\n // Always throw network errors regardless of the error policy\n (result.error.networkError || allowsThrownErrors)\n ) {\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: maybeWrapConcastWithCustomPromise(\n observable.reobserveAsConcast(watchQueryOptions),\n { deferred }\n ),\n observable,\n });\n }\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 client,\n data: result.data,\n error: errorPolicy === 'ignore' ? void 0 : toApolloError(result),\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 subscribeToMore: (options) => observable.subscribeToMore(options),\n };\n }, [client, 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\nfunction maybeWrapConcastWithCustomPromise<TData>(\n concast: Concast<ApolloQueryResult<TData>>,\n { deferred }: { deferred: boolean }\n): Promise<ApolloQueryResult<TData>> {\n if (deferred) {\n return new Promise((resolve, reject) => {\n // Unlike `concast.promise`, we want to resolve the promise on the initial\n // chunk of the deferred query. This allows the component to unsuspend\n // when we get the initial set of data, rather than waiting until all\n // chunks have been loaded.\n const subscription = concast.subscribe({\n next: (value) => {\n resolve(value);\n subscription.unsubscribe();\n },\n error: reject,\n });\n });\n }\n\n return concast.promise;\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables\n> {\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SuspenseQueryHookOptions<TData, TVariables>;\n client: ApolloClient<any>;\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\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 useIsDeferred(query: DocumentNode) {\n return useMemo(() => hasDirectives(['defer'], query), [query]);\n}\n\nfunction useObservableQueryResult<TData>(observable: ObservableQuery<TData>) {\n const resultRef = useRef<ApolloQueryResult<TData>>();\n const isMountedRef = useRef(false);\n const subscribeTimeoutRef = useRef<NodeJS.Timeout>();\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 useIsomorphicLayoutEffect(() => {\n isMountedRef.current = true;\n\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n return useSyncExternalStore(\n useCallback(\n (forceUpdate) => {\n clearTimeout(subscribeTimeoutRef.current);\n\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 let subscription: Subscription;\n\n // We use a `setTimeout` here to avoid issues in React's strict mode\n // where the subscription would be torn down, but resubscribing would\n // be stuck in the torn down state, therefore updates to the cache would\n // not trigger the observable's subscription. This occurs due to the new\n // `fetchOnFirstSubscribe` option introduced with `useSuspenseQuery`,\n // which avoids issuing a network request (via `reobserve`) when calling\n // `subscribe` on the observable. Unfortunately `reobserve` is required\n // to put the observable back into a non-torn-down state, which is not\n // called due to this option. Instead we try delaying calling subscribe\n // for the first time by allowing React to run this effect, tear it down,\n // then set it back up again before we resubscribe.\n //\n // Authors note (Jerel): This feels super hacky and I hate it, but this\n // seems like the best approach to avoid completely changing around the\n // internals of ObservableQuery, which could introduce new bugs if I'm\n // not careful. Ideally we could call `subscribe()`, `unsubscribe()`,\n // then `subscribe()` again and be back into a normal state, but this\n // might require a sizable refactor to accomplish.\n //\n // Related to https://github.com/apollographql/apollo-client/issues/10428\n subscribeTimeoutRef.current = setTimeout(() => {\n subscription = observable.subscribe({\n next: handleUpdate,\n error: handleUpdate,\n });\n });\n\n return () => {\n subscription?.unsubscribe();\n };\n },\n [observable]\n ),\n () => resultRef.current!,\n () => resultRef.current!\n );\n}\n"]}
@@ -6,6 +6,7 @@ import { FetchResult } from '../../link/core';
6
6
  import { ApolloError } from '../../errors';
7
7
  import { ApolloCache, ApolloClient, DefaultContext, FetchPolicy, MutationOptions, NetworkStatus, ObservableQuery, OperationVariables, InternalRefetchQueriesInclude, WatchQueryOptions, WatchQueryFetchPolicy } from '../../core';
8
8
  import { NextFetchPolicyContext } from '../../core/watchQueryOptions';
9
+ import { SuspenseCache } from '../cache';
9
10
  export type { DefaultContext as Context } from "../../core";
10
11
  export type CommonOptions<TOptions> = TOptions & {
11
12
  client?: ApolloClient<object>;
@@ -49,6 +50,7 @@ export interface SuspenseQueryHookOptions<TData = any, TVariables extends Operat
49
50
  fetchPolicy?: SuspenseQueryHookFetchPolicy;
50
51
  nextFetchPolicy?: SuspenseQueryHookFetchPolicy | ((currentFetchPolicy: SuspenseQueryHookFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => SuspenseQueryHookFetchPolicy);
51
52
  suspensePolicy?: SuspensePolicy;
53
+ suspenseCache?: SuspenseCache;
52
54
  }
53
55
  export interface QueryLazyOptions<TVariables> {
54
56
  variables?: TVariables;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAItE,YAAY,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,aAAa,CAAC,QAAQ,IAAI,QAAQ,GAAG;IAC/C,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAIF,MAAM,WAAW,gBAAgB,CAAC,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,CAC5F,SAAQ,IAAI,CAAC,iBA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
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/types/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { Observable, ObservableSubscription } from '../../utilities';\nimport { FetchResult } from '../../link/core';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloCache,\n ApolloClient,\n DefaultContext,\n FetchPolicy,\n MutationOptions,\n NetworkStatus,\n ObservableQuery,\n OperationVariables,\n InternalRefetchQueriesInclude,\n WatchQueryOptions,\n WatchQueryFetchPolicy,\n} from '../../core';\nimport { NextFetchPolicyContext } from '../../core/watchQueryOptions';\n\n/* Common types */\n\nexport type { DefaultContext as Context } from \"../../core\";\n\nexport type CommonOptions<TOptions> = TOptions & {\n client?: ApolloClient<object>;\n};\n\n/* Query types */\n\nexport interface BaseQueryOptions<TVariables extends OperationVariables = OperationVariables>\nextends Omit<WatchQueryOptions<TVariables>, \"query\"> {\n ssr?: boolean;\n client?: ApolloClient<any>;\n context?: DefaultContext;\n}\n\nexport interface QueryFunctionOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseQueryOptions<TVariables> {\n skip?: boolean;\n onCompleted?: (data: TData) => void;\n onError?: (error: ApolloError) => void;\n\n // Default WatchQueryOptions for this useQuery, providing initial values for\n // unspecified options, superseding client.defaultOptions.watchQuery (option\n // by option, not whole), but never overriding options previously passed to\n // useQuery (or options added/modified later by other means).\n // TODO What about about default values that are expensive to evaluate?\n defaultOptions?: Partial<WatchQueryOptions<TVariables, TData>>;\n}\n\nexport type ObservableQueryFields<TData, TVariables extends OperationVariables> = Pick<\n ObservableQuery<TData, TVariables>,\n | 'startPolling'\n | 'stopPolling'\n | 'subscribeToMore'\n | 'updateQuery'\n | 'refetch'\n | 'reobserve'\n | 'variables'\n | 'fetchMore'\n>;\n\nexport interface QueryResult<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends ObservableQueryFields<TData, TVariables> {\n client: ApolloClient<any>;\n observable: ObservableQuery<TData, TVariables>;\n data: TData | undefined;\n previousData?: TData;\n error?: ApolloError;\n loading: boolean;\n networkStatus: NetworkStatus;\n called: boolean;\n}\n\nexport interface QueryDataOptions<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends QueryFunctionOptions<TData, TVariables> {\n children?: (result: QueryResult<TData, TVariables>) => ReactNode;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport interface QueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends QueryFunctionOptions<TData, TVariables> {\n}\n\nexport interface LazyQueryHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends Omit<QueryHookOptions<TData, TVariables>, 'skip'> {\n}\n\nexport interface LazyQueryHookExecOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends LazyQueryHookOptions<TData, TVariables> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\n/**\n * suspensePolicy determines how suspense behaves for a refetch. The options are:\n * - always (default): Re-suspend a component when a refetch occurs\n * - initial: Only suspend on the first fetch\n */\nexport type SuspensePolicy =\n | 'always'\n | 'initial'\n\nexport type SuspenseQueryHookFetchPolicy = Extract<\n WatchQueryFetchPolicy,\n | 'cache-first'\n | 'network-only'\n | 'no-cache'\n | 'cache-and-network'\n>;\n\nexport interface SuspenseQueryHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends Pick<\n QueryHookOptions<TData, TVariables>,\n | 'client'\n | 'variables'\n | 'errorPolicy'\n | 'context'\n | 'canonizeResults'\n | 'returnPartialData'\n | 'refetchWritePolicy'\n> {\n fetchPolicy?: SuspenseQueryHookFetchPolicy;\n nextFetchPolicy?:\n | SuspenseQueryHookFetchPolicy\n | ((\n currentFetchPolicy: SuspenseQueryHookFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>\n ) => SuspenseQueryHookFetchPolicy);\n suspensePolicy?: SuspensePolicy;\n}\n\n/**\n * @deprecated TODO Delete this unused interface.\n */\nexport interface QueryLazyOptions<TVariables> {\n variables?: TVariables;\n context?: DefaultContext;\n}\n\n/**\n * @deprecated TODO Delete this unused type alias.\n */\nexport type LazyQueryResult<TData, TVariables extends OperationVariables> = QueryResult<TData, TVariables>;\n\n/**\n * @deprecated TODO Delete this unused type alias.\n */\nexport type QueryTuple<TData, TVariables extends OperationVariables> =\n LazyQueryResultTuple<TData, TVariables>;\n\nexport type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (\n options?: Partial<LazyQueryHookExecOptions<TData, TVariables>>,\n) => Promise<QueryResult<TData, TVariables>>;\n\nexport type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [\n LazyQueryExecFunction<TData, TVariables>,\n QueryResult<TData, TVariables>,\n];\n\n/* Mutation types */\n\nexport type RefetchQueriesFunction = (\n ...args: any[]\n) => InternalRefetchQueriesInclude;\n\nexport interface BaseMutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>\n> extends Omit<\n MutationOptions<TData, TVariables, TContext, TCache>,\n | \"mutation\"\n> {\n client?: ApolloClient<object>;\n notifyOnNetworkStatusChange?: boolean;\n onCompleted?: (data: TData, clientOptions?: BaseMutationOptions) => void;\n onError?: (error: ApolloError, clientOptions?: BaseMutationOptions) => void;\n ignoreResults?: boolean;\n}\n\nexport interface MutationFunctionOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport interface MutationResult<TData = any> {\n data?: TData | null;\n error?: ApolloError;\n loading: boolean;\n called: boolean;\n client: ApolloClient<object>;\n reset(): void;\n}\n\nexport declare type MutationFunction<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> = (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n) => Promise<FetchResult<TData>>;\n\nexport interface MutationHookOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n}\n\nexport interface MutationDataOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport type MutationTuple<\n TData,\n TVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> = [\n (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n // TODO This FetchResult<TData> seems strange here, as opposed to an\n // ApolloQueryResult<TData>\n ) => Promise<FetchResult<TData>>,\n MutationResult<TData>,\n];\n\n/* Subscription types */\n\nexport interface OnDataOptions<TData = any> {\n client: ApolloClient<object>;\n data: SubscriptionResult<TData>;\n}\n\nexport interface OnSubscriptionDataOptions<TData = any> {\n client: ApolloClient<object>;\n subscriptionData: SubscriptionResult<TData>;\n}\n\nexport interface BaseSubscriptionOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> {\n variables?: TVariables;\n fetchPolicy?: FetchPolicy;\n shouldResubscribe?:\n | boolean\n | ((options: BaseSubscriptionOptions<TData, TVariables>) => boolean);\n client?: ApolloClient<object>;\n skip?: boolean;\n context?: DefaultContext;\n onComplete?: () => void;\n onData?: (options: OnDataOptions<TData>) => any;\n /**\n * @deprecated Use onData instead\n */\n onSubscriptionData?: (options: OnSubscriptionDataOptions<TData>) => any;\n onError?: (error: ApolloError) => void;\n /**\n * @deprecated Use onComplete instead\n */\n onSubscriptionComplete?: () => void;\n}\n\nexport interface SubscriptionResult<TData = any, TVariables = any> {\n loading: boolean;\n data?: TData;\n error?: ApolloError;\n // This was added by the legacy useSubscription type, and is tested in unit\n // tests, but probably shouldn’t be added to the result.\n variables?: TVariables;\n}\n\nexport interface SubscriptionHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseSubscriptionOptions<TData, TVariables> {\n}\n\nexport interface SubscriptionDataOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseSubscriptionOptions<TData, TVariables> {\n subscription: DocumentNode | TypedDocumentNode<TData, TVariables>;\n children?: null | ((result: SubscriptionResult<TData>) => JSX.Element | null);\n}\n\nexport interface SubscriptionCurrentObservable {\n query?: Observable<any>;\n subscription?: ObservableSubscription;\n}\n\n/**\nHelper type that allows using a type in a way that cannot be \"widened\" by inference on the value it is used on.\n\nThis type was first suggested [in this Github discussion](https://github.com/microsoft/TypeScript/issues/14829#issuecomment-504042546).\n\nExample usage:\n```ts\nexport function useQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> = Object.create(null),\n)\n```\nIn this case, `TData` and `TVariables` should be inferred from `query`, but never widened from something in `options`.\n\nSo, in this code example:\n```ts\ndeclare const typedNode: TypedDocumentNode<{ foo: string}, { bar: number }>\nconst { variables } = useQuery(typedNode, { variables: { bar: 4, nonExistingVariable: \"string\" } });\n```\nWithout the use of `NoInfer`, `variables` would now be of the type `{ bar: number, nonExistingVariable: \"string\" }`.\nWith `NoInfer`, it will instead give an error on `nonExistingVariable`.\n */\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/types/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { Observable, ObservableSubscription } from '../../utilities';\nimport { FetchResult } from '../../link/core';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloCache,\n ApolloClient,\n DefaultContext,\n FetchPolicy,\n MutationOptions,\n NetworkStatus,\n ObservableQuery,\n OperationVariables,\n InternalRefetchQueriesInclude,\n WatchQueryOptions,\n WatchQueryFetchPolicy,\n} from '../../core';\nimport { NextFetchPolicyContext } from '../../core/watchQueryOptions';\nimport { SuspenseCache } from '../cache';\n\n/* Common types */\n\nexport type { DefaultContext as Context } from \"../../core\";\n\nexport type CommonOptions<TOptions> = TOptions & {\n client?: ApolloClient<object>;\n};\n\n/* Query types */\n\nexport interface BaseQueryOptions<TVariables extends OperationVariables = OperationVariables>\nextends Omit<WatchQueryOptions<TVariables>, \"query\"> {\n ssr?: boolean;\n client?: ApolloClient<any>;\n context?: DefaultContext;\n}\n\nexport interface QueryFunctionOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseQueryOptions<TVariables> {\n skip?: boolean;\n onCompleted?: (data: TData) => void;\n onError?: (error: ApolloError) => void;\n\n // Default WatchQueryOptions for this useQuery, providing initial values for\n // unspecified options, superseding client.defaultOptions.watchQuery (option\n // by option, not whole), but never overriding options previously passed to\n // useQuery (or options added/modified later by other means).\n // TODO What about about default values that are expensive to evaluate?\n defaultOptions?: Partial<WatchQueryOptions<TVariables, TData>>;\n}\n\nexport type ObservableQueryFields<TData, TVariables extends OperationVariables> = Pick<\n ObservableQuery<TData, TVariables>,\n | 'startPolling'\n | 'stopPolling'\n | 'subscribeToMore'\n | 'updateQuery'\n | 'refetch'\n | 'reobserve'\n | 'variables'\n | 'fetchMore'\n>;\n\nexport interface QueryResult<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends ObservableQueryFields<TData, TVariables> {\n client: ApolloClient<any>;\n observable: ObservableQuery<TData, TVariables>;\n data: TData | undefined;\n previousData?: TData;\n error?: ApolloError;\n loading: boolean;\n networkStatus: NetworkStatus;\n called: boolean;\n}\n\nexport interface QueryDataOptions<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends QueryFunctionOptions<TData, TVariables> {\n children?: (result: QueryResult<TData, TVariables>) => ReactNode;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport interface QueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables>\n extends QueryFunctionOptions<TData, TVariables> {\n}\n\nexport interface LazyQueryHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends Omit<QueryHookOptions<TData, TVariables>, 'skip'> {\n}\n\nexport interface LazyQueryHookExecOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends LazyQueryHookOptions<TData, TVariables> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\n/**\n * suspensePolicy determines how suspense behaves for a refetch. The options are:\n * - always (default): Re-suspend a component when a refetch occurs\n * - initial: Only suspend on the first fetch\n */\nexport type SuspensePolicy =\n | 'always'\n | 'initial'\n\nexport type SuspenseQueryHookFetchPolicy = Extract<\n WatchQueryFetchPolicy,\n | 'cache-first'\n | 'network-only'\n | 'no-cache'\n | 'cache-and-network'\n>;\n\nexport interface SuspenseQueryHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends Pick<\n QueryHookOptions<TData, TVariables>,\n | 'client'\n | 'variables'\n | 'errorPolicy'\n | 'context'\n | 'canonizeResults'\n | 'returnPartialData'\n | 'refetchWritePolicy'\n> {\n fetchPolicy?: SuspenseQueryHookFetchPolicy;\n nextFetchPolicy?:\n | SuspenseQueryHookFetchPolicy\n | ((\n currentFetchPolicy: SuspenseQueryHookFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>\n ) => SuspenseQueryHookFetchPolicy);\n suspensePolicy?: SuspensePolicy;\n suspenseCache?: SuspenseCache;\n}\n\n/**\n * @deprecated TODO Delete this unused interface.\n */\nexport interface QueryLazyOptions<TVariables> {\n variables?: TVariables;\n context?: DefaultContext;\n}\n\n/**\n * @deprecated TODO Delete this unused type alias.\n */\nexport type LazyQueryResult<TData, TVariables extends OperationVariables> = QueryResult<TData, TVariables>;\n\n/**\n * @deprecated TODO Delete this unused type alias.\n */\nexport type QueryTuple<TData, TVariables extends OperationVariables> =\n LazyQueryResultTuple<TData, TVariables>;\n\nexport type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (\n options?: Partial<LazyQueryHookExecOptions<TData, TVariables>>,\n) => Promise<QueryResult<TData, TVariables>>;\n\nexport type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [\n LazyQueryExecFunction<TData, TVariables>,\n QueryResult<TData, TVariables>,\n];\n\n/* Mutation types */\n\nexport type RefetchQueriesFunction = (\n ...args: any[]\n) => InternalRefetchQueriesInclude;\n\nexport interface BaseMutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>\n> extends Omit<\n MutationOptions<TData, TVariables, TContext, TCache>,\n | \"mutation\"\n> {\n client?: ApolloClient<object>;\n notifyOnNetworkStatusChange?: boolean;\n onCompleted?: (data: TData, clientOptions?: BaseMutationOptions) => void;\n onError?: (error: ApolloError, clientOptions?: BaseMutationOptions) => void;\n ignoreResults?: boolean;\n}\n\nexport interface MutationFunctionOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport interface MutationResult<TData = any> {\n data?: TData | null;\n error?: ApolloError;\n loading: boolean;\n called: boolean;\n client: ApolloClient<object>;\n reset(): void;\n}\n\nexport declare type MutationFunction<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> = (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n) => Promise<FetchResult<TData>>;\n\nexport interface MutationHookOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n}\n\nexport interface MutationDataOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n}\n\nexport type MutationTuple<\n TData,\n TVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> = [\n (\n options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>\n // TODO This FetchResult<TData> seems strange here, as opposed to an\n // ApolloQueryResult<TData>\n ) => Promise<FetchResult<TData>>,\n MutationResult<TData>,\n];\n\n/* Subscription types */\n\nexport interface OnDataOptions<TData = any> {\n client: ApolloClient<object>;\n data: SubscriptionResult<TData>;\n}\n\nexport interface OnSubscriptionDataOptions<TData = any> {\n client: ApolloClient<object>;\n subscriptionData: SubscriptionResult<TData>;\n}\n\nexport interface BaseSubscriptionOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> {\n variables?: TVariables;\n fetchPolicy?: FetchPolicy;\n shouldResubscribe?:\n | boolean\n | ((options: BaseSubscriptionOptions<TData, TVariables>) => boolean);\n client?: ApolloClient<object>;\n skip?: boolean;\n context?: DefaultContext;\n onComplete?: () => void;\n onData?: (options: OnDataOptions<TData>) => any;\n /**\n * @deprecated Use onData instead\n */\n onSubscriptionData?: (options: OnSubscriptionDataOptions<TData>) => any;\n onError?: (error: ApolloError) => void;\n /**\n * @deprecated Use onComplete instead\n */\n onSubscriptionComplete?: () => void;\n}\n\nexport interface SubscriptionResult<TData = any, TVariables = any> {\n loading: boolean;\n data?: TData;\n error?: ApolloError;\n // This was added by the legacy useSubscription type, and is tested in unit\n // tests, but probably shouldn’t be added to the result.\n variables?: TVariables;\n}\n\nexport interface SubscriptionHookOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseSubscriptionOptions<TData, TVariables> {\n}\n\nexport interface SubscriptionDataOptions<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> extends BaseSubscriptionOptions<TData, TVariables> {\n subscription: DocumentNode | TypedDocumentNode<TData, TVariables>;\n children?: null | ((result: SubscriptionResult<TData>) => JSX.Element | null);\n}\n\nexport interface SubscriptionCurrentObservable {\n query?: Observable<any>;\n subscription?: ObservableSubscription;\n}\n\n/**\nHelper type that allows using a type in a way that cannot be \"widened\" by inference on the value it is used on.\n\nThis type was first suggested [in this Github discussion](https://github.com/microsoft/TypeScript/issues/14829#issuecomment-504042546).\n\nExample usage:\n```ts\nexport function useQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> = Object.create(null),\n)\n```\nIn this case, `TData` and `TVariables` should be inferred from `query`, but never widened from something in `options`.\n\nSo, in this code example:\n```ts\ndeclare const typedNode: TypedDocumentNode<{ foo: string}, { bar: number }>\nconst { variables } = useQuery(typedNode, { variables: { bar: 4, nonExistingVariable: \"string\" } });\n```\nWithout the use of `NoInfer`, `variables` would now be of the type `{ bar: number, nonExistingVariable: \"string\" }`.\nWith `NoInfer`, it will instead give an error on `nonExistingVariable`.\n */\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"itAsync.js","sourceRoot":"","sources":["../../../src/testing/core/itAsync.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAU,GAA8B;IACnD,OAAO,UACL,OAAe,EACf,QAGQ,EACR,OAAgB,IACb,OAAA,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE;QAAA,iBAIlC;QAHC,OAAO,IAAI,OAAO,CAChB,UAAC,OAAO,EAAE,MAAM,IAAK,OAAA,QAAQ,CAAC,IAAI,CAAC,KAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAApC,CAAoC,CAC1D,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,EAJN,CAIM,CAAC;AACd,CAAC;AAED,IAAM,SAAS,GAAG,IAAI,EAAE,CAAC;AAEzB,MAAM,CAAC,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,cAAqC;SAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC;QAArC,yBAAqC;;IAErC,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,EAAE;IACD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC","sourcesContent":["function wrap<TResult>(key?: \"only\" | \"skip\" | \"todo\") {\n return (\n message: string,\n callback: (\n resolve: (result?: any) => void,\n reject: (reason?: any) => void,\n ) => any,\n timeout?: number,\n ) => (key ? it[key] : it)(message, function () {\n return new Promise(\n (resolve, reject) => callback.call(this, resolve, reject),\n );\n }, timeout);\n}\n\nconst wrappedIt = wrap();\n\nexport const itAsync = Object.assign(function (\n ...args: Parameters<typeof wrappedIt>\n) {\n return wrappedIt.apply(this, args);\n}, {\n only: wrap(\"only\"),\n skip: wrap(\"skip\"),\n todo: wrap(\"todo\"),\n});\n"]}
1
+ {"version":3,"file":"itAsync.js","sourceRoot":"","sources":["../../../src/testing/core/itAsync.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAC,GAA8B;IAC1C,OAAO,UACL,OAAe,EACf,QAGQ,EACR,OAAgB,IACb,OAAA,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE;QAAA,iBAIlC;QAHC,OAAO,IAAI,OAAO,CAChB,UAAC,OAAO,EAAE,MAAM,IAAK,OAAA,QAAQ,CAAC,IAAI,CAAC,KAAI,EAAE,OAAO,EAAE,MAAM,CAAC,EAApC,CAAoC,CAC1D,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,EAJN,CAIM,CAAC;AACd,CAAC;AAED,IAAM,SAAS,GAAG,IAAI,EAAE,CAAC;AAEzB,MAAM,CAAC,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,cAAqC;SAArC,UAAqC,EAArC,qBAAqC,EAArC,IAAqC;QAArC,yBAAqC;;IAErC,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,EAAE;IACD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC","sourcesContent":["function wrap(key?: \"only\" | \"skip\" | \"todo\") {\n return (\n message: string,\n callback: (\n resolve: (result?: any) => void,\n reject: (reason?: any) => void,\n ) => any,\n timeout?: number,\n ) => (key ? it[key] : it)(message, function () {\n return new Promise(\n (resolve, reject) => callback.call(this, resolve, reject),\n );\n }, timeout);\n}\n\nconst wrappedIt = wrap();\n\nexport const itAsync = Object.assign(function (\n ...args: Parameters<typeof wrappedIt>\n) {\n return wrappedIt.apply(this, args);\n}, {\n only: wrap(\"only\"),\n skip: wrap(\"skip\"),\n todo: wrap(\"todo\"),\n});\n"]}
@@ -1,2 +1,3 @@
1
+ export declare const isArray: (a: any) => a is any[] | readonly any[];
1
2
  export declare function isNonEmptyArray<T>(value?: ArrayLike<T>): value is Array<T>;
2
3
  //# sourceMappingURL=arrays.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/arrays.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE1E"}
1
+ {"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/arrays.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG,EAAE,GAAG,SAAS,GAAG,EAAkB,CAAC;AAE9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE1E"}
@@ -1,3 +1,4 @@
1
+ export var isArray = Array.isArray;
1
2
  export function isNonEmptyArray(value) {
2
3
  return Array.isArray(value) && value.length > 0;
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/utilities/common/arrays.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAI,KAAoB;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC","sourcesContent":["export function isNonEmptyArray<T>(value?: ArrayLike<T>): value is Array<T> {\n return Array.isArray(value) && value.length > 0;\n}\n"]}
1
+ {"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/utilities/common/arrays.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,IAAM,OAAO,GAA4C,KAAK,CAAC,OAAO,CAAC;AAE9E,MAAM,UAAU,eAAe,CAAI,KAAoB;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// A version of Array.isArray that works better with readonly arrays.\nexport const isArray: (a: any) => a is any[] | readonly any[] = Array.isArray;\n\nexport function isNonEmptyArray<T>(value?: ArrayLike<T>): value is Array<T> {\n return Array.isArray(value) && value.length > 0;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getFromAST.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/getFromAST.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAKjB,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,gBA0B9C;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,YAAY,GAChB,uBAAuB,GAAG,SAAS,CAKrC;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CASjE;AAGD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,YAAY,GAChB,sBAAsB,EAAE,CAI1B;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,uBAAuB,CAS7E;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,GAChB,sBAAsB,CAoBxB;AAOD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,GACrB,uBAAuB,GAAG,sBAAsB,CA8BlD;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,uBAAuB,GAAG,SAAS,GAC9C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAerB"}
1
+ {"version":3,"file":"getFromAST.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/getFromAST.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AASjB,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,gBA0B9C;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,YAAY,GAChB,uBAAuB,GAAG,SAAS,CAMrC;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CASjE;AAGD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,YAAY,GAChB,sBAAsB,EAAE,CAK1B;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,uBAAuB,CAS7E;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,YAAY,GAChB,sBAAsB,CAoBxB;AAOD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,GACrB,uBAAuB,GAAG,sBAAsB,CA8BlD;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,uBAAuB,GAAG,SAAS,GAC9C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAerB"}
@@ -15,17 +15,21 @@ export function checkDocument(doc) {
15
15
  }
16
16
  export function getOperationDefinition(doc) {
17
17
  checkDocument(doc);
18
- return doc.definitions.filter(function (definition) { return definition.kind === 'OperationDefinition'; })[0];
18
+ return doc.definitions.filter(function (definition) {
19
+ return definition.kind === 'OperationDefinition';
20
+ })[0];
19
21
  }
20
22
  export function getOperationName(doc) {
21
23
  return (doc.definitions
22
24
  .filter(function (definition) {
23
- return definition.kind === 'OperationDefinition' && definition.name;
25
+ return definition.kind === 'OperationDefinition' && !!definition.name;
24
26
  })
25
27
  .map(function (x) { return x.name.value; })[0] || null);
26
28
  }
27
29
  export function getFragmentDefinitions(doc) {
28
- return doc.definitions.filter(function (definition) { return definition.kind === 'FragmentDefinition'; });
30
+ return doc.definitions.filter(function (definition) {
31
+ return definition.kind === 'FragmentDefinition';
32
+ });
29
33
  }
30
34
  export function getQueryDefinition(doc) {
31
35
  var queryDef = getOperationDefinition(doc);