@apollo/client 3.3.9 → 3.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/apollo-client.cjs.js +34 -28
  3. package/apollo-client.cjs.js.map +1 -1
  4. package/apollo-client.cjs.min.js +1 -1
  5. package/core/ObservableQuery.d.ts.map +1 -1
  6. package/core/ObservableQuery.js +0 -1
  7. package/core/ObservableQuery.js.map +1 -1
  8. package/core/QueryInfo.d.ts +1 -0
  9. package/core/QueryInfo.d.ts.map +1 -1
  10. package/core/QueryInfo.js +7 -2
  11. package/core/QueryInfo.js.map +1 -1
  12. package/core/QueryManager.d.ts.map +1 -1
  13. package/core/QueryManager.js +1 -0
  14. package/core/QueryManager.js.map +1 -1
  15. package/core/core.cjs.js +9 -4
  16. package/core/core.cjs.js.map +1 -1
  17. package/invariantErrorCodes.js +1 -1
  18. package/link/http/createHttpLink.d.ts.map +1 -1
  19. package/link/http/createHttpLink.js +1 -1
  20. package/link/http/createHttpLink.js.map +1 -1
  21. package/link/http/http.cjs.js +1 -2
  22. package/link/http/http.cjs.js.map +1 -1
  23. package/package.json +18 -19
  24. package/react/data/MutationData.d.ts +1 -1
  25. package/react/data/MutationData.d.ts.map +1 -1
  26. package/react/data/MutationData.js.map +1 -1
  27. package/react/data/QueryData.d.ts +2 -2
  28. package/react/data/QueryData.d.ts.map +1 -1
  29. package/react/data/QueryData.js.map +1 -1
  30. package/react/data/SubscriptionData.d.ts.map +1 -1
  31. package/react/data/SubscriptionData.js +2 -1
  32. package/react/data/SubscriptionData.js.map +1 -1
  33. package/react/data/data.cjs.js +2 -1
  34. package/react/data/data.cjs.js.map +1 -1
  35. package/react/hooks/hooks.cjs.js +11 -18
  36. package/react/hooks/hooks.cjs.js.map +1 -1
  37. package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
  38. package/react/hooks/utils/useBaseQuery.js +11 -18
  39. package/react/hooks/utils/useBaseQuery.js.map +1 -1
  40. package/react/types/types.d.ts +1 -0
  41. package/react/types/types.d.ts.map +1 -1
  42. package/react/types/types.js.map +1 -1
  43. package/testing/testing.cjs.js +12 -4
  44. package/testing/testing.cjs.js.map +1 -1
  45. package/utilities/graphql/transform.js.map +1 -1
  46. package/utilities/observables/Observable.d.ts +0 -5
  47. package/utilities/observables/Observable.d.ts.map +1 -1
  48. package/utilities/observables/Observable.js +5 -1
  49. package/utilities/observables/Observable.js.map +1 -1
  50. package/utilities/observables/asyncMap.d.ts.map +1 -1
  51. package/utilities/observables/asyncMap.js +11 -3
  52. package/utilities/observables/asyncMap.js.map +1 -1
  53. package/utilities/testing/mocking/MockedProvider.d.ts +1 -1
  54. package/utilities/testing/mocking/MockedProvider.d.ts.map +1 -1
  55. package/utilities/testing/mocking/MockedProvider.js +1 -1
  56. package/utilities/testing/mocking/MockedProvider.js.map +1 -1
  57. package/utilities/utilities.cjs.js +11 -3
  58. package/utilities/utilities.cjs.js.map +1 -1
  59. package/version.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,UAAU,EAGV,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoB1C,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAEnC;IAGU,mCAAoC;IAqB5C,yBAAY,EAQX;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA;QAHT,YASE,kBAAM,UAAC,QAA4C;YACjD,OAA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CAAC,eAAe,CAAC,CAAC;AAEvC,SAAS,wCAAwC,CAAC,KAAkB;IAClE,SAAS,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { invariant } from 'ts-invariant';\nimport { equal } from '@wry/equality';\n\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport {\n cloneDeep,\n getOperationDefinition,\n Observable,\n Observer,\n ObservableSubscription,\n iterateObserversSafely,\n isNonEmptyArray,\n fixObservableSubclass,\n} from '../utilities';\nimport { ApolloError } from '../errors';\nimport { QueryManager } from './QueryManager';\nimport { ApolloQueryResult, OperationVariables } from './types';\nimport {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from './watchQueryOptions';\nimport { Reobserver } from './Reobserver';\nimport { QueryInfo } from './QueryInfo';\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n },\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\nlet warnedAboutUpdateQuery = false;\n\nexport class ObservableQuery<\n TData = any,\n TVariables = OperationVariables\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private lastResult: ApolloQueryResult<TData>;\n private lastResultSnapshot: ApolloQueryResult<TData>;\n private lastError: ApolloError;\n private queryInfo: QueryInfo;\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) =>\n this.onSubscribe(observer),\n );\n\n // active state\n this.isTornDown = false;\n\n // query information\n this.options = options;\n this.queryId = queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(options.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n\n // related classes\n this.queryManager = queryManager;\n\n this.queryInfo = queryInfo;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n const { lastResult } = this;\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result: ApolloQueryResult<TData> = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n };\n\n if (this.isTornDown) {\n return result;\n }\n\n const { fetchPolicy = 'cache-first' } = this.options;\n if (fetchPolicy === 'no-cache' ||\n fetchPolicy === 'network-only') {\n // Similar to setting result.partial to false, but taking advantage\n // of the falsiness of missing fields.\n delete result.partial;\n } else if (\n !result.data ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust result.data, since it was read from the cache without\n // running local resolvers (and it's too late to run resolvers now,\n // since we must return a result synchronously). TODO In the future\n // (after Apollo Client 3.0), we should find a way to trust\n // this.lastResult in more cases, and read from the cache only in\n // cases when no result has been received yet.\n !this.queryManager.transform(this.options.query).hasForcedResolvers\n ) {\n const diff = this.queryInfo.getDiff();\n result.data = (\n diff.complete ||\n this.options.returnPartialData\n ) ? diff.result : void 0;\n if (diff.complete) {\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next\n // result we receive will have NetworkStatus.ready and !loading.\n if (result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === 'cache-first' ||\n fetchPolicy === 'cache-only')) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n delete result.partial;\n } else {\n result.partial = true;\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(newResult: ApolloQueryResult<TData>) {\n return !equal(this.lastResultSnapshot, newResult);\n }\n\n // Returns the last result that observer.next was called with. This is not the same as\n // getCurrentResult! If you're not sure which you need, then you probably need getCurrentResult.\n public getLastResult(): ApolloQueryResult<TData> {\n return this.lastResult;\n }\n\n public getLastError(): ApolloError {\n return this.lastError;\n }\n\n public resetLastResults(): void {\n delete this.lastResult;\n delete this.lastResultSnapshot;\n delete this.lastError;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(variables?: Partial<TVariables>): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'cache-and-network') {\n reobserveOptions.fetchPolicy = 'network-only';\n // Go back to the original options.fetchPolicy after this refetch.\n reobserveOptions.nextFetchPolicy = fetchPolicy || \"cache-first\";\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n return this.newReobserver(false).reobserve(\n reobserveOptions,\n NetworkStatus.refetch,\n );\n }\n\n public fetchMore<K extends keyof TVariables>(\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, K, TData> &\n FetchMoreOptions<TData, TVariables>,\n ): Promise<ApolloQueryResult<TData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : {\n ...this.options,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions;\n\n const qid = this.queryManager.generateQueryId();\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.queryInfo.networkStatus = NetworkStatus.fetchMore;\n this.observe();\n }\n\n return this.queryManager.fetchQuery(\n qid,\n combinedOptions,\n NetworkStatus.fetchMore,\n ).then(fetchMoreResult => {\n const data = fetchMoreResult.data as TData;\n const { updateQuery } = fetchMoreOptions;\n\n if (updateQuery) {\n if (process.env.NODE_ENV !== \"production\" &&\n !warnedAboutUpdateQuery) {\n invariant.warn(\n`The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore.`);\n warnedAboutUpdateQuery = true;\n }\n this.updateQuery(previous => updateQuery(previous, {\n fetchMoreResult: data,\n variables: combinedOptions.variables as TVariables,\n }));\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n this.queryManager.cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data,\n });\n }\n\n return fetchMoreResult as ApolloQueryResult<TData>;\n\n }).finally(() => {\n this.queryManager.stopQuery(qid);\n this.reobserve();\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >,\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n }),\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error('Unhandled GraphQL subscription error', err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>,\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n /**\n * This is for *internal* use only. Most users should instead use `refetch`\n * in order to be properly notified of results even when they come from cache.\n *\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. If you want to force new results, use `refetch`.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n *\n * @param tryFetch: Try and fetch new results even if the variables haven't\n * changed (we may still just hit the store, but if there's nothing in there\n * this will refetch)\n */\n public setVariables(\n variables: TVariables,\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size\n ? this.result()\n : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n let { fetchPolicy = 'cache-first' } = this.options;\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n fetchPolicy,\n variables,\n };\n\n if (fetchPolicy !== 'cache-first' &&\n fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'network-only') {\n reobserveOptions.fetchPolicy = 'cache-and-network';\n reobserveOptions.nextFetchPolicy = fetchPolicy;\n }\n\n return this.reobserve(\n reobserveOptions,\n NetworkStatus.setVariables,\n );\n }\n\n public updateQuery<TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">,\n ) => TData,\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n previousResult: this.lastResult?.data,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.getReobserver().updateOptions({ pollInterval });\n }\n\n public stopPolling() {\n if (this.reobserver) {\n this.reobserver.updateOptions({ pollInterval: 0 });\n }\n }\n\n private updateLastResult(newResult: ApolloQueryResult<TData>) {\n const previousResult = this.lastResult;\n this.lastResult = newResult;\n this.lastResultSnapshot = this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult);\n if (!isNonEmptyArray(newResult.errors)) {\n delete this.lastError;\n }\n return previousResult;\n }\n\n private onSubscribe(observer: Observer<ApolloQueryResult<TData>>) {\n // Subscribing using this.observer will create an infinite notificaion\n // loop, but the intent of broadcasting results to all the other\n // this.observers can be satisfied without doing anything, which is\n // why we do not bother throwing an error here.\n if (observer === this.observer) {\n return () => {};\n }\n\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n if (this.lastError) {\n observer.error && observer.error(this.lastError);\n } else if (this.lastResult) {\n observer.next && observer.next(this.lastResult);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n this.reobserve().catch(_ => {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n });\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n }\n\n private reobserver?: Reobserver<TData, TVariables>;\n\n private getReobserver(): Reobserver<TData, TVariables> {\n return this.reobserver || (this.reobserver = this.newReobserver(true));\n }\n\n private newReobserver(shareOptions: boolean) {\n const { queryManager, queryId } = this;\n queryManager.setObservableQuery(this);\n return new Reobserver<TData, TVariables>(\n this.observer,\n // Sharing options allows this.reobserver.options to be ===\n // this.options, so we don't have to worry about synchronizing the\n // properties of two distinct objects.\n shareOptions ? this.options : { ...this.options },\n (currentOptions, newNetworkStatus) => {\n queryManager.setObservableQuery(this);\n return queryManager.fetchQueryObservable(\n queryId,\n currentOptions,\n newNetworkStatus,\n );\n },\n // Avoid polling during SSR and when the query is already in flight.\n !queryManager.ssrMode && (\n () => !isNetworkRequestInFlight(this.queryInfo.networkStatus))\n );\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus,\n ): Promise<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n return this.getReobserver().reobserve(newOptions, newNetworkStatus);\n }\n\n // Pass the current result to this.observer.next without applying any\n // fetch policies, bypassing the Reobserver.\n private observe() {\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.observer.next.\n this.observer.next(this.getCurrentResult(false));\n }\n\n private observer = {\n next: (result: ApolloQueryResult<TData>) => {\n if (this.lastError || this.isDifferentFromLastResult(result)) {\n this.updateLastResult(result);\n iterateObserversSafely(this.observers, 'next', result);\n }\n },\n\n error: (error: ApolloError) => {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n this.updateLastResult({\n ...this.lastResult,\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n });\n\n iterateObserversSafely(this.observers, 'error', this.lastError = error);\n },\n };\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n\n if (this.reobserver) {\n this.reobserver.stop();\n delete this.reobserver;\n }\n\n // Since the user-provided context object can retain arbitrarily large\n // amounts of memory, we delete it when the ObservableQuery is torn\n // down, to avoid the possibility of memory leaks.\n delete this.options.context;\n\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach(sub => sub.unsubscribe());\n this.subscriptions.clear();\n\n this.queryManager.stopQuery(this.queryId);\n\n this.observers.clear();\n\n this.isTornDown = true;\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error('Unhandled error', error.message, error.stack);\n}\n"]}
