@apollo/client 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apollo-client.cjs +34 -59
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +7 -23
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +8 -24
- package/core/core.cjs.map +1 -1
- package/core/watchQueryOptions.d.ts +0 -1
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +2 -2
- package/react/hooks/hooks.cjs +2 -25
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +3 -26
- package/react/hooks/useQuery.js.map +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +24 -10
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +24 -10
- package/react/parser/parser.cjs.map +1 -1
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAsB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAsB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,aAAa,GAKd,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,YAAY,EAAE,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,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,AAveD,IAueC;AAED,SAAS,qBAAqB,CAC5B,cAAoD,EACpD,2BAAsD;IAEtD,IAAI,2BAA2B,EAAE;QAC/B,IAAI,cAAc,EAAE;YAGlB,2BAA2B,CAAC,IAAI,CAAC,CAAC;SACnC;aAAM;YAGL,UAAU,CAAC,cAAM,OAAA,2BAA2B,CAAC,KAAK,CAAC,EAAlC,CAAkC,EAAE,IAAI,CAAC,CAAC;SAC5D;KACF;IAED,SAAS,CAAC;QACR,IAAI,2BAA2B,EAAE;YAC/B,2BAA2B,CAAC,IAAI,CAAC,CAAC;SACnC;IACH,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';\nimport { equal } from '@wry/equality';\n\nimport { mergeOptions, OperationVariables } from '../../core';\nimport { ApolloContextValue, getApolloContext } from '../context';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloClient,\n ApolloQueryResult,\n NetworkStatus,\n ObservableQuery,\n DocumentNode,\n TypedDocumentNode,\n WatchQueryOptions,\n} from '../../core';\nimport {\n QueryHookOptions,\n QueryResult,\n ObservableQueryFields,\n} from '../types/types';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { useApolloClient } from './useApolloClient';\nimport { canUseWeakMap, isNonEmptyArray, maybeDeepFreeze } from '../../utilities';\n\nconst {\n prototype: {\n hasOwnProperty,\n },\n} = Object;\n\nexport function useQuery<\n TData = any,\n TVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<TData, TVariables> = Object.create(null),\n): QueryResult<TData, TVariables> {\n return useInternalState(\n useApolloClient(options.client),\n query,\n ).useQuery(options);\n}\n\nexport function useInternalState<TData, TVariables>(\n client: ApolloClient<any>,\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n): InternalState<TData, TVariables> {\n const stateRef = useRef<InternalState<TData, TVariables>>();\n if (\n !stateRef.current ||\n client !== stateRef.current.client ||\n query !== stateRef.current.query\n ) {\n stateRef.current = new InternalState(client, query);\n }\n const state = stateRef.current;\n\n // By default, InternalState.prototype.forceUpdate is an empty function, but\n // we replace it here (before anyone has had a chance to see this state yet)\n // with a function that unconditionally forces an update, using the latest\n // setTick function. Updating this state by calling state.forceUpdate is the\n // only way we trigger React component updates (no other useState calls within\n // the InternalState class).\n const [_tick, setTick] = useState(0);\n state.forceUpdate = () => {\n setTick(tick => tick + 1);\n };\n\n return state;\n}\n\nclass InternalState<TData, TVariables> {\n constructor(\n public readonly client: ReturnType<typeof useApolloClient>,\n public readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ) {\n verifyDocumentType(query, DocumentType.Query);\n }\n\n forceUpdate() {\n // Replaced (in useInternalState) with a method that triggers an update.\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 );\n\n // TODO Remove this method when we remove support for options.partialRefetch.\n this.unsafeHandlePartialRefetch(result);\n\n return this.toQueryResult(result);\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 let resolveFetchBlockingPromise: undefined | ((result: boolean) => any);\n\n if (!equal(watchQueryOptions, currentWatchQueryOptions)) {\n this.watchQueryOptions = watchQueryOptions;\n if (currentWatchQueryOptions && this.observable) {\n // Though it might be tempting to postpone this setOptions 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 setOptions\n // (potentially) kicks off a network request (for example, when the\n // variables have changed). To prevent any risk of premature/unwanted\n // network traffic, we use a fetchBlockingPromise, which will only be\n // unblocked once the useEffect has fired.\n this.observable.reobserve({\n fetchBlockingPromise: new Promise<boolean>(resolve => {\n resolveFetchBlockingPromise = resolve;\n }),\n // If watchQueryOptions.fetchBlockingPromise is also defined, it takes\n // precedence over the fetchBlockingPromise we just created.\n ...watchQueryOptions,\n });\n\n this.previousData = this.result?.data || this.previousData;\n this.result = void 0;\n }\n }\n\n useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);\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 ) {\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 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 displayName,\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 // We use the mergeOptions helper function (which uses compact(...) and\n // shallow-merges variables) to combine globalDefaults with any local\n // defaultOptions provided to useQuery.\n const toMerge: Partial<WatchQueryOptions<TVariables, TData>>[] = [];\n\n // Merge global client.watchQuery default options with the lowest priority.\n const globalDefaults = this.client.defaultOptions.watchQuery;\n if (globalDefaults) toMerge.push(globalDefaults);\n\n // Next, merge any defaultOptions passed directly to useQuery.\n if (defaultOptions) toMerge.push(defaultOptions);\n\n const latestOptions = this.observable && this.observable.options;\n if (latestOptions && toMerge.length) {\n // If we already have this.watchQueryOptions, those options should take\n // precedence over default options of the same name. It might be simpler\n // to do toMerge.push(this.watchQueryOptions), but that potentially\n // (re)injects unrelated/unwanted options. Passing Object.create(null) as\n // the second argument to toMerge.reduce ensures the result is a newly\n // created object, so we can safely modify it in the forEach loop below.\n const defaults = toMerge.reduce(mergeOptions, Object.create(null));\n\n // Compact the toMerge array to hold only the merged defaults. This is\n // equivalent to toMerge.splice(0, toMerge.length, defaults).\n toMerge.length = 1;\n toMerge[0] = defaults;\n\n Object.keys(defaults).forEach(\n (defaultOptionName: keyof WatchQueryOptions<TVariables, TData>) => {\n const currentOptionValue = latestOptions[defaultOptionName];\n if (\n hasOwnProperty.call(latestOptions, defaultOptionName) &&\n !equal(defaults[defaultOptionName], currentOptionValue)\n ) {\n // If you keep passing useQuery({ defaultOptions: { variables }}),\n // those default variables continue to provide their default values\n // every time, though in most cases this.watchQueryOptions.variables\n // will have a current value for every default variable name, so the\n // defaults don't matter. However, if a variable has been removed\n // from this.watchQueryOptions.variables, future useQuery calls can\n // restore its default value from defaultOptions.variables.\n defaults[defaultOptionName] = defaultOptionName === \"variables\"\n ? { ...defaults.variables, ...currentOptionValue }\n : currentOptionValue;\n }\n },\n );\n }\n\n // Give highest precedence to any non-default WatchQueryOptions passed\n // directly to useQuery.\n toMerge.push(otherOptions);\n\n const merged = toMerge.reduce(mergeOptions, Object.create(null));\n\n // This Object.assign is safe because merged is the fresh object created by\n // the Object.create(null) argument to toMerge.reduce.\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> =\n Object.assign(merged, { 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 } else if (!watchQueryOptions.fetchPolicy) {\n // We applied all available fetchPolicy default values above (from\n // globalDefaults and defaultOptions), so, if fetchPolicy is still\n // undefined, fall back to the default default (no typo), cache-first.\n watchQueryOptions.fetchPolicy = 'cache-first';\n }\n\n if (skip) {\n const {\n // The watchQueryOptions.initialFetchPolicy field usually defaults to\n // watchQueryOptions.fetchPolicy, which has now been properly\n // defaulted/initialized. However, watchQueryOptions.initialFetchPolicy\n // can be provided explicitly instead, if more control is desired.\n initialFetchPolicy = watchQueryOptions.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 }\n\n if (!watchQueryOptions.variables) {\n watchQueryOptions.variables = {} as TVariables;\n }\n\n return watchQueryOptions;\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 let resolveFetchBlockingPromise: undefined | ((result: boolean) => any);\n\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({\n fetchBlockingPromise: new Promise<boolean>(resolve => {\n resolveFetchBlockingPromise = resolve;\n }),\n ...this.watchQueryOptions,\n });\n\n useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);\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 if (this.renderPromises) {\n this.renderPromises.registerSSRObservable(obsQuery);\n\n const ssrAllowed = !(\n this.queryHookOptions.ssr === false ||\n this.queryHookOptions.skip\n );\n\n if (ssrAllowed && obsQuery.getCurrentResult().loading) {\n // TODO: This is a legacy API which could probably be cleaned up\n this.renderPromises.addObservableQueryPromise(obsQuery);\n }\n }\n\n return obsQuery;\n }\n\n // These members are populated by getCurrentResult and setResult, and it's\n // okay/normal for them to be initially undefined.\n private result: undefined | ApolloQueryResult<TData>;\n private previousData: undefined | TData;\n\n private setResult(nextResult: ApolloQueryResult<TData>) {\n const previousResult = this.result;\n if (previousResult && previousResult.data) {\n this.previousData = previousResult.data;\n }\n this.result = nextResult;\n // Calling state.setResult always triggers an update, though some call sites\n // perform additional equality checks before committing to an update.\n this.forceUpdate();\n this.handleErrorOrCompleted(nextResult);\n }\n\n private handleErrorOrCompleted(result: ApolloQueryResult<TData>) {\n if (!result.loading) {\n if (result.error) {\n this.onError(result.error);\n } else if (result.data) {\n this.onCompleted(result.data);\n }\n }\n }\n\n private getCurrentResult(): ApolloQueryResult<TData> {\n // Using this.result as a cache ensures getCurrentResult continues returning\n // the same (===) result object, unless state.setResult has been called, or\n // we're doing server rendering and therefore override the result below.\n if (!this.result) {\n this.handleErrorOrCompleted(\n this.result = this.observable.getCurrentResult()\n );\n }\n return this.result;\n }\n\n // This cache allows the referential stability of this.result (as returned by\n // getCurrentResult) to translate into referential stability of the resulting\n // QueryResult object returned by toQueryResult.\n private toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)<\n ApolloQueryResult<TData>,\n QueryResult<TData, TVariables>\n >();\n\n toQueryResult(\n result: ApolloQueryResult<TData>,\n ): QueryResult<TData, TVariables> {\n let queryResult = this.toQueryResultCache.get(result);\n if (queryResult) return queryResult;\n\n const { data, partial, ...resultWithoutPartial } = result;\n this.toQueryResultCache.set(result, queryResult = {\n data, // Ensure always defined, even if result.data is missing.\n ...resultWithoutPartial,\n ...this.obsQueryFields,\n client: this.client,\n observable: this.observable,\n variables: this.observable.variables,\n called: true,\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\nfunction useUnblockFetchEffect<TData, TVars>(\n renderPromises: ApolloContextValue[\"renderPromises\"],\n resolveFetchBlockingPromise?: (result: boolean) => any,\n) {\n if (resolveFetchBlockingPromise) {\n if (renderPromises) {\n // Since we're doing SSR, the useEffect callback will not be called, so we\n // must unblock the fetchBlockingPromise now.\n resolveFetchBlockingPromise(true);\n } else {\n // Otherwise, silently discard blocked fetches whose useEffect callbacks\n // have not fired within 5 seconds (more than enough time to mount).\n setTimeout(() => resolveFetchBlockingPromise(false), 5000);\n }\n }\n\n useEffect(() => {\n if (resolveFetchBlockingPromise) {\n resolveFetchBlockingPromise(true);\n }\n }, [resolveFetchBlockingPromise]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mapp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,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,AAldD,IAkdC","sourcesContent":["import {\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';\nimport { equal } from '@wry/equality';\n\nimport { mergeOptions, OperationVariables } from '../../core';\nimport { ApolloContextValue, getApolloContext } from '../context';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloClient,\n ApolloQueryResult,\n NetworkStatus,\n ObservableQuery,\n DocumentNode,\n TypedDocumentNode,\n WatchQueryOptions,\n} from '../../core';\nimport {\n QueryHookOptions,\n QueryResult,\n ObservableQueryFields,\n} from '../types/types';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { useApolloClient } from './useApolloClient';\nimport { canUseWeakMap, isNonEmptyArray, maybeDeepFreeze } from '../../utilities';\n\nconst {\n prototype: {\n hasOwnProperty,\n },\n} = Object;\n\nexport function useQuery<\n TData = any,\n TVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<TData, TVariables> = Object.create(null),\n): QueryResult<TData, TVariables> {\n return useInternalState(\n useApolloClient(options.client),\n query,\n ).useQuery(options);\n}\n\nexport function useInternalState<TData, TVariables>(\n client: ApolloClient<any>,\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n): InternalState<TData, TVariables> {\n const stateRef = useRef<InternalState<TData, TVariables>>();\n if (\n !stateRef.current ||\n client !== stateRef.current.client ||\n query !== stateRef.current.query\n ) {\n stateRef.current = new InternalState(client, query);\n }\n const state = stateRef.current;\n\n // By default, InternalState.prototype.forceUpdate is an empty function, but\n // we replace it here (before anyone has had a chance to see this state yet)\n // with a function that unconditionally forces an update, using the latest\n // setTick function. Updating this state by calling state.forceUpdate is the\n // only way we trigger React component updates (no other useState calls within\n // the InternalState class).\n const [_tick, setTick] = useState(0);\n state.forceUpdate = () => {\n setTick(tick => tick + 1);\n };\n\n return state;\n}\n\nclass InternalState<TData, TVariables> {\n constructor(\n public readonly client: ReturnType<typeof useApolloClient>,\n public readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ) {\n verifyDocumentType(query, DocumentType.Query);\n }\n\n forceUpdate() {\n // Replaced (in useInternalState) with a method that triggers an update.\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 );\n\n // TODO Remove this method when we remove support for options.partialRefetch.\n this.unsafeHandlePartialRefetch(result);\n\n return this.toQueryResult(result);\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 if (!equal(watchQueryOptions, currentWatchQueryOptions)) {\n this.watchQueryOptions = watchQueryOptions;\n if (currentWatchQueryOptions && this.observable) {\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(watchQueryOptions);\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 ) {\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 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 displayName,\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 // We use the mergeOptions helper function (which uses compact(...) and\n // shallow-merges variables) to combine globalDefaults with any local\n // defaultOptions provided to useQuery.\n const toMerge: Partial<WatchQueryOptions<TVariables, TData>>[] = [];\n\n // Merge global client.watchQuery default options with the lowest priority.\n const globalDefaults = this.client.defaultOptions.watchQuery;\n if (globalDefaults) toMerge.push(globalDefaults);\n\n // Next, merge any defaultOptions passed directly to useQuery.\n if (defaultOptions) toMerge.push(defaultOptions);\n\n const latestOptions = this.observable && this.observable.options;\n if (latestOptions && toMerge.length) {\n // If we already have this.watchQueryOptions, those options should take\n // precedence over default options of the same name. It might be simpler\n // to do toMerge.push(this.watchQueryOptions), but that potentially\n // (re)injects unrelated/unwanted options. Passing Object.create(null) as\n // the second argument to toMerge.reduce ensures the result is a newly\n // created object, so we can safely modify it in the forEach loop below.\n const defaults = toMerge.reduce(mergeOptions, Object.create(null));\n\n // Compact the toMerge array to hold only the merged defaults. This is\n // equivalent to toMerge.splice(0, toMerge.length, defaults).\n toMerge.length = 1;\n toMerge[0] = defaults;\n\n Object.keys(defaults).forEach(\n (defaultOptionName: keyof WatchQueryOptions<TVariables, TData>) => {\n const currentOptionValue = latestOptions[defaultOptionName];\n if (\n hasOwnProperty.call(latestOptions, defaultOptionName) &&\n !equal(defaults[defaultOptionName], currentOptionValue)\n ) {\n // If you keep passing useQuery({ defaultOptions: { variables }}),\n // those default variables continue to provide their default values\n // every time, though in most cases this.watchQueryOptions.variables\n // will have a current value for every default variable name, so the\n // defaults don't matter. However, if a variable has been removed\n // from this.watchQueryOptions.variables, future useQuery calls can\n // restore its default value from defaultOptions.variables.\n defaults[defaultOptionName] = defaultOptionName === \"variables\"\n ? { ...defaults.variables, ...currentOptionValue }\n : currentOptionValue;\n }\n },\n );\n }\n\n // Give highest precedence to any non-default WatchQueryOptions passed\n // directly to useQuery.\n toMerge.push(otherOptions);\n\n const merged = toMerge.reduce(mergeOptions, Object.create(null));\n\n // This Object.assign is safe because merged is the fresh object created by\n // the Object.create(null) argument to toMerge.reduce.\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> =\n Object.assign(merged, { 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 } else if (!watchQueryOptions.fetchPolicy) {\n // We applied all available fetchPolicy default values above (from\n // globalDefaults and defaultOptions), so, if fetchPolicy is still\n // undefined, fall back to the default default (no typo), cache-first.\n watchQueryOptions.fetchPolicy = 'cache-first';\n }\n\n if (skip) {\n const {\n // The watchQueryOptions.initialFetchPolicy field usually defaults to\n // watchQueryOptions.fetchPolicy, which has now been properly\n // defaulted/initialized. However, watchQueryOptions.initialFetchPolicy\n // can be provided explicitly instead, if more control is desired.\n initialFetchPolicy = watchQueryOptions.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 }\n\n if (!watchQueryOptions.variables) {\n watchQueryOptions.variables = {} as TVariables;\n }\n\n return watchQueryOptions;\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({\n ...this.watchQueryOptions,\n });\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 if (this.renderPromises) {\n this.renderPromises.registerSSRObservable(obsQuery);\n\n const ssrAllowed = !(\n this.queryHookOptions.ssr === false ||\n this.queryHookOptions.skip\n );\n\n if (ssrAllowed && obsQuery.getCurrentResult().loading) {\n // TODO: This is a legacy API which could probably be cleaned up\n this.renderPromises.addObservableQueryPromise(obsQuery);\n }\n }\n\n return obsQuery;\n }\n\n // These members are populated by getCurrentResult and setResult, and it's\n // okay/normal for them to be initially undefined.\n private result: undefined | ApolloQueryResult<TData>;\n private previousData: undefined | TData;\n\n private setResult(nextResult: ApolloQueryResult<TData>) {\n const previousResult = this.result;\n if (previousResult && previousResult.data) {\n this.previousData = previousResult.data;\n }\n this.result = nextResult;\n // Calling state.setResult always triggers an update, though some call sites\n // perform additional equality checks before committing to an update.\n this.forceUpdate();\n this.handleErrorOrCompleted(nextResult);\n }\n\n private handleErrorOrCompleted(result: ApolloQueryResult<TData>) {\n if (!result.loading) {\n if (result.error) {\n this.onError(result.error);\n } else if (result.data) {\n this.onCompleted(result.data);\n }\n }\n }\n\n private getCurrentResult(): ApolloQueryResult<TData> {\n // Using this.result as a cache ensures getCurrentResult continues returning\n // the same (===) result object, unless state.setResult has been called, or\n // we're doing server rendering and therefore override the result below.\n if (!this.result) {\n this.handleErrorOrCompleted(\n this.result = this.observable.getCurrentResult()\n );\n }\n return this.result;\n }\n\n // This cache allows the referential stability of this.result (as returned by\n // getCurrentResult) to translate into referential stability of the resulting\n // QueryResult object returned by toQueryResult.\n private toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)<\n ApolloQueryResult<TData>,\n QueryResult<TData, TVariables>\n >();\n\n toQueryResult(\n result: ApolloQueryResult<TData>,\n ): QueryResult<TData, TVariables> {\n let queryResult = this.toQueryResultCache.get(result);\n if (queryResult) return queryResult;\n\n const { data, partial, ...resultWithoutPartial } = result;\n this.toQueryResultCache.set(result, queryResult = {\n data, // Ensure always defined, even if result.data is missing.\n ...resultWithoutPartial,\n ...this.obsQueryFields,\n client: this.client,\n observable: this.observable,\n variables: this.observable.variables,\n called: true,\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/parser/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EAEZ,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,oBAAY,YAAY;IACtB,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,YAAY,IAAA;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAClD;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,UAc/C;AAGD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/parser/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EAEZ,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,oBAAY,YAAY;IACtB,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,YAAY,IAAA;CACb;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAClD;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,UAc/C;AAGD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,mBAAmB,CAkFlE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,QAS5E"}
|
package/react/parser/index.js
CHANGED
|
@@ -29,16 +29,30 @@ export function parser(document) {
|
|
|
29
29
|
__DEV__ ? invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
30
30
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
31
31
|
"to convert your operation into a document") : invariant(!!document && !!document.kind, 30);
|
|
32
|
-
var fragments =
|
|
33
|
-
var queries =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
var fragments = [];
|
|
33
|
+
var queries = [];
|
|
34
|
+
var mutations = [];
|
|
35
|
+
var subscriptions = [];
|
|
36
|
+
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
|
|
37
|
+
var x = _a[_i];
|
|
38
|
+
if (x.kind === 'FragmentDefinition') {
|
|
39
|
+
fragments.push(x);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (x.kind === 'OperationDefinition') {
|
|
43
|
+
switch (x.operation) {
|
|
44
|
+
case 'query':
|
|
45
|
+
queries.push(x);
|
|
46
|
+
break;
|
|
47
|
+
case 'mutation':
|
|
48
|
+
mutations.push(x);
|
|
49
|
+
break;
|
|
50
|
+
case 'subscription':
|
|
51
|
+
subscriptions.push(x);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
__DEV__ ? invariant(!fragments.length ||
|
|
43
57
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
44
58
|
"You must include a query, subscription or mutation as well") : invariant(!fragments.length ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,iDAAK,CAAA;IACL,uDAAQ,CAAA;IACR,+DAAY,CAAA;AACd,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAQD,IAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;AAExB,MAAM,UAAU,aAAa,CAAC,IAAkB;IAC9C,IAAI,IAAI,CAAC;IACT,QAAQ,IAAI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AC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAsB,EAAE,IAAkB;IAC3E,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAM,qBAAqB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,IAAM,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACP,SAAS,CAAC,IAAI,KAAK,IAAI,EACvB,oBAAa,qBAAqB,yBAAsB;QACtD,UAAG,qBAAqB,qBAAW,iBAAiB,uBAAoB,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\n\nimport {\n DocumentNode,\n DefinitionNode,\n VariableDefinitionNode,\n OperationDefinitionNode\n} from 'graphql';\n\nexport enum DocumentType {\n Query,\n Mutation,\n Subscription\n}\n\nexport interface IDocumentDefinition {\n type: DocumentType;\n name: string;\n variables: ReadonlyArray<VariableDefinitionNode>;\n}\n\nconst cache = new Map();\n\nexport function operationName(type: DocumentType) {\n let name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\n\n// This parser is mostly used to safety check incoming documents.\nexport function parser(document: DocumentNode): IDocumentDefinition {\n const cached = cache.get(document);\n if (cached) return cached;\n\n let variables, type, name;\n\n invariant(\n !!document && !!document.kind,\n `Argument of ${document} passed to parser was not a valid GraphQL ` +\n `DocumentNode. You may need to use 'graphql-tag' or another method ` +\n `to convert your operation into a document`\n );\n\n const fragments: DefinitionNode[] = []\n const queries: DefinitionNode[] = []\n const mutations: DefinitionNode[] = []\n const subscriptions: DefinitionNode[] = []\n\n for (const x of document.definitions) {\n if (x.kind === 'FragmentDefinition') {\n fragments.push(x);\n continue\n }\n\n if (x.kind === 'OperationDefinition') {\n switch (x.operation) {\n case 'query':\n queries.push(x);\n break;\n case 'mutation':\n mutations.push(x);\n break;\n case 'subscription':\n subscriptions.push(x);\n break;\n }\n }\n }\n\n invariant(\n !fragments.length ||\n (queries.length || mutations.length || subscriptions.length),\n `Passing only a fragment to 'graphql' is not yet supported. ` +\n `You must include a query, subscription or mutation as well`\n );\n\n invariant(\n queries.length + mutations.length + subscriptions.length <= 1,\n `react-apollo only supports a query, subscription, or a mutation per HOC. ` +\n `${document} had ${queries.length} queries, ${subscriptions.length} ` +\n `subscriptions and ${mutations.length} mutations. ` +\n `You can use 'compose' to join multiple operation types to a component`\n );\n\n type = queries.length ? DocumentType.Query : DocumentType.Mutation;\n if (!queries.length && !mutations.length) type = DocumentType.Subscription;\n\n const definitions = queries.length\n ? queries\n : mutations.length\n ? mutations\n : subscriptions;\n\n invariant(\n definitions.length === 1,\n `react-apollo only supports one definition per HOC. ${document} had ` +\n `${definitions.length} definitions. ` +\n `You can use 'compose' to join multiple operation types to a component`\n );\n\n const definition = definitions[0] as OperationDefinitionNode;\n variables = definition.variableDefinitions || [];\n\n if (definition.name && definition.name.kind === 'Name') {\n name = definition.name.value;\n } else {\n name = 'data'; // fallback to using data if no name\n }\n\n const payload = { name, type, variables };\n cache.set(document, payload);\n return payload;\n}\n\nexport function verifyDocumentType(document: DocumentNode, type: DocumentType) {\n const operation = parser(document);\n const requiredOperationName = operationName(type);\n const usedOperationName = operationName(operation.type);\n invariant(\n operation.type === type,\n `Running a ${requiredOperationName} requires a graphql ` +\n `${requiredOperationName}, but a ${usedOperationName} was used instead.`\n );\n}\n\n"]}
|
package/react/parser/parser.cjs
CHANGED
|
@@ -34,16 +34,30 @@ function parser(document) {
|
|
|
34
34
|
__DEV__ ? globals.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
35
35
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
36
36
|
"to convert your operation into a document") : globals.invariant(!!document && !!document.kind, 30);
|
|
37
|
-
var fragments =
|
|
38
|
-
var queries =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
var fragments = [];
|
|
38
|
+
var queries = [];
|
|
39
|
+
var mutations = [];
|
|
40
|
+
var subscriptions = [];
|
|
41
|
+
for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
|
|
42
|
+
var x = _a[_i];
|
|
43
|
+
if (x.kind === 'FragmentDefinition') {
|
|
44
|
+
fragments.push(x);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (x.kind === 'OperationDefinition') {
|
|
48
|
+
switch (x.operation) {
|
|
49
|
+
case 'query':
|
|
50
|
+
queries.push(x);
|
|
51
|
+
break;
|
|
52
|
+
case 'mutation':
|
|
53
|
+
mutations.push(x);
|
|
54
|
+
break;
|
|
55
|
+
case 'subscription':
|
|
56
|
+
subscriptions.push(x);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
47
61
|
__DEV__ ? globals.invariant(!fragments.length ||
|
|
48
62
|
(queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
|
|
49
63
|
"You must include a query, subscription or mutation as well") : globals.invariant(!fragments.length ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n __DEV__ ? invariant(!!document && !!document.kind, \"Argument of \".concat(document, \" passed to parser was not a valid GraphQL \") +\n \"DocumentNode. You may need to use 'graphql-tag' or another method \" +\n \"to convert your operation into a document\") : invariant(!!document && !!document.kind, 30);\n var fragments =
|
|
1
|
+
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n __DEV__ ? invariant(!!document && !!document.kind, \"Argument of \".concat(document, \" passed to parser was not a valid GraphQL \") +\n \"DocumentNode. You may need to use 'graphql-tag' or another method \" +\n \"to convert your operation into a document\") : invariant(!!document && !!document.kind, 30);\n var fragments = [];\n var queries = [];\n var mutations = [];\n var subscriptions = [];\n for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {\n var x = _a[_i];\n if (x.kind === 'FragmentDefinition') {\n fragments.push(x);\n continue;\n }\n if (x.kind === 'OperationDefinition') {\n switch (x.operation) {\n case 'query':\n queries.push(x);\n break;\n case 'mutation':\n mutations.push(x);\n break;\n case 'subscription':\n subscriptions.push(x);\n break;\n }\n }\n }\n __DEV__ ? invariant(!fragments.length ||\n (queries.length || mutations.length || subscriptions.length), \"Passing only a fragment to 'graphql' is not yet supported. \" +\n \"You must include a query, subscription or mutation as well\") : invariant(!fragments.length ||\n (queries.length || mutations.length || subscriptions.length), 31);\n __DEV__ ? invariant(queries.length + mutations.length + subscriptions.length <= 1, \"react-apollo only supports a query, subscription, or a mutation per HOC. \" +\n \"\".concat(document, \" had \").concat(queries.length, \" queries, \").concat(subscriptions.length, \" \") +\n \"subscriptions and \".concat(mutations.length, \" mutations. \") +\n \"You can use 'compose' to join multiple operation types to a component\") : invariant(queries.length + mutations.length + subscriptions.length <= 1, 32);\n type = queries.length ? DocumentType.Query : DocumentType.Mutation;\n if (!queries.length && !mutations.length)\n type = DocumentType.Subscription;\n var definitions = queries.length\n ? queries\n : mutations.length\n ? mutations\n : subscriptions;\n __DEV__ ? invariant(definitions.length === 1, \"react-apollo only supports one definition per HOC. \".concat(document, \" had \") +\n \"\".concat(definitions.length, \" definitions. \") +\n \"You can use 'compose' to join multiple operation types to a component\") : invariant(definitions.length === 1, 33);\n var definition = definitions[0];\n variables = definition.variableDefinitions || [];\n if (definition.name && definition.name.kind === 'Name') {\n name = definition.name.value;\n }\n else {\n name = 'data';\n }\n var payload = { name: name, type: type, variables: variables };\n cache.set(document, payload);\n return payload;\n}\nexport function verifyDocumentType(document, type) {\n var operation = parser(document);\n var requiredOperationName = operationName(type);\n var usedOperationName = operationName(operation.type);\n __DEV__ ? invariant(operation.type === type, \"Running a \".concat(requiredOperationName, \" requires a graphql \") +\n \"\".concat(requiredOperationName, \", but a \").concat(usedOperationName, \" was used instead.\")) : invariant(operation.type === type, 34);\n}\n//# sourceMappingURL=index.js.map"],"names":["DocumentType","invariant"],"mappings":";;;;;;AACWA,8BAAa;AACxB,CAAC,UAAU,YAAY,EAAE;AACzB,IAAI,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;AACtD,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,YA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