1
+ {"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,UAAU,EAGV,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoB1C,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAEnC;IAGU,mCAAoC;IAqB5C,yBAAY,EAQX;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA;QAHT,YASE,kBAAM,UAAC,QAA4C;YACjD,OAAA,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;QAA1B,CAA0B,CAC3B,SAgBF;QAnCO,eAAS,GAAG,IAAI,GAAG,EAAsC,CAAC;QAC1D,mBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QA2hBlD,cAAQ,GAAG;YACjB,IAAI,EAAE,UAAC,MAAgC;gBACrC,IAAI,KAAI,CAAC,SAAS,IAAI,KAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE;oBAC5D,KAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;oBAC9B,sBAAsB,CAAC,KAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;iBACxD;YACH,CAAC;YAED,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,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;IAyBM,sCAAY,GAAnB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;IACjC,CAAC;IAEO,uCAAa,GAArB;QACE,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAE5B,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,UAAU,CAAC;SACxB;QAGD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,EAAE,EAAjB,CAAiB,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAE3B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAEvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IACH,sBAAC;AAAD,CAAC,AAzlBD,CAGU,UAAU,GAslBnB;;AAID,qBAAqB,CAAC,eAAe,CAAC,CAAC;AAEvC,SAAS,wCAAwC,CAAC,KAAkB;IAClE,SAAS,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { invariant } from 'ts-invariant';\nimport { equal } from '@wry/equality';\n\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport {\n cloneDeep,\n getOperationDefinition,\n Observable,\n Observer,\n ObservableSubscription,\n iterateObserversSafely,\n isNonEmptyArray,\n fixObservableSubclass,\n} from '../utilities';\nimport { ApolloError } from '../errors';\nimport { QueryManager } from './QueryManager';\nimport { ApolloQueryResult, OperationVariables } from './types';\nimport {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from './watchQueryOptions';\nimport { Reobserver } from './Reobserver';\nimport { QueryInfo } from './QueryInfo';\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n },\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\nlet warnedAboutUpdateQuery = false;\n\nexport class ObservableQuery<\n TData = any,\n TVariables = OperationVariables\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private lastResult: ApolloQueryResult<TData>;\n private lastResultSnapshot: ApolloQueryResult<TData>;\n private lastError: ApolloError;\n private queryInfo: QueryInfo;\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) =>\n this.onSubscribe(observer),\n );\n\n // active state\n this.isTornDown = false;\n\n // query information\n this.options = options;\n this.queryId = queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(options.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n\n // related classes\n this.queryManager = queryManager;\n\n this.queryInfo = queryInfo;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n const { lastResult } = this;\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result: ApolloQueryResult<TData> = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n };\n\n if (this.isTornDown) {\n return result;\n }\n\n const { fetchPolicy = 'cache-first' } = this.options;\n if (fetchPolicy === 'no-cache' ||\n fetchPolicy === 'network-only') {\n // Similar to setting result.partial to false, but taking advantage\n // of the falsiness of missing fields.\n delete result.partial;\n } else if (\n !result.data ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust result.data, since it was read from the cache without\n // running local resolvers (and it's too late to run resolvers now,\n // since we must return a result synchronously). TODO In the future\n // (after Apollo Client 3.0), we should find a way to trust\n // this.lastResult in more cases, and read from the cache only in\n // cases when no result has been received yet.\n !this.queryManager.transform(this.options.query).hasForcedResolvers\n ) {\n const diff = this.queryInfo.getDiff();\n result.data = (\n diff.complete ||\n this.options.returnPartialData\n ) ? diff.result : void 0;\n if (diff.complete) {\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next\n // result we receive will have NetworkStatus.ready and !loading.\n if (result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === 'cache-first' ||\n fetchPolicy === 'cache-only')) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n delete result.partial;\n } else {\n result.partial = true;\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(newResult: ApolloQueryResult<TData>) {\n return !equal(this.lastResultSnapshot, newResult);\n }\n\n // Returns the last result that observer.next was called with. This is not the same as\n // getCurrentResult! If you're not sure which you need, then you probably need getCurrentResult.\n public getLastResult(): ApolloQueryResult<TData> {\n return this.lastResult;\n }\n\n public getLastError(): ApolloError {\n return this.lastError;\n }\n\n public resetLastResults(): void {\n delete this.lastResult;\n delete this.lastResultSnapshot;\n delete this.lastError;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(variables?: Partial<TVariables>): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'cache-and-network') {\n reobserveOptions.fetchPolicy = 'network-only';\n // Go back to the original options.fetchPolicy after this refetch.\n reobserveOptions.nextFetchPolicy = fetchPolicy || \"cache-first\";\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n return this.newReobserver(false).reobserve(\n reobserveOptions,\n NetworkStatus.refetch,\n );\n }\n\n public fetchMore<K extends keyof TVariables>(\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, K, TData> &\n FetchMoreOptions<TData, TVariables>,\n ): Promise<ApolloQueryResult<TData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : {\n ...this.options,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions;\n\n const qid = this.queryManager.generateQueryId();\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.queryInfo.networkStatus = NetworkStatus.fetchMore;\n this.observe();\n }\n\n return this.queryManager.fetchQuery(\n qid,\n combinedOptions,\n NetworkStatus.fetchMore,\n ).then(fetchMoreResult => {\n const data = fetchMoreResult.data as TData;\n const { updateQuery } = fetchMoreOptions;\n\n if (updateQuery) {\n if (process.env.NODE_ENV !== \"production\" &&\n !warnedAboutUpdateQuery) {\n invariant.warn(\n`The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore.`);\n warnedAboutUpdateQuery = true;\n }\n this.updateQuery(previous => updateQuery(previous, {\n fetchMoreResult: data,\n variables: combinedOptions.variables as TVariables,\n }));\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n this.queryManager.cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data,\n });\n }\n\n return fetchMoreResult as ApolloQueryResult<TData>;\n\n }).finally(() => {\n this.queryManager.stopQuery(qid);\n this.reobserve();\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >,\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n }),\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error('Unhandled GraphQL subscription error', err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>,\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n /**\n * This is for *internal* use only. Most users should instead use `refetch`\n * in order to be properly notified of results even when they come from cache.\n *\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. If you want to force new results, use `refetch`.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n *\n * @param tryFetch: Try and fetch new results even if the variables haven't\n * changed (we may still just hit the store, but if there's nothing in there\n * this will refetch)\n */\n public setVariables(\n variables: TVariables,\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size\n ? this.result()\n : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n let { fetchPolicy = 'cache-first' } = this.options;\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n fetchPolicy,\n variables,\n };\n\n if (fetchPolicy !== 'cache-first' &&\n fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'network-only') {\n reobserveOptions.fetchPolicy = 'cache-and-network';\n reobserveOptions.nextFetchPolicy = fetchPolicy;\n }\n\n return this.reobserve(\n reobserveOptions,\n NetworkStatus.setVariables,\n );\n }\n\n public updateQuery<TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">,\n ) => TData,\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n previousResult: this.lastResult?.data,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.getReobserver().updateOptions({ pollInterval });\n }\n\n public stopPolling() {\n if (this.reobserver) {\n this.reobserver.updateOptions({ pollInterval: 0 });\n }\n }\n\n private updateLastResult(newResult: ApolloQueryResult<TData>) {\n const previousResult = this.lastResult;\n this.lastResult = newResult;\n this.lastResultSnapshot = this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult);\n if (!isNonEmptyArray(newResult.errors)) {\n delete this.lastError;\n }\n return previousResult;\n }\n\n private onSubscribe(observer: Observer<ApolloQueryResult<TData>>) {\n // Subscribing using this.observer will create an infinite notificaion\n // loop, but the intent of broadcasting results to all the other\n // this.observers can be satisfied without doing anything, which is\n // why we do not bother throwing an error here.\n if (observer === this.observer) {\n return () => {};\n }\n\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n if (this.lastError) {\n observer.error && observer.error(this.lastError);\n } else if (this.lastResult) {\n observer.next && observer.next(this.lastResult);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n this.reobserve().catch(_ => {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n });\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n }\n\n private reobserver?: Reobserver<TData, TVariables>;\n\n private getReobserver(): Reobserver<TData, TVariables> {\n return this.reobserver || (this.reobserver = this.newReobserver(true));\n }\n\n private newReobserver(shareOptions: boolean) {\n const { queryManager, queryId } = this;\n queryManager.setObservableQuery(this);\n return new Reobserver<TData, TVariables>(\n this.observer,\n // Sharing options allows this.reobserver.options to be ===\n // this.options, so we don't have to worry about synchronizing the\n // properties of two distinct objects.\n shareOptions ? this.options : { ...this.options },\n (currentOptions, newNetworkStatus) => {\n queryManager.setObservableQuery(this);\n return queryManager.fetchQueryObservable(\n queryId,\n currentOptions,\n newNetworkStatus,\n );\n },\n // Avoid polling during SSR and when the query is already in flight.\n !queryManager.ssrMode && (\n () => !isNetworkRequestInFlight(this.queryInfo.networkStatus))\n );\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus,\n ): Promise<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n return this.getReobserver().reobserve(newOptions, newNetworkStatus);\n }\n\n // Pass the current result to this.observer.next without applying any\n // fetch policies, bypassing the Reobserver.\n private observe() {\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.observer.next.\n this.observer.next(this.getCurrentResult(false));\n }\n\n private observer = {\n next: (result: ApolloQueryResult<TData>) => {\n if (this.lastError || this.isDifferentFromLastResult(result)) {\n this.updateLastResult(result);\n iterateObserversSafely(this.observers, 'next', result);\n }\n },\n\n error: (error: ApolloError) => {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n this.updateLastResult({\n ...this.lastResult,\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n });\n\n iterateObserversSafely(this.observers, 'error', this.lastError = error);\n },\n };\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n\n if (this.reobserver) {\n this.reobserver.stop();\n delete this.reobserver;\n }\n\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach(sub => sub.unsubscribe());\n this.subscriptions.clear();\n\n this.queryManager.stopQuery(this.queryId);\n\n this.observers.clear();\n\n this.isTornDown = true;\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error('Unhandled error', error.message, error.stack);\n}\n"]}
@@ -30,6 +30,7 @@ export declare class QueryInfo {
30
30
  private dirty;
31
31
  private notifyTimeout?;
32
32
  private diff;
33
+ reset(): void;
33
34
  getDiff(variables?: Record<string, any> | undefined): Cache.DiffResult<any>;
34
35
  setDiff(diff: Cache.DiffResult<any> | null): void;
35
36
  readonly observableQuery: ObservableQuery<any> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryInfo.d.ts","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,EAAE,KAAK,EA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,GAAG,IAAI;IAY1C,SAAgB,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IACpE,OAAO,CAAC,UAAU,CAAC,CAAgB;IAEnC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI;IA4BlD,MAAM;IAUN,OAAO,CAAC,YAAY;IAiBb,IAAI;IAkBX,OAAO,CAAC,MAAM;IAEd,OAAO,CAAC,SAAS,CAAC,CAAqB;IAEvC,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,SAAS,CAAC,CAIhB;IAEF,OAAO,CAAC,WAAW;IAgBZ,UAAU,CAAC,CAAC,EACjB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAC3B,WAAW,GACX,aAAa,GACb,aAAa,CAAC,EAClB,eAAe,EAAE,OAAO;IA0GnB,SAAS;IAKT,SAAS,CAAC,KAAK,EAAE,WAAW;CAgBpC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EACtB,WAAW,GAAE,WAAoB,WAUlC"}
package/core/QueryInfo.js CHANGED
@@ -60,6 +60,11 @@ var QueryInfo = (function () {
60
60
  }
61
61
  return this;
62
62
  };
63
+ QueryInfo.prototype.reset = function () {
64
+ cancelNotifyTimeout(this);
65
+ this.diff = null;
66
+ this.dirty = false;
67
+ };
63
68
  QueryInfo.prototype.getDiff = function (variables) {
64
69
  if (variables === void 0) { variables = this.variables; }
65
70
  if (this.diff && equal(variables, this.variables)) {
@@ -171,7 +176,7 @@ var QueryInfo = (function () {
171
176
  QueryInfo.prototype.markResult = function (result, options, allowCacheWrite) {
172
177
  var _this = this;
173
178
  this.graphQLErrors = isNonEmptyArray(result.errors) ? result.errors : [];
174
- cancelNotifyTimeout(this);
179
+ this.reset();
175
180
  if (options.fetchPolicy === 'no-cache') {
176
181
  this.diff = { result: result.data, complete: true };
177
182
  }
@@ -223,7 +228,7 @@ var QueryInfo = (function () {
223
228
  QueryInfo.prototype.markError = function (error) {
224
229
  this.networkStatus = NetworkStatus.error;
225
230
  this.lastWrite = void 0;
226
- cancelNotifyTimeout(this);
231
+ this.reset();
227
232
  if (error.graphQLErrors) {
228
233
  this.graphQLErrors = error.graphQLErrors;
229
234
  }
@@ -1 +1 @@
1
- {"version":3,"file":"QueryInfo.js","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAOtC,OAAO,EAEL,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAUzB,IAAM,uBAAuB,GAAG,IAAI,CAClC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAC9B,EAA4B,CAAC;AAE9B,SAAS,0BAA0B,CACjC,KAAuB,EACvB,UAAkC;IAElC,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAClC,KAAK,CAAC,UAAU,CAAC,GAAG;YAClB,uBAAuB,CAAC,GAAG,CACzB,KAAK,EAKL,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CACjD,CAAC;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC,CAAC;KACH;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAe;IAC1C,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE;QACzB,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC,CAAC;KAChC;AACH,CAAC;AAcD;I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AAC;QACzC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;QAExB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAE1B,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;SAC1C;QAED,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;SACxC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gBAAC;AAAD,CAAC,AAhWD,IAgWC;;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,WAAiC;IAAjC,4BAAA,EAAA,oBAAiC;IAEjC,IAAM,YAAY,GAChB,WAAW,KAAK,QAAQ;QACxB,WAAW,KAAK,KAAK,CAAC;IACxB,IAAI,eAAe,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,EAAE;QACnD,eAAe,GAAG,IAAI,CAAC;KACxB;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { DocumentNode, GraphQLError } from 'graphql';\nimport { equal } from \"@wry/equality\";\n\nimport { Cache, ApolloCache } from '../cache';\nimport { WatchQueryOptions, ErrorPolicy } from './watchQueryOptions';\nimport { ObservableQuery } from './ObservableQuery';\nimport { QueryListener } from './types';\nimport { FetchResult } from '../link/core';\nimport {\n ObservableSubscription,\n isNonEmptyArray,\n graphQLResultHasError,\n canUseWeakMap,\n} from '../utilities';\nimport {\n NetworkStatus,\n isNetworkRequestInFlight,\n} from './networkStatus';\nimport { ApolloError } from '../errors';\n\nexport type QueryStoreValue = Pick<QueryInfo,\n | \"variables\"\n | \"networkStatus\"\n | \"networkError\"\n | \"graphQLErrors\"\n >;\n\nconst destructiveMethodCounts = new (\n canUseWeakMap ? WeakMap : Map\n)<ApolloCache<any>, number>();\n\nfunction wrapDestructiveCacheMethod(\n cache: ApolloCache<any>,\n methodName: keyof ApolloCache<any>,\n) {\n const original = cache[methodName];\n if (typeof original === \"function\") {\n cache[methodName] = function () {\n destructiveMethodCounts.set(\n cache,\n // The %1e15 allows the count to wrap around to 0 safely every\n // quadrillion evictions, so there's no risk of overflow. To be\n // clear, this is more of a pedantic principle than something\n // that matters in any conceivable practical scenario.\n (destructiveMethodCounts.get(cache)! + 1) % 1e15,\n );\n return original.apply(this, arguments);\n };\n }\n}\n\nfunction cancelNotifyTimeout(info: QueryInfo) {\n if (info[\"notifyTimeout\"]) {\n clearTimeout(info[\"notifyTimeout\"]);\n info[\"notifyTimeout\"] = void 0;\n }\n}\n\n// A QueryInfo object represents a single query managed by the\n// QueryManager, which tracks all QueryInfo objects by queryId in its\n// this.queries Map. QueryInfo objects store the latest results and errors\n// for the given query, and are responsible for reporting those results to\n// the corresponding ObservableQuery, via the QueryInfo.notify method.\n// Results are reported asynchronously whenever setDiff marks the\n// QueryInfo object as dirty, though a call to the QueryManager's\n// broadcastQueries method may trigger the notification before it happens\n// automatically. This class used to be a simple interface type without\n// any field privacy or meaningful methods, which is why it still has so\n// many public fields. The effort to lock down and simplify the QueryInfo\n// interface is ongoing, and further improvements are welcome.\nexport class QueryInfo {\n listeners = new Set<QueryListener>();\n document: DocumentNode | null = null;\n lastRequestId = 1;\n subscriptions = new Set<ObservableSubscription>();\n variables?: Record<string, any>;\n networkStatus?: NetworkStatus;\n networkError?: Error | null;\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n stopped = false;\n\n constructor(private cache: ApolloCache<any>) {\n // Track how often cache.evict is called, since we want eviction to\n // override the feud-stopping logic in the markResult method, by\n // causing shouldWrite to return true. Wrapping the cache.evict method\n // is a bit of a hack, but it saves us from having to make eviction\n // counting an official part of the ApolloCache API.\n if (!destructiveMethodCounts.has(cache)) {\n destructiveMethodCounts.set(cache, 0);\n wrapDestructiveCacheMethod(cache, \"evict\");\n wrapDestructiveCacheMethod(cache, \"modify\");\n wrapDestructiveCacheMethod(cache, \"reset\");\n }\n }\n\n public init(query: {\n document: DocumentNode;\n variables: Record<string, any> | undefined,\n // The initial networkStatus for this fetch, most often\n // NetworkStatus.loading, but also possibly fetchMore, poll, refetch,\n // or setVariables.\n networkStatus?: NetworkStatus,\n observableQuery?: ObservableQuery<any>;\n lastRequestId?: number;\n }): this {\n let networkStatus = query.networkStatus || NetworkStatus.loading;\n if (this.variables &&\n this.networkStatus !== NetworkStatus.loading &&\n !equal(this.variables, query.variables)) {\n networkStatus = NetworkStatus.setVariables;\n }\n\n if (!equal(query.variables, this.variables)) {\n this.diff = null;\n }\n\n Object.assign(this, {\n document: query.document,\n variables: query.variables,\n networkError: null,\n graphQLErrors: this.graphQLErrors || [],\n networkStatus,\n });\n\n if (query.observableQuery) {\n this.setObservableQuery(query.observableQuery);\n }\n\n if (query.lastRequestId) {\n this.lastRequestId = query.lastRequestId;\n }\n\n return this;\n }\n\n private dirty: boolean = false;\n\n private notifyTimeout?: ReturnType<typeof setTimeout>;\n\n private diff: Cache.DiffResult<any> | null = null;\n\n getDiff(variables = this.variables): Cache.DiffResult<any> {\n if (this.diff && equal(variables, this.variables)) {\n return this.diff;\n }\n\n this.updateWatch(this.variables = variables);\n\n return this.diff = this.cache.diff({\n query: this.document!,\n variables,\n returnPartialData: true,\n optimistic: true,\n });\n }\n\n setDiff(diff: Cache.DiffResult<any> | null) {\n const oldDiff = this.diff;\n this.diff = diff;\n if (!this.dirty &&\n (diff && diff.result) !== (oldDiff && oldDiff.result)) {\n this.dirty = true;\n if (!this.notifyTimeout) {\n this.notifyTimeout = setTimeout(() => this.notify(), 0);\n }\n }\n }\n\n public readonly observableQuery: ObservableQuery<any> | null = null;\n private oqListener?: QueryListener;\n\n setObservableQuery(oq: ObservableQuery<any> | null) {\n if (oq === this.observableQuery) return;\n\n if (this.oqListener) {\n this.listeners.delete(this.oqListener);\n }\n\n (this as any).observableQuery = oq;\n\n if (oq) {\n oq[\"queryInfo\"] = this;\n this.listeners.add(this.oqListener = () => {\n // If this.diff came from an optimistic transaction, deliver the\n // current cache data to the ObservableQuery, but don't perform a\n // full reobservation, since oq.reobserve might make a network\n // request, and we don't want to trigger network requests for\n // optimistic updates.\n if (this.getDiff().fromOptimisticTransaction) {\n oq[\"observe\"]();\n } else {\n oq.reobserve();\n }\n });\n } else {\n delete this.oqListener;\n }\n }\n\n notify() {\n cancelNotifyTimeout(this);\n\n if (this.shouldNotify()) {\n this.listeners.forEach(listener => listener(this));\n }\n\n this.dirty = false;\n }\n\n private shouldNotify() {\n if (!this.dirty || !this.listeners.size) {\n return false;\n }\n\n if (isNetworkRequestInFlight(this.networkStatus) &&\n this.observableQuery) {\n const { fetchPolicy } = this.observableQuery.options;\n if (fetchPolicy !== \"cache-only\" &&\n fetchPolicy !== \"cache-and-network\") {\n return false;\n }\n }\n\n return true;\n }\n\n public stop() {\n if (!this.stopped) {\n this.stopped = true;\n\n this.cancel();\n // Revert back to the no-op version of cancel inherited from\n // QueryInfo.prototype.\n delete this.cancel;\n\n this.subscriptions.forEach(sub => sub.unsubscribe());\n\n const oq = this.observableQuery;\n if (oq) oq.stopPolling();\n }\n }\n\n // This method is a no-op by default, until/unless overridden by the\n // updateWatch method.\n private cancel() {}\n\n private lastWatch?: Cache.WatchOptions;\n\n private updateWatch(variables = this.variables) {\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return;\n }\n if (!this.lastWatch ||\n this.lastWatch.query !== this.document ||\n !equal(variables, this.lastWatch.variables)) {\n this.cancel();\n this.cancel = this.cache.watch(this.lastWatch = {\n query: this.document!,\n variables,\n optimistic: true,\n callback: diff => this.setDiff(diff),\n });\n }\n }\n\n private lastWrite?: {\n result: FetchResult<any>;\n variables: WatchQueryOptions[\"variables\"];\n dmCount: number | undefined;\n };\n\n private shouldWrite(\n result: FetchResult<any>,\n variables: WatchQueryOptions[\"variables\"],\n ) {\n const { lastWrite } = this;\n return !(\n lastWrite &&\n // If cache.evict has been called since the last time we wrote this\n // data into the cache, there's a chance writing this result into\n // the cache will repair what was evicted.\n lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&\n equal(variables, lastWrite.variables) &&\n equal(result.data, lastWrite.result.data)\n );\n }\n\n public markResult<T>(\n result: FetchResult<T>,\n options: Pick<WatchQueryOptions,\n | \"variables\"\n | \"fetchPolicy\"\n | \"errorPolicy\">,\n allowCacheWrite: boolean,\n ) {\n this.graphQLErrors = isNonEmptyArray(result.errors) ? result.errors : [];\n\n // If there is a pending notify timeout, cancel it because we are\n // about to update this.diff to hold the latest data, and we can\n // assume the data will be broadcast through some other mechanism.\n cancelNotifyTimeout(this);\n\n if (options.fetchPolicy === 'no-cache') {\n this.diff = { result: result.data, complete: true };\n\n } else if (!this.stopped && allowCacheWrite) {\n if (shouldWriteResult(result, options.errorPolicy)) {\n // Using a transaction here so we have a chance to read the result\n // back from the cache before the watch callback fires as a result\n // of writeQuery, so we can store the new diff quietly and ignore\n // it when we receive it redundantly from the watch callback.\n this.cache.performTransaction(cache => {\n if (this.shouldWrite(result, options.variables)) {\n cache.writeQuery({\n query: this.document!,\n data: result.data as T,\n variables: options.variables,\n });\n\n this.lastWrite = {\n result,\n variables: options.variables,\n dmCount: destructiveMethodCounts.get(this.cache),\n };\n } else {\n // If result is the same as the last result we received from\n // the network (and the variables match too), avoid writing\n // result into the cache again. The wisdom of skipping this\n // cache write is far from obvious, since any cache write\n // could be the one that puts the cache back into a desired\n // state, fixing corruption or missing data. However, if we\n // always write every network result into the cache, we enable\n // feuds between queries competing to update the same data in\n // incompatible ways, which can lead to an endless cycle of\n // cache broadcasts and useless network requests. As with any\n // feud, eventually one side must step back from the brink,\n // letting the other side(s) have the last word(s). There may\n // be other points where we could break this cycle, such as\n // silencing the broadcast for cache.writeQuery (not a good\n // idea, since it just delays the feud a bit) or somehow\n // avoiding the network request that just happened (also bad,\n // because the server could return useful new data). All\n // options considered, skipping this cache write seems to be\n // the least damaging place to break the cycle, because it\n // reflects the intuition that we recently wrote this exact\n // result into the cache, so the cache *should* already/still\n // contain this data. If some other query has clobbered that\n // data in the meantime, that's too bad, but there will be no\n // winners if every query blindly reverts to its own version\n // of the data. This approach also gives the network a chance\n // to return new data, which will be written into the cache as\n // usual, notifying only those queries that are directly\n // affected by the cache updates, as usual. In the future, an\n // even more sophisticated cache could perhaps prevent or\n // mitigate the clobbering somehow, but that would make this\n // particular cache write even less important, and thus\n // skipping it would be even safer than it is today.\n if (this.diff && this.diff.complete) {\n // Reuse data from the last good (complete) diff that we\n // received, when possible.\n result.data = this.diff.result;\n return;\n }\n // If the previous this.diff was incomplete, fall through to\n // re-reading the latest data with cache.diff, below.\n }\n\n const diff = cache.diff<T>({\n query: this.document!,\n variables: options.variables,\n returnPartialData: true,\n optimistic: true,\n });\n\n // In case the QueryManager stops this QueryInfo before its\n // results are delivered, it's important to avoid restarting the\n // cache watch when markResult is called.\n if (!this.stopped) {\n // Any time we're about to update this.diff, we need to make\n // sure we've started watching the cache.\n this.updateWatch(options.variables);\n }\n\n // If we're allowed to write to the cache, and we can read a\n // complete result from the cache, update result.data to be the\n // result from the cache, rather than the raw network result.\n // Set without setDiff to avoid triggering a notify call, since\n // we have other ways of notifying for this result.\n this.diff = diff;\n if (diff.complete) {\n result.data = diff.result;\n }\n });\n\n } else {\n this.lastWrite = void 0;\n }\n }\n }\n\n public markReady() {\n this.networkError = null;\n return this.networkStatus = NetworkStatus.ready;\n }\n\n public markError(error: ApolloError) {\n this.networkStatus = NetworkStatus.error;\n this.lastWrite = void 0;\n\n cancelNotifyTimeout(this);\n\n if (error.graphQLErrors) {\n this.graphQLErrors = error.graphQLErrors;\n }\n\n if (error.networkError) {\n this.networkError = error.networkError;\n }\n\n return error;\n }\n}\n\nexport function shouldWriteResult<T>(\n result: FetchResult<T>,\n errorPolicy: ErrorPolicy = \"none\",\n) {\n const ignoreErrors =\n errorPolicy === \"ignore\" ||\n errorPolicy === \"all\";\n let writeWithErrors = !graphQLResultHasError(result);\n if (!writeWithErrors && ignoreErrors && result.data) {\n writeWithErrors = true;\n }\n return writeWithErrors;\n}\n"]}
1
+ {"version":3,"file":"QueryInfo.js","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAOtC,OAAO,EAEL,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAUzB,IAAM,uBAAuB,GAAG,IAAI,CAClC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAC9B,EAA4B,CAAC;AAE9B,SAAS,0BAA0B,CACjC,KAAuB,EACvB,UAAkC;IAElC,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAClC,KAAK,CAAC,UAAU,CAAC,GAAG;YAClB,uBAAuB,CAAC,GAAG,CACzB,KAAK,EAKL,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CACjD,CAAC;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC,CAAC;KACH;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAe;IAC1C,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE;QACzB,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC,CAAC;KAChC;AACH,CAAC;AAcD;IAWE,mBAAoB,KAAuB;QAAvB,UAAK,GAAL,KAAK,CAAkB;QAV3C,cAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;QACrC,aAAQ,GAAwB,IAAI,CAAC;QACrC,kBAAa,GAAG,CAAC,CAAC;QAClB,kBAAa,GAA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AAG,KAAK,CAAC,CAAC;QAExB,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;SAC1C;QAED,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;SACxC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gBAAC;AAAD,CAAC,AArWD,IAqWC;;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,WAAiC;IAAjC,4BAAA,EAAA,oBAAiC;IAEjC,IAAM,YAAY,GAChB,WAAW,KAAK,QAAQ;QACxB,WAAW,KAAK,KAAK,CAAC;IACxB,IAAI,eAAe,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,EAAE;QACnD,eAAe,GAAG,IAAI,CAAC;KACxB;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { DocumentNode, GraphQLError } from 'graphql';\nimport { equal } from \"@wry/equality\";\n\nimport { Cache, ApolloCache } from '../cache';\nimport { WatchQueryOptions, ErrorPolicy } from './watchQueryOptions';\nimport { ObservableQuery } from './ObservableQuery';\nimport { QueryListener } from './types';\nimport { FetchResult } from '../link/core';\nimport {\n ObservableSubscription,\n isNonEmptyArray,\n graphQLResultHasError,\n canUseWeakMap,\n} from '../utilities';\nimport {\n NetworkStatus,\n isNetworkRequestInFlight,\n} from './networkStatus';\nimport { ApolloError } from '../errors';\n\nexport type QueryStoreValue = Pick<QueryInfo,\n | \"variables\"\n | \"networkStatus\"\n | \"networkError\"\n | \"graphQLErrors\"\n >;\n\nconst destructiveMethodCounts = new (\n canUseWeakMap ? WeakMap : Map\n)<ApolloCache<any>, number>();\n\nfunction wrapDestructiveCacheMethod(\n cache: ApolloCache<any>,\n methodName: keyof ApolloCache<any>,\n) {\n const original = cache[methodName];\n if (typeof original === \"function\") {\n cache[methodName] = function () {\n destructiveMethodCounts.set(\n cache,\n // The %1e15 allows the count to wrap around to 0 safely every\n // quadrillion evictions, so there's no risk of overflow. To be\n // clear, this is more of a pedantic principle than something\n // that matters in any conceivable practical scenario.\n (destructiveMethodCounts.get(cache)! + 1) % 1e15,\n );\n return original.apply(this, arguments);\n };\n }\n}\n\nfunction cancelNotifyTimeout(info: QueryInfo) {\n if (info[\"notifyTimeout\"]) {\n clearTimeout(info[\"notifyTimeout\"]);\n info[\"notifyTimeout\"] = void 0;\n }\n}\n\n// A QueryInfo object represents a single query managed by the\n// QueryManager, which tracks all QueryInfo objects by queryId in its\n// this.queries Map. QueryInfo objects store the latest results and errors\n// for the given query, and are responsible for reporting those results to\n// the corresponding ObservableQuery, via the QueryInfo.notify method.\n// Results are reported asynchronously whenever setDiff marks the\n// QueryInfo object as dirty, though a call to the QueryManager's\n// broadcastQueries method may trigger the notification before it happens\n// automatically. This class used to be a simple interface type without\n// any field privacy or meaningful methods, which is why it still has so\n// many public fields. The effort to lock down and simplify the QueryInfo\n// interface is ongoing, and further improvements are welcome.\nexport class QueryInfo {\n listeners = new Set<QueryListener>();\n document: DocumentNode | null = null;\n lastRequestId = 1;\n subscriptions = new Set<ObservableSubscription>();\n variables?: Record<string, any>;\n networkStatus?: NetworkStatus;\n networkError?: Error | null;\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n stopped = false;\n\n constructor(private cache: ApolloCache<any>) {\n // Track how often cache.evict is called, since we want eviction to\n // override the feud-stopping logic in the markResult method, by\n // causing shouldWrite to return true. Wrapping the cache.evict method\n // is a bit of a hack, but it saves us from having to make eviction\n // counting an official part of the ApolloCache API.\n if (!destructiveMethodCounts.has(cache)) {\n destructiveMethodCounts.set(cache, 0);\n wrapDestructiveCacheMethod(cache, \"evict\");\n wrapDestructiveCacheMethod(cache, \"modify\");\n wrapDestructiveCacheMethod(cache, \"reset\");\n }\n }\n\n public init(query: {\n document: DocumentNode;\n variables: Record<string, any> | undefined,\n // The initial networkStatus for this fetch, most often\n // NetworkStatus.loading, but also possibly fetchMore, poll, refetch,\n // or setVariables.\n networkStatus?: NetworkStatus,\n observableQuery?: ObservableQuery<any>;\n lastRequestId?: number;\n }): this {\n let networkStatus = query.networkStatus || NetworkStatus.loading;\n if (this.variables &&\n this.networkStatus !== NetworkStatus.loading &&\n !equal(this.variables, query.variables)) {\n networkStatus = NetworkStatus.setVariables;\n }\n\n if (!equal(query.variables, this.variables)) {\n this.diff = null;\n }\n\n Object.assign(this, {\n document: query.document,\n variables: query.variables,\n networkError: null,\n graphQLErrors: this.graphQLErrors || [],\n networkStatus,\n });\n\n if (query.observableQuery) {\n this.setObservableQuery(query.observableQuery);\n }\n\n if (query.lastRequestId) {\n this.lastRequestId = query.lastRequestId;\n }\n\n return this;\n }\n\n private dirty: boolean = false;\n\n private notifyTimeout?: ReturnType<typeof setTimeout>;\n\n private diff: Cache.DiffResult<any> | null = null;\n\n reset() {\n cancelNotifyTimeout(this);\n this.diff = null;\n this.dirty = false;\n }\n\n getDiff(variables = this.variables): Cache.DiffResult<any> {\n if (this.diff && equal(variables, this.variables)) {\n return this.diff;\n }\n\n this.updateWatch(this.variables = variables);\n\n return this.diff = this.cache.diff({\n query: this.document!,\n variables,\n returnPartialData: true,\n optimistic: true,\n });\n }\n\n setDiff(diff: Cache.DiffResult<any> | null) {\n const oldDiff = this.diff;\n this.diff = diff;\n if (!this.dirty &&\n (diff && diff.result) !== (oldDiff && oldDiff.result)) {\n this.dirty = true;\n if (!this.notifyTimeout) {\n this.notifyTimeout = setTimeout(() => this.notify(), 0);\n }\n }\n }\n\n public readonly observableQuery: ObservableQuery<any> | null = null;\n private oqListener?: QueryListener;\n\n setObservableQuery(oq: ObservableQuery<any> | null) {\n if (oq === this.observableQuery) return;\n\n if (this.oqListener) {\n this.listeners.delete(this.oqListener);\n }\n\n (this as any).observableQuery = oq;\n\n if (oq) {\n oq[\"queryInfo\"] = this;\n this.listeners.add(this.oqListener = () => {\n // If this.diff came from an optimistic transaction, deliver the\n // current cache data to the ObservableQuery, but don't perform a\n // full reobservation, since oq.reobserve might make a network\n // request, and we don't want to trigger network requests for\n // optimistic updates.\n if (this.getDiff().fromOptimisticTransaction) {\n oq[\"observe\"]();\n } else {\n oq.reobserve();\n }\n });\n } else {\n delete this.oqListener;\n }\n }\n\n notify() {\n cancelNotifyTimeout(this);\n\n if (this.shouldNotify()) {\n this.listeners.forEach(listener => listener(this));\n }\n\n this.dirty = false;\n }\n\n private shouldNotify() {\n if (!this.dirty || !this.listeners.size) {\n return false;\n }\n\n if (isNetworkRequestInFlight(this.networkStatus) &&\n this.observableQuery) {\n const { fetchPolicy } = this.observableQuery.options;\n if (fetchPolicy !== \"cache-only\" &&\n fetchPolicy !== \"cache-and-network\") {\n return false;\n }\n }\n\n return true;\n }\n\n public stop() {\n if (!this.stopped) {\n this.stopped = true;\n\n this.cancel();\n // Revert back to the no-op version of cancel inherited from\n // QueryInfo.prototype.\n delete this.cancel;\n\n this.subscriptions.forEach(sub => sub.unsubscribe());\n\n const oq = this.observableQuery;\n if (oq) oq.stopPolling();\n }\n }\n\n // This method is a no-op by default, until/unless overridden by the\n // updateWatch method.\n private cancel() {}\n\n private lastWatch?: Cache.WatchOptions;\n\n private updateWatch(variables = this.variables) {\n const oq = this.observableQuery;\n if (oq && oq.options.fetchPolicy === \"no-cache\") {\n return;\n }\n if (!this.lastWatch ||\n this.lastWatch.query !== this.document ||\n !equal(variables, this.lastWatch.variables)) {\n this.cancel();\n this.cancel = this.cache.watch(this.lastWatch = {\n query: this.document!,\n variables,\n optimistic: true,\n callback: diff => this.setDiff(diff),\n });\n }\n }\n\n private lastWrite?: {\n result: FetchResult<any>;\n variables: WatchQueryOptions[\"variables\"];\n dmCount: number | undefined;\n };\n\n private shouldWrite(\n result: FetchResult<any>,\n variables: WatchQueryOptions[\"variables\"],\n ) {\n const { lastWrite } = this;\n return !(\n lastWrite &&\n // If cache.evict has been called since the last time we wrote this\n // data into the cache, there's a chance writing this result into\n // the cache will repair what was evicted.\n lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&\n equal(variables, lastWrite.variables) &&\n equal(result.data, lastWrite.result.data)\n );\n }\n\n public markResult<T>(\n result: FetchResult<T>,\n options: Pick<WatchQueryOptions,\n | \"variables\"\n | \"fetchPolicy\"\n | \"errorPolicy\">,\n allowCacheWrite: boolean,\n ) {\n this.graphQLErrors = isNonEmptyArray(result.errors) ? result.errors : [];\n\n // Cancel the pending notify timeout (if it exists) to prevent extraneous network\n // requests. To allow future notify timeouts, diff and dirty are reset as well.\n this.reset();\n\n if (options.fetchPolicy === 'no-cache') {\n this.diff = { result: result.data, complete: true };\n\n } else if (!this.stopped && allowCacheWrite) {\n if (shouldWriteResult(result, options.errorPolicy)) {\n // Using a transaction here so we have a chance to read the result\n // back from the cache before the watch callback fires as a result\n // of writeQuery, so we can store the new diff quietly and ignore\n // it when we receive it redundantly from the watch callback.\n this.cache.performTransaction(cache => {\n if (this.shouldWrite(result, options.variables)) {\n cache.writeQuery({\n query: this.document!,\n data: result.data as T,\n variables: options.variables,\n });\n\n this.lastWrite = {\n result,\n variables: options.variables,\n dmCount: destructiveMethodCounts.get(this.cache),\n };\n } else {\n // If result is the same as the last result we received from\n // the network (and the variables match too), avoid writing\n // result into the cache again. The wisdom of skipping this\n // cache write is far from obvious, since any cache write\n // could be the one that puts the cache back into a desired\n // state, fixing corruption or missing data. However, if we\n // always write every network result into the cache, we enable\n // feuds between queries competing to update the same data in\n // incompatible ways, which can lead to an endless cycle of\n // cache broadcasts and useless network requests. As with any\n // feud, eventually one side must step back from the brink,\n // letting the other side(s) have the last word(s). There may\n // be other points where we could break this cycle, such as\n // silencing the broadcast for cache.writeQuery (not a good\n // idea, since it just delays the feud a bit) or somehow\n // avoiding the network request that just happened (also bad,\n // because the server could return useful new data). All\n // options considered, skipping this cache write seems to be\n // the least damaging place to break the cycle, because it\n // reflects the intuition that we recently wrote this exact\n // result into the cache, so the cache *should* already/still\n // contain this data. If some other query has clobbered that\n // data in the meantime, that's too bad, but there will be no\n // winners if every query blindly reverts to its own version\n // of the data. This approach also gives the network a chance\n // to return new data, which will be written into the cache as\n // usual, notifying only those queries that are directly\n // affected by the cache updates, as usual. In the future, an\n // even more sophisticated cache could perhaps prevent or\n // mitigate the clobbering somehow, but that would make this\n // particular cache write even less important, and thus\n // skipping it would be even safer than it is today.\n if (this.diff && this.diff.complete) {\n // Reuse data from the last good (complete) diff that we\n // received, when possible.\n result.data = this.diff.result;\n return;\n }\n // If the previous this.diff was incomplete, fall through to\n // re-reading the latest data with cache.diff, below.\n }\n\n const diff = cache.diff<T>({\n query: this.document!,\n variables: options.variables,\n returnPartialData: true,\n optimistic: true,\n });\n\n // In case the QueryManager stops this QueryInfo before its\n // results are delivered, it's important to avoid restarting the\n // cache watch when markResult is called.\n if (!this.stopped) {\n // Any time we're about to update this.diff, we need to make\n // sure we've started watching the cache.\n this.updateWatch(options.variables);\n }\n\n // If we're allowed to write to the cache, and we can read a\n // complete result from the cache, update result.data to be the\n // result from the cache, rather than the raw network result.\n // Set without setDiff to avoid triggering a notify call, since\n // we have other ways of notifying for this result.\n this.diff = diff;\n if (diff.complete) {\n result.data = diff.result;\n }\n });\n\n } else {\n this.lastWrite = void 0;\n }\n }\n }\n\n public markReady() {\n this.networkError = null;\n return this.networkStatus = NetworkStatus.ready;\n }\n\n public markError(error: ApolloError) {\n this.networkStatus = NetworkStatus.error;\n this.lastWrite = void 0;\n\n this.reset();\n\n if (error.graphQLErrors) {\n this.graphQLErrors = error.graphQLErrors;\n }\n\n if (error.networkError) {\n this.networkError = error.networkError;\n }\n\n return error;\n }\n}\n\nexport function shouldWriteResult<T>(\n result: FetchResult<T>,\n errorPolicy: ErrorPolicy = \"none\",\n) {\n const ignoreErrors =\n errorPolicy === \"ignore\" ||\n errorPolicy === \"all\";\n let writeWithErrors = !graphQLResultHasError(result);\n if (!writeWithErrors && ignoreErrors && result.data) {\n writeWithErrors = true;\n }\n return writeWithErrors;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"QueryManager.d.ts","sourceRoot":"","sources":["../../src/core/QueryManager.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC,OAAO,EAAE,UAAU,EAAW,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAS,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EASL,UAAU,EAGV,OAAO,EAER,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EAEf,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAsC,MAAM,aAAa,CAAC;AAI5E,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,qBAAa,YAAY,CAAC,MAAM;IACvB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;IACxB,SAAgB,sBAAsB,EAAE,OAAO,CAAC;IAChD,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,OAAO,CAAC,kBAAkB,CAAU;IACpC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,UAAU,CAAqB;IAEvC,OAAO,CAAC,WAAW,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IAKvC,OAAO,CAAC,2BAA2B;IAK5B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B3B,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAY/C,wBAAwB,CAC7B,cAAc,GAAE,OAAe,GAC9B,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAwB7B,kBAAkB,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC;IAI7D,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,EACvC,KAAK,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,OAAY,GACb,EAAE,mBAAmB,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAuD5C,SAAS,CAAC,OAAO,EAAE,MAAM;IAKhC,OAAO,CAAC,oBAAoB;IAKrB,WAAW,CAAC,OAAO,EAAE,MAAM;IAW3B,gBAAgB;IAKhB,aAAa,IAAI,UAAU,CAAC,MAAM,CAAC;IAI1C,OAAO,CAAC,uBAAuB,CAG3B;IAEJ,OAAO,CAAC,qBAAqB;IA4E7B,OAAO,CAAC,kBAAkB;IA2DnB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,EAIxC,aAAa,gBAAwB,GACpC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAiHpC,OAAO,CAAC,kBAAkB;IA0H1B,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,cAAc;CAOvB"}
@@ -151,6 +151,7 @@ var QueryManager = (function () {
151
151
  self.queries.forEach(function (_a) {
152
152
  var observableQuery = _a.observableQuery;
153
153
  if (observableQuery &&
154
+ observableQuery.hasObservers() &&
154
155
  observableQuery.queryName === refetchQuery) {
155
156
  refetchQueryPromises.push(observableQuery.refetch());
156
157
  }