mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-11-23 01:36:14 +00:00
1 line
194 KiB
Plaintext
1 line
194 KiB
Plaintext
{"version":3,"sources":["../src/core/networkStatus.ts","../src/util/Observable.ts","../src/util/arrays.ts","../src/errors/ApolloError.ts","../src/core/types.ts","../src/core/ObservableQuery.ts","../src/data/mutations.ts","../src/data/queries.ts","../src/util/capitalizeFirstLetter.ts","../src/core/LocalState.ts","../src/util/observables.ts","../src/core/QueryManager.ts","../src/data/store.ts","../src/version.ts","../src/ApolloClient.ts"],"names":["LinkObservable"],"mappings":";;;;;;;;;;;;;;;;;;;;IAGY,a;;;AAAZ,CAAA,UAAY,aAAZ,EAAyB;AAMvB,EAAA,aAAA,CAAA,aAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAMA,EAAA,aAAA,CAAA,aAAA,CAAA,cAAA,CAAA,GAAA,CAAA,CAAA,GAAA,cAAA;AAMA,EAAA,aAAA,CAAA,aAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAA;AAMA,EAAA,aAAA,CAAA,aAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAOA,EAAA,aAAA,CAAA,aAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAA;AAKA,EAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA;AAKA,EAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAA;AACD,CA1CD,EAAY,aAAa,6BAAb,aAAa,GAAA,EAAA,CAAzB;;AAgDA,SAAgB,wBAAhB,CACE,aADF,EAC8B;AAE5B,SAAO,aAAa,GAAG,CAAvB;AACD;;AC7CD,IAAA,UAAA,GAAA,UAAA,MAAA,EAAA;AAAmCA,wBAAAA,UAAAA,EAAAA,MAAAA;;AAAnC,WAAA,UAAA,GAAA;;AAQ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M;;AAWA,EAAA,YAAA,CAAA,SAAA,CAAA,OAAA,GAAP,UAAe,eAAf,EAA2C;AACzC,WAAO,KAAK,KAAL,CAAW,OAAX,CAAmB,eAAnB,CAAP;AACD,GAFM;;AAOA,EAAA,YAAA,CAAA,SAAA,CAAA,YAAA,GAAP,UAAoB,SAApB,EAAsD;AACpD,SAAK,UAAL,CAAgB,YAAhB,CAA6B,SAA7B;AACD,GAFM;;AAOA,EAAA,YAAA,CAAA,SAAA,CAAA,YAAA,GAAP,UAAoB,SAApB,EAAsD;AACpD,SAAK,UAAL,CAAgB,YAAhB,CAA6B,SAA7B;AACD,GAFM;;AAOA,EAAA,YAAA,CAAA,SAAA,CAAA,YAAA,GAAP,YAAA;AACE,WAAO,KAAK,UAAL,CAAgB,YAAhB,EAAP;AACD,GAFM;;AAOA,EAAA,YAAA,CAAA,SAAA,CAAA,4BAAA,GAAP,UAAoC,eAApC,EAAoE;AAClE,SAAK,UAAL,CAAgB,kBAAhB,CAAmC,eAAnC;AACD,GAFM;;AAGT,SAAA,YAAA;AAAC,CA3gBD,EAAA","sourcesContent":["/**\n * The current status of a query’s execution in our system.\n */\nexport enum NetworkStatus {\n /**\n * The query has never been run before and the query is now currently running. A query will still\n * have this network status even if a partial data result was returned from the cache, but a\n * query was dispatched anyway.\n */\n loading = 1,\n\n /**\n * If `setVariables` was called and a query was fired because of that then the network status\n * will be `setVariables` until the result of that query comes back.\n */\n setVariables = 2,\n\n /**\n * Indicates that `fetchMore` was called on this query and that the query created is currently in\n * flight.\n */\n fetchMore = 3,\n\n /**\n * Similar to the `setVariables` network status. It means that `refetch` was called on a query\n * and the refetch request is currently in flight.\n */\n refetch = 4,\n\n /**\n * Indicates that a polling query is currently in flight. So for example if you are polling a\n * query every 10 seconds then the network status will switch to `poll` every 10 seconds whenever\n * a poll request has been sent but not resolved.\n */\n poll = 6,\n\n /**\n * No request is in flight for this query, and no errors happened. Everything is OK.\n */\n ready = 7,\n\n /**\n * No request is in flight for this query, but one or more errors were detected.\n */\n error = 8,\n}\n\n/**\n * Returns true if there is currently a network request in flight according to a given network\n * status.\n */\nexport function isNetworkRequestInFlight(\n networkStatus: NetworkStatus,\n): boolean {\n return networkStatus < 7;\n}\n","// This simplified polyfill attempts to follow the ECMAScript Observable proposal.\n// See https://github.com/zenparsing/es-observable\nimport { Observable as LinkObservable } from 'apollo-link';\n\nexport type Subscription = ZenObservable.Subscription;\nexport type Observer<T> = ZenObservable.Observer<T>;\n\nimport $$observable from 'symbol-observable';\n\n// rxjs interopt\nexport class Observable<T> extends LinkObservable<T> {\n public [$$observable]() {\n return this;\n }\n\n public ['@@observable' as any]() {\n return this;\n }\n}\n","export function isNonEmptyArray<T>(value?: ArrayLike<T>): value is Array<T> {\n return Array.isArray(value) && value.length > 0;\n}\n","import { GraphQLError } from 'graphql';\nimport { isNonEmptyArray } from '../util/arrays';\n\nexport function isApolloError(err: Error): err is ApolloError {\n return err.hasOwnProperty('graphQLErrors');\n}\n\n// Sets the error message on this error according to the\n// the GraphQL and network errors that are present.\n// If the error message has already been set through the\n// constructor or otherwise, this function is a nop.\nconst generateErrorMessage = (err: ApolloError) => {\n let message = '';\n // If we have GraphQL errors present, add that to the error message.\n if (isNonEmptyArray(err.graphQLErrors)) {\n err.graphQLErrors.forEach((graphQLError: GraphQLError) => {\n const errorMessage = graphQLError\n ? graphQLError.message\n : 'Error message not found.';\n message += `GraphQL error: ${errorMessage}\\n`;\n });\n }\n\n if (err.networkError) {\n message += 'Network error: ' + err.networkError.message + '\\n';\n }\n\n // strip newline from the end of the message\n message = message.replace(/\\n$/, '');\n return message;\n};\n\nexport class ApolloError extends Error {\n public message: string;\n public graphQLErrors: ReadonlyArray<GraphQLError>;\n public networkError: Error | null;\n\n // An object that can be used to provide some additional information\n // about an error, e.g. specifying the type of error this is. Used\n // internally within Apollo Client.\n public extraInfo: any;\n\n // Constructs an instance of ApolloError given a GraphQLError\n // or a network error. Note that one of these has to be a valid\n // value or the constructed error will be meaningless.\n constructor({\n graphQLErrors,\n networkError,\n errorMessage,\n extraInfo,\n }: {\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n networkError?: Error | null;\n errorMessage?: string;\n extraInfo?: any;\n }) {\n super(errorMessage);\n this.graphQLErrors = graphQLErrors || [];\n this.networkError = networkError || null;\n\n if (!errorMessage) {\n this.message = generateErrorMessage(this);\n } else {\n this.message = errorMessage;\n }\n\n this.extraInfo = extraInfo;\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully\n // supported on Android (see issue #3236).\n (this as any).__proto__ = ApolloError.prototype;\n }\n}\n","import { FetchResult } from 'apollo-link';\nimport { DocumentNode, GraphQLError } from 'graphql';\n\nimport { QueryStoreValue } from '../data/queries';\nimport { NetworkStatus } from './networkStatus';\nimport { Resolver } from './LocalState';\n\nexport type QueryListener = (\n queryStoreValue: QueryStoreValue,\n newData?: any,\n forceResolvers?: boolean,\n) => void;\n\nexport type OperationVariables = { [key: string]: any };\n\nexport type PureQueryOptions = {\n query: DocumentNode;\n variables?: { [key: string]: any };\n context?: any;\n};\n\nexport type ApolloQueryResult<T> = {\n data: T;\n errors?: ReadonlyArray<GraphQLError>;\n loading: boolean;\n networkStatus: NetworkStatus;\n stale: boolean;\n};\n\nexport enum FetchType {\n normal = 1,\n refetch = 2,\n poll = 3,\n}\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: FetchResult<T>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n },\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\nexport interface Resolvers {\n [key: string]: {\n [ field: string ]: Resolver;\n };\n}\n","import {\n isEqual,\n tryFunctionOrLogError,\n cloneDeep,\n getOperationDefinition,\n} from 'apollo-utilities';\nimport { GraphQLError } from 'graphql';\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport { Observable, Observer, Subscription } from '../util/Observable';\nimport { ApolloError } from '../errors/ApolloError';\nimport { QueryManager } from './QueryManager';\nimport { ApolloQueryResult, FetchType, OperationVariables } from './types';\nimport {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n ErrorPolicy,\n} from './watchQueryOptions';\n\nimport { QueryStoreValue } from '../data/queries';\n\nimport { invariant, InvariantError } from 'ts-invariant';\nimport { isNonEmptyArray } from '../util/arrays';\n\n// XXX remove in the next breaking semver change (3.0)\n// Deprecated, use ApolloCurrentQueryResult\nexport type ApolloCurrentResult<T> = {\n data: T | {};\n errors?: ReadonlyArray<GraphQLError>;\n loading: boolean;\n networkStatus: NetworkStatus;\n error?: ApolloError;\n partial?: boolean;\n};\n\nexport type ApolloCurrentQueryResult<T> = {\n data: T | undefined;\n errors?: ReadonlyArray<GraphQLError>;\n loading: boolean;\n networkStatus: NetworkStatus;\n error?: ApolloError;\n partial?: boolean;\n stale?: boolean;\n};\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\nexport const hasError = (\n storeValue: QueryStoreValue,\n policy: ErrorPolicy = 'none',\n) => storeValue && (\n storeValue.networkError ||\n (policy === 'none' && isNonEmptyArray(storeValue.graphQLErrors))\n);\n\nexport class ObservableQuery<\n TData = any,\n TVariables = OperationVariables\n> extends Observable<ApolloQueryResult<TData>> {\n public options: WatchQueryOptions<TVariables>;\n public readonly queryId: string;\n public readonly queryName?: string;\n /**\n *\n * The current value of the variables for this query. Can change.\n */\n public variables: TVariables;\n\n private shouldSubscribe: boolean;\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<Subscription>();\n\n private lastResult: ApolloQueryResult<TData>;\n private lastResultSnapshot: ApolloQueryResult<TData>;\n private lastError: ApolloError;\n\n constructor({\n queryManager,\n options,\n shouldSubscribe = true,\n }: {\n queryManager: QueryManager<any>;\n options: WatchQueryOptions<TVariables>;\n shouldSubscribe?: boolean;\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.variables = options.variables || ({} as TVariables);\n this.queryId = queryManager.generateQueryId();\n this.shouldSubscribe = shouldSubscribe;\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\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 // XXX remove in the next breaking semver change (3.0)\n // Deprecated, use getCurrentResult()\n public currentResult(): ApolloCurrentResult<TData> {\n const result = this.getCurrentResult() as ApolloCurrentResult<TData>;\n if (result.data === undefined) {\n result.data = {};\n }\n return result;\n }\n\n /**\n * Return the result of the query from the local cache as well as some fetching status\n * `loading` and `networkStatus` allow to know if a request is in flight\n * `partial` lets you know if the result from the local cache is complete or partial\n * @return {data: Object, error: ApolloError, loading: boolean, networkStatus: number, partial: boolean}\n */\n public getCurrentResult(): ApolloCurrentQueryResult<TData> {\n if (this.isTornDown) {\n const { lastResult } = this;\n return {\n data: !this.lastError && lastResult && lastResult.data || void 0,\n error: this.lastError,\n loading: false,\n networkStatus: NetworkStatus.error,\n };\n }\n\n const { data, partial } = this.queryManager.getCurrentQueryResult(this);\n const queryStoreValue = this.queryManager.queryStore.get(this.queryId);\n let result: ApolloQueryResult<TData>;\n\n const { fetchPolicy } = this.options;\n\n const isNetworkFetchPolicy =\n fetchPolicy === 'network-only' ||\n fetchPolicy === 'no-cache';\n\n if (queryStoreValue) {\n const { networkStatus } = queryStoreValue;\n\n if (hasError(queryStoreValue, this.options.errorPolicy)) {\n return {\n data: void 0,\n loading: false,\n networkStatus,\n error: new ApolloError({\n graphQLErrors: queryStoreValue.graphQLErrors,\n networkError: queryStoreValue.networkError,\n }),\n };\n }\n\n // Variables might have been added dynamically at query time, when\n // using `@client @export(as: \"varname\")` for example. When this happens,\n // the variables have been updated in the query store, but not updated on\n // the original `ObservableQuery`. We'll update the observable query\n // variables here to match, so retrieving from the cache doesn't fail.\n if (queryStoreValue.variables) {\n this.options.variables = {\n ...this.options.variables,\n ...(queryStoreValue.variables as TVariables),\n };\n this.variables = this.options.variables;\n }\n\n result = {\n data,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n if (queryStoreValue.graphQLErrors && this.options.errorPolicy === 'all') {\n result.errors = queryStoreValue.graphQLErrors;\n }\n\n } else {\n // We need to be careful about the loading state we show to the user, to try\n // and be vaguely in line with what the user would have seen from .subscribe()\n // but to still provide useful information synchronously when the query\n // will not end up hitting the server.\n // See more: https://github.com/apollostack/apollo-client/issues/707\n // Basically: is there a query in flight right now (modolo the next tick)?\n const loading = isNetworkFetchPolicy ||\n (partial && fetchPolicy !== 'cache-only');\n\n result = {\n data,\n loading,\n networkStatus: loading ? NetworkStatus.loading : NetworkStatus.ready,\n } as ApolloQueryResult<TData>;\n }\n\n if (!partial) {\n this.updateLastResult({ ...result, stale: false });\n }\n\n return { ...result, partial };\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 const { lastResultSnapshot: snapshot } = this;\n return !(\n snapshot &&\n newResult &&\n snapshot.networkStatus === newResult.networkStatus &&\n snapshot.stale === newResult.stale &&\n isEqual(snapshot.data, newResult.data)\n );\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 const queryStore = this.queryManager.queryStore.get(this.queryId);\n if (queryStore) {\n queryStore.networkError = null;\n queryStore.graphQLErrors = [];\n }\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?: TVariables): Promise<ApolloQueryResult<TData>> {\n let { fetchPolicy } = this.options;\n // early return if trying to read from cache during refetch\n if (fetchPolicy === 'cache-only') {\n return Promise.reject(new InvariantError(\n 'cache-only fetchPolicy option should not be used together with query refetch.',\n ));\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 if (fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'cache-and-network') {\n fetchPolicy = 'network-only';\n }\n\n if (!isEqual(this.variables, variables)) {\n // update observable variables\n this.variables = {\n ...this.variables,\n ...variables,\n };\n }\n\n if (!isEqual(this.options.variables, this.variables)) {\n // Update the existing options with new variables\n this.options.variables = {\n ...this.options.variables,\n ...this.variables,\n };\n }\n\n return this.queryManager.fetchQuery(\n this.queryId,\n { ...this.options, fetchPolicy },\n FetchType.refetch,\n ) as Promise<ApolloQueryResult<TData>>;\n }\n\n public fetchMore<K extends keyof TVariables>(\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, K> &\n FetchMoreOptions<TData, TVariables>,\n ): Promise<ApolloQueryResult<TData>> {\n // early return if no update Query\n invariant(\n fetchMoreOptions.updateQuery,\n 'updateQuery option is required. This function defines how to update the query data with the new results.',\n );\n\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : {\n ...this.options,\n ...fetchMoreOptions,\n variables: {\n ...this.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n fetchPolicy: 'network-only',\n } as WatchQueryOptions;\n\n const qid = this.queryManager.generateQueryId();\n\n return this.queryManager\n .fetchQuery(\n qid,\n combinedOptions,\n FetchType.normal,\n this.queryId,\n )\n .then(\n fetchMoreResult => {\n this.updateQuery((previousResult: any) =>\n fetchMoreOptions.updateQuery(previousResult, {\n fetchMoreResult: fetchMoreResult.data as TData,\n variables: combinedOptions.variables as TVariables,\n }),\n );\n this.queryManager.stopQuery(qid);\n return fetchMoreResult as ApolloQueryResult<TData>;\n },\n error => {\n this.queryManager.stopQuery(qid);\n throw error;\n },\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 })\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 // Note: if the query is not active (there are no subscribers), the promise\n // will return null immediately.\n public setOptions(\n opts: WatchQueryOptions,\n ): Promise<ApolloQueryResult<TData> | void> {\n const { fetchPolicy: oldFetchPolicy } = this.options;\n this.options = {\n ...this.options,\n ...opts,\n } as WatchQueryOptions<TVariables>;\n\n if (opts.pollInterval) {\n this.startPolling(opts.pollInterval);\n } else if (opts.pollInterval === 0) {\n this.stopPolling();\n }\n\n const { fetchPolicy } = opts;\n\n return this.setVariables(\n this.options.variables as TVariables,\n // Try to fetch the query if fetchPolicy changed from either cache-only\n // or standby to something else, or changed to network-only.\n oldFetchPolicy !== fetchPolicy && (\n oldFetchPolicy === 'cache-only' ||\n oldFetchPolicy === 'standby' ||\n fetchPolicy === 'network-only'\n ),\n opts.fetchResults,\n );\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 * @param fetchResults: Option to ignore fetching results when updating variables\n */\n public setVariables(\n variables: TVariables,\n tryFetch: boolean = false,\n fetchResults = true,\n ): Promise<ApolloQueryResult<TData> | void> {\n // since setVariables restarts the subscription, we reset the tornDown status\n this.isTornDown = false;\n\n variables = variables || this.variables;\n\n if (!tryFetch && isEqual(variables, this.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 && fetchResults\n ? this.result()\n : Promise.resolve();\n }\n\n this.variables = this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n // Use the same options as before, but with new variables\n return this.queryManager.fetchQuery(\n this.queryId,\n this.options,\n ) as Promise<ApolloQueryResult<TData>>;\n }\n\n public updateQuery<TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: UpdateQueryOptions<TVars>,\n ) => TData,\n ): void {\n const { queryManager } = this;\n const {\n previousResult,\n variables,\n document,\n } = queryManager.getQueryWithPreviousResult<TData, TVars>(\n this.queryId,\n );\n\n const newResult = tryFunctionOrLogError(() =>\n mapFn(previousResult, { variables }),\n );\n\n if (newResult) {\n queryManager.dataStore.markUpdateQueryResult(\n document,\n variables,\n newResult,\n );\n queryManager.broadcastQueries();\n }\n }\n\n public stopPolling() {\n this.queryManager.stopPollingQuery(this.queryId);\n this.options.pollInterval = undefined;\n }\n\n public startPolling(pollInterval: number) {\n assertNotCacheFirstOrOnly(this);\n this.options.pollInterval = pollInterval;\n this.queryManager.startPollingQuery(this.options, this.queryId);\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 return previousResult;\n }\n\n private onSubscribe(observer: Observer<ApolloQueryResult<TData>>) {\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 initial result\n if (observer.next && this.lastResult) observer.next(this.lastResult);\n if (observer.error && this.lastError) observer.error(this.lastError);\n\n // setup the query if it hasn't been done before\n if (first) {\n this.setUpQuery();\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n }\n\n private setUpQuery() {\n const { queryManager, queryId } = this;\n\n if (this.shouldSubscribe) {\n queryManager.addObservableQuery<TData>(queryId, this);\n }\n\n if (this.options.pollInterval) {\n assertNotCacheFirstOrOnly(this);\n queryManager.startPollingQuery(this.options, queryId);\n }\n\n const onError = (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 errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n });\n iterateObserversSafely(this.observers, 'error', this.lastError = error);\n };\n\n queryManager.observeQuery<TData>(queryId, this.options, {\n next: (result: ApolloQueryResult<TData>) => {\n if (this.lastError || this.isDifferentFromLastResult(result)) {\n const previousResult = this.updateLastResult(result);\n const { query, variables, fetchPolicy } = this.options;\n\n // Before calling `next` on each observer, we need to first see if\n // the query is using `@client @export` directives, and update\n // any variables that might have changed. If `@export` variables have\n // changed, and the query is calling against both local and remote\n // data, a refetch is needed to pull in new data, using the\n // updated `@export` variables.\n if (queryManager.transform(query).hasClientExports) {\n queryManager.getLocalState().addExportedVariables(\n query,\n variables,\n ).then((variables: TVariables) => {\n const previousVariables = this.variables;\n this.variables = this.options.variables = variables;\n if (\n !result.loading &&\n previousResult &&\n fetchPolicy !== 'cache-only' &&\n queryManager.transform(query).serverQuery &&\n !isEqual(previousVariables, variables)\n ) {\n this.refetch();\n } else {\n iterateObserversSafely(this.observers, 'next', result);\n }\n });\n } else {\n iterateObserversSafely(this.observers, 'next', result);\n }\n }\n },\n error: onError,\n }).catch(onError);\n }\n\n private tearDownQuery() {\n const { queryManager } = this;\n\n this.isTornDown = true;\n queryManager.stopPollingQuery(this.queryId);\n\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach(sub => sub.unsubscribe());\n this.subscriptions.clear();\n\n queryManager.removeObservableQuery(this.queryId);\n queryManager.stopQuery(this.queryId);\n\n this.observers.clear();\n }\n}\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error('Unhandled error', error.message, error.stack);\n}\n\nfunction iterateObserversSafely<E, A>(\n observers: Set<Observer<E>>,\n method: keyof Observer<E>,\n argument?: A,\n) {\n // In case observers is modified during iteration, we need to commit to the\n // original elements, which also provides an opportunity to filter them down\n // to just the observers with the given method.\n const observersWithMethod: Observer<E>[] = [];\n observers.forEach(obs => obs[method] && observersWithMethod.push(obs));\n observersWithMethod.forEach(obs => (obs as any)[method](argument));\n}\n\nfunction assertNotCacheFirstOrOnly<TData, TVariables>(\n obsQuery: ObservableQuery<TData, TVariables>,\n) {\n const { fetchPolicy } = obsQuery.options;\n invariant(\n fetchPolicy !== 'cache-first' && fetchPolicy !== 'cache-only',\n 'Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.',\n );\n}\n","import { DocumentNode } from 'graphql';\n\nexport class MutationStore {\n private store: { [mutationId: string]: MutationStoreValue } = {};\n\n public getStore(): { [mutationId: string]: MutationStoreValue } {\n return this.store;\n }\n\n public get(mutationId: string): MutationStoreValue {\n return this.store[mutationId];\n }\n\n public initMutation(\n mutationId: string,\n mutation: DocumentNode,\n variables: Object | undefined,\n ) {\n this.store[mutationId] = {\n mutation,\n variables: variables || {},\n loading: true,\n error: null,\n };\n }\n\n public markMutationError(mutationId: string, error: Error) {\n const mutation = this.store[mutationId];\n if (mutation) {\n mutation.loading = false;\n mutation.error = error;\n }\n }\n\n public markMutationResult(mutationId: string) {\n const mutation = this.store[mutationId];\n if (mutation) {\n mutation.loading = false;\n mutation.error = null;\n }\n }\n\n public reset() {\n this.store = {};\n }\n}\n\nexport interface MutationStoreValue {\n mutation: DocumentNode;\n variables: Object;\n loading: boolean;\n error: Error | null;\n}\n","import { DocumentNode, GraphQLError, ExecutionResult } from 'graphql';\nimport { isEqual } from 'apollo-utilities';\nimport { invariant } from 'ts-invariant';\nimport { NetworkStatus } from '../core/networkStatus';\nimport { isNonEmptyArray } from '../util/arrays';\n\nexport type QueryStoreValue = {\n document: DocumentNode;\n variables: Object;\n previousVariables?: Object | null;\n networkStatus: NetworkStatus;\n networkError?: Error | null;\n graphQLErrors?: ReadonlyArray<GraphQLError>;\n metadata: any;\n};\n\nexport class QueryStore {\n private store: { [queryId: string]: QueryStoreValue } = {};\n\n public getStore(): { [queryId: string]: QueryStoreValue } {\n return this.store;\n }\n\n public get(queryId: string): QueryStoreValue {\n return this.store[queryId];\n }\n\n public initQuery(query: {\n queryId: string;\n document: DocumentNode;\n storePreviousVariables: boolean;\n variables: Object;\n isPoll: boolean;\n isRefetch: boolean;\n metadata: any;\n fetchMoreForQueryId: string | undefined;\n }) {\n const previousQuery = this.store[query.queryId];\n\n // XXX we're throwing an error here to catch bugs where a query gets overwritten by a new one.\n // we should implement a separate action for refetching so that QUERY_INIT may never overwrite\n // an existing query (see also: https://github.com/apollostack/apollo-client/issues/732)\n invariant(\n !previousQuery ||\n previousQuery.document === query.document ||\n isEqual(previousQuery.document, query.document),\n 'Internal Error: may not update existing query string in store',\n );\n\n let isSetVariables = false;\n\n let previousVariables: Object | null = null;\n if (\n query.storePreviousVariables &&\n previousQuery &&\n previousQuery.networkStatus !== NetworkStatus.loading\n // if the previous query was still loading, we don't want to remember it at all.\n ) {\n if (!isEqual(previousQuery.variables, query.variables)) {\n isSetVariables = true;\n previousVariables = previousQuery.variables;\n }\n }\n\n // TODO break this out into a separate function\n let networkStatus;\n if (isSetVariables) {\n networkStatus = NetworkStatus.setVariables;\n } else if (query.isPoll) {\n networkStatus = NetworkStatus.poll;\n } else if (query.isRefetch) {\n networkStatus = NetworkStatus.refetch;\n // TODO: can we determine setVariables here if it's a refetch and the variables have changed?\n } else {\n networkStatus = NetworkStatus.loading;\n }\n\n let graphQLErrors: ReadonlyArray<GraphQLError> = [];\n if (previousQuery && previousQuery.graphQLErrors) {\n graphQLErrors = previousQuery.graphQLErrors;\n }\n\n // XXX right now if QUERY_INIT is fired twice, like in a refetch situation, we just overwrite\n // the store. We probably want a refetch action instead, because I suspect that if you refetch\n // before the initial fetch is done, you'll get an error.\n this.store[query.queryId] = {\n document: query.document,\n variables: query.variables,\n previousVariables,\n networkError: null,\n graphQLErrors: graphQLErrors,\n networkStatus,\n metadata: query.metadata,\n };\n\n // If the action had a `moreForQueryId` property then we need to set the\n // network status on that query as well to `fetchMore`.\n //\n // We have a complement to this if statement in the query result and query\n // error action branch, but importantly *not* in the client result branch.\n // This is because the implementation of `fetchMore` *always* sets\n // `fetchPolicy` to `network-only` so we would never have a client result.\n if (\n typeof query.fetchMoreForQueryId === 'string' &&\n this.store[query.fetchMoreForQueryId]\n ) {\n this.store[query.fetchMoreForQueryId].networkStatus =\n NetworkStatus.fetchMore;\n }\n }\n\n public markQueryResult(\n queryId: string,\n result: ExecutionResult,\n fetchMoreForQueryId: string | undefined,\n ) {\n if (!this.store || !this.store[queryId]) return;\n\n this.store[queryId].networkError = null;\n this.store[queryId].graphQLErrors = isNonEmptyArray(result.errors) ? result.errors : [];\n this.store[queryId].previousVariables = null;\n this.store[queryId].networkStatus = NetworkStatus.ready;\n\n // If we have a `fetchMoreForQueryId` then we need to update the network\n // status for that query. See the branch for query initialization for more\n // explanation about this process.\n if (\n typeof fetchMoreForQueryId === 'string' &&\n this.store[fetchMoreForQueryId]\n ) {\n this.store[fetchMoreForQueryId].networkStatus = NetworkStatus.ready;\n }\n }\n\n public markQueryError(\n queryId: string,\n error: Error,\n fetchMoreForQueryId: string | undefined,\n ) {\n if (!this.store || !this.store[queryId]) return;\n\n this.store[queryId].networkError = error;\n this.store[queryId].networkStatus = NetworkStatus.error;\n\n // If we have a `fetchMoreForQueryId` then we need to update the network\n // status for that query. See the branch for query initialization for more\n // explanation about this process.\n if (typeof fetchMoreForQueryId === 'string') {\n this.markQueryResultClient(fetchMoreForQueryId, true);\n }\n }\n\n public markQueryResultClient(queryId: string, complete: boolean) {\n const storeValue = this.store && this.store[queryId];\n if (storeValue) {\n storeValue.networkError = null;\n storeValue.previousVariables = null;\n if (complete) {\n storeValue.networkStatus = NetworkStatus.ready;\n }\n }\n }\n\n public stopQuery(queryId: string) {\n delete this.store[queryId];\n }\n\n public reset(observableQueryIds: string[]) {\n Object.keys(this.store).forEach(queryId => {\n if (observableQueryIds.indexOf(queryId) < 0) {\n this.stopQuery(queryId);\n } else {\n // XXX set loading to true so listeners don't trigger unless they want results with partial data\n this.store[queryId].networkStatus = NetworkStatus.loading;\n }\n });\n }\n}\n","export function capitalizeFirstLetter(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n","import {\n DocumentNode,\n OperationDefinitionNode,\n SelectionSetNode,\n SelectionNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n FieldNode,\n ASTNode,\n} from 'graphql';\nimport { visit, BREAK } from 'graphql/language/visitor';\n\nimport { ApolloCache } from 'apollo-cache';\nimport {\n getMainDefinition,\n buildQueryFromSelectionSet,\n hasDirectives,\n removeClientSetsFromDocument,\n mergeDeep,\n mergeDeepArray,\n FragmentMap,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getFragmentDefinitions,\n createFragmentMap,\n shouldInclude,\n isField,\n isInlineFragment,\n} from 'apollo-utilities';\nimport { FetchResult } from 'apollo-link';\n\nimport { invariant } from 'ts-invariant';\n\nimport ApolloClient from '../ApolloClient';\nimport { Resolvers, OperationVariables } from './types';\nimport { capitalizeFirstLetter } from '../util/capitalizeFirstLetter';\n\nexport type Resolver = (\n rootValue?: any,\n args?: any,\n context?: any,\n info?: {\n field: FieldNode;\n fragmentMap: FragmentMap;\n },\n) => any;\n\nexport type VariableMap = { [name: string]: any };\n\nexport type FragmentMatcher = (\n rootValue: any,\n typeCondition: string,\n context: any,\n) => boolean;\n\nexport type ExecContext = {\n fragmentMap: FragmentMap;\n context: any;\n variables: VariableMap;\n fragmentMatcher: FragmentMatcher;\n defaultOperationType: string;\n exportedVariables: Record<string, any>;\n onlyRunForcedResolvers: boolean;\n};\n\nexport type LocalStateOptions<TCacheShape> = {\n cache: ApolloCache<TCacheShape>;\n client?: ApolloClient<TCacheShape>;\n resolvers?: Resolvers | Resolvers[];\n fragmentMatcher?: FragmentMatcher;\n};\n\nexport class LocalState<TCacheShape> {\n private cache: ApolloCache<TCacheShape>;\n private client: ApolloClient<TCacheShape>;\n private resolvers?: Resolvers;\n private fragmentMatcher: FragmentMatcher;\n\n constructor({\n cache,\n client,\n resolvers,\n fragmentMatcher,\n }: LocalStateOptions<TCacheShape>) {\n this.cache = cache;\n\n if (client) {\n this.client = client;\n }\n\n if (resolvers) {\n this.addResolvers(resolvers);\n }\n\n if (fragmentMatcher) {\n this.setFragmentMatcher(fragmentMatcher);\n }\n }\n\n public addResolvers(resolvers: Resolvers | Resolvers[]) {\n this.resolvers = this.resolvers || {};\n if (Array.isArray(resolvers)) {\n resolvers.forEach(resolverGroup => {\n this.resolvers = mergeDeep(this.resolvers, resolverGroup);\n });\n } else {\n this.resolvers = mergeDeep(this.resolvers, resolvers);\n }\n }\n\n public setResolvers(resolvers: Resolvers | Resolvers[]) {\n this.resolvers = {};\n this.addResolvers(resolvers);\n }\n\n public getResolvers() {\n return this.resolvers || {};\n }\n\n // Run local client resolvers against the incoming query and remote data.\n // Locally resolved field values are merged with the incoming remote data,\n // and returned. Note that locally resolved fields will overwrite\n // remote data using the same field name.\n public async runResolvers<TData>({\n document,\n remoteResult,\n context,\n variables,\n onlyRunForcedResolvers = false,\n }: {\n document: DocumentNode | null;\n remoteResult: FetchResult<TData>;\n context?: Record<string, any>;\n variables?: Record<string, any>;\n onlyRunForcedResolvers?: boolean;\n }): Promise<FetchResult<TData>> {\n if (document) {\n return this.resolveDocument(\n document,\n remoteResult.data,\n context,\n variables,\n this.fragmentMatcher,\n onlyRunForcedResolvers,\n ).then(localResult => ({\n ...remoteResult,\n data: localResult.result,\n }));\n }\n\n return remoteResult;\n }\n\n public setFragmentMatcher(fragmentMatcher: FragmentMatcher) {\n this.fragmentMatcher = fragmentMatcher;\n }\n\n public getFragmentMatcher(): FragmentMatcher {\n return this.fragmentMatcher;\n }\n\n // Client queries contain everything in the incoming document (if a @client\n // directive is found).\n public clientQuery(document: DocumentNode) {\n if (hasDirectives(['client'], document)) {\n if (this.resolvers) {\n return document;\n }\n invariant.warn(\n 'Found @client directives in a query but no ApolloClient resolvers ' +\n 'were specified. This means ApolloClient local resolver handling ' +\n 'has been disabled, and @client directives will be passed through ' +\n 'to your link chain.',\n );\n }\n return null;\n }\n\n // Server queries are stripped of all @client based selection sets.\n public serverQuery(document: DocumentNode) {\n return this.resolvers ? removeClientSetsFromDocument(document) : document;\n }\n\n public prepareContext(context = {}) {\n const { cache } = this;\n\n const newContext = {\n ...context,\n cache,\n // Getting an entry's cache key is useful for local state resolvers.\n getCacheKey: (obj: { __typename: string; id: string | number }) => {\n if ((cache as any).config) {\n return (cache as any).config.dataIdFromObject(obj);\n } else {\n invariant(false,\n 'To use context.getCacheKey, you need to use a cache that has ' +\n 'a configurable dataIdFromObject, like apollo-cache-inmemory.',\n );\n }\n },\n };\n\n return newContext;\n }\n\n // To support `@client @export(as: \"someVar\")` syntax, we'll first resolve\n // @client @export fields locally, then pass the resolved values back to be\n // used alongside the original operation variables.\n public async addExportedVariables(\n document: DocumentNode,\n variables: OperationVariables = {},\n context = {},\n ) {\n if (document) {\n return this.resolveDocument(\n document,\n this.buildRootValueFromCache(document, variables) || {},\n this.prepareContext(context),\n variables,\n ).then(data => ({\n ...variables,\n ...data.exportedVariables,\n }));\n }\n\n return {\n ...variables,\n };\n }\n\n public shouldForceResolvers(document: ASTNode) {\n let forceResolvers = false;\n visit(document, {\n Directive: {\n enter(node) {\n if (node.name.value === 'client' && node.arguments) {\n forceResolvers = node.arguments.some(\n arg =>\n arg.name.value === 'always' &&\n arg.value.kind === 'BooleanValue' &&\n arg.value.value === true,\n );\n if (forceResolvers) {\n return BREAK;\n }\n }\n },\n },\n });\n return forceResolvers;\n }\n\n // Query the cache and return matching data.\n private buildRootValueFromCache(\n document: DocumentNode,\n variables?: Record<string, any>,\n ) {\n return this.cache.diff({\n query: buildQueryFromSelectionSet(document),\n variables,\n returnPartialData: true,\n optimistic: false,\n }).result;\n }\n\n private async resolveDocument<TData>(\n document: DocumentNode,\n rootValue: TData,\n context: any = {},\n variables: VariableMap = {},\n fragmentMatcher: FragmentMatcher = () => true,\n onlyRunForcedResolvers: boolean = false,\n ) {\n const mainDefinition = getMainDefinition(document);\n const fragments = getFragmentDefinitions(document);\n const fragmentMap = createFragmentMap(fragments);\n\n const definitionOperation = (mainDefinition as OperationDefinitionNode)\n .operation;\n\n const defaultOperationType = definitionOperation\n ? capitalizeFirstLetter(definitionOperation)\n : 'Query';\n\n const { cache, client } = this;\n const execContext: ExecContext = {\n fragmentMap,\n context: {\n ...context,\n cache,\n client,\n },\n variables,\n fragmentMatcher,\n defaultOperationType,\n exportedVariables: {},\n onlyRunForcedResolvers,\n };\n\n return this.resolveSelectionSet(\n mainDefinition.selectionSet,\n rootValue,\n execContext,\n ).then(result => ({\n result,\n exportedVariables: execContext.exportedVariables,\n }));\n }\n\n private async resolveSelectionSet<TData>(\n selectionSet: SelectionSetNode,\n rootValue: TData,\n execContext: ExecContext,\n ) {\n const { fragmentMap, context, variables } = execContext;\n const resultsToMerge: TData[] = [rootValue];\n\n const execute = async (selection: SelectionNode): Promise<void> => {\n if (!shouldInclude(selection, variables)) {\n // Skip this entirely.\n return;\n }\n\n if (isField(selection)) {\n return this.resolveField(selection, rootValue, execContext).then(\n fieldResult => {\n if (typeof fieldResult !== 'undefined') {\n resultsToMerge.push({\n [resultKeyNameFromField(selection)]: fieldResult,\n } as TData);\n }\n },\n );\n }\n\n let fragment: InlineFragmentNode | FragmentDefinitionNode;\n\n if (isInlineFragment(selection)) {\n fragment = selection;\n } else {\n // This is a named fragment.\n fragment = fragmentMap[selection.name.value];\n invariant(fragment, `No fragment named ${selection.name.value}`);\n }\n\n if (fragment && fragment.typeCondition) {\n const typeCondition = fragment.typeCondition.name.value;\n if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {\n return this.resolveSelectionSet(\n fragment.selectionSet,\n rootValue,\n execContext,\n ).then(fragmentResult => {\n resultsToMerge.push(fragmentResult);\n });\n }\n }\n };\n\n return Promise.all(selectionSet.selections.map(execute)).then(function() {\n return mergeDeepArray(resultsToMerge);\n });\n }\n\n private async resolveField(\n field: FieldNode,\n rootValue: any,\n execContext: ExecContext,\n ): Promise<any> {\n const { variables } = execContext;\n const fieldName = field.name.value;\n const aliasedFieldName = resultKeyNameFromField(field);\n const aliasUsed = fieldName !== aliasedFieldName;\n const defaultResult = rootValue[aliasedFieldName] || rootValue[fieldName];\n let resultPromise = Promise.resolve(defaultResult);\n\n // Usually all local resolvers are run when passing through here, but\n // if we've specifically identified that we only want to run forced\n // resolvers (that is, resolvers for fields marked with\n // `@client(always: true)`), then we'll skip running non-forced resolvers.\n if (\n !execContext.onlyRunForcedResolvers ||\n this.shouldForceResolvers(field)\n ) {\n const resolverType =\n rootValue.__typename || execContext.defaultOperationType;\n const resolverMap = this.resolvers && this.resolvers[resolverType];\n if (resolverMap) {\n const resolve = resolverMap[aliasUsed ? fieldName : aliasedFieldName];\n if (resolve) {\n resultPromise = Promise.resolve(resolve(\n rootValue,\n argumentsObjectFromField(field, variables),\n execContext.context,\n { field, fragmentMap: execContext.fragmentMap },\n ));\n }\n }\n }\n\n return resultPromise.then((result = defaultResult) => {\n // If an @export directive is associated with the current field, store\n // the `as` export variable name and current result for later use.\n if (field.directives) {\n field.directives.forEach(directive => {\n if (directive.name.value === 'export' && directive.arguments) {\n directive.arguments.forEach(arg => {\n if (arg.name.value === 'as' && arg.value.kind === 'StringValue') {\n execContext.exportedVariables[arg.value.value] = result;\n }\n });\n }\n });\n }\n\n // Handle all scalar types here.\n if (!field.selectionSet) {\n return result;\n }\n\n // From here down, the field has a selection set, which means it's trying\n // to query a GraphQLObjectType.\n if (result == null) {\n // Basically any field in a GraphQL response can be null, or missing\n return result;\n }\n\n if (Array.isArray(result)) {\n return this.resolveSubSelectedArray(field, result, execContext);\n }\n\n // Returned value is an object, and the query has a sub-selection. Recurse.\n if (field.selectionSet) {\n return this.resolveSelectionSet(\n field.selectionSet,\n result,\n execContext,\n );\n }\n });\n }\n\n private resolveSubSelectedArray(\n field: FieldNode,\n result: any[],\n execContext: ExecContext,\n ): any {\n return Promise.all(\n result.map(item => {\n if (item === null) {\n return null;\n }\n\n // This is a nested array, recurse.\n if (Array.isArray(item)) {\n return this.resolveSubSelectedArray(field, item, execContext);\n }\n\n // This is an object, run the selection set on it.\n if (field.selectionSet) {\n return this.resolveSelectionSet(field.selectionSet, item, execContext);\n }\n }),\n );\n }\n}\n","import { Observable, Observer, Subscription } from './Observable';\n\n// Returns a normal Observable that can have any number of subscribers,\n// while ensuring the original Observable gets subscribed to at most once.\nexport function multiplex<T>(inner: Observable<T>): Observable<T> {\n const observers = new Set<Observer<T>>();\n let sub: Subscription | null = null;\n return new Observable<T>(observer => {\n observers.add(observer);\n sub = sub || inner.subscribe({\n next(value) {\n observers.forEach(obs => obs.next && obs.next(value));\n },\n error(error) {\n observers.forEach(obs => obs.error && obs.error(error));\n },\n complete() {\n observers.forEach(obs => obs.complete && obs.complete());\n },\n });\n return () => {\n if (observers.delete(observer) && !observers.size && sub) {\n sub.unsubscribe();\n sub = null;\n }\n };\n });\n}\n\n// Like Observable.prototype.map, except that the mapping function can\n// optionally return a Promise (or be async).\nexport function asyncMap<V, R>(\n observable: Observable<V>,\n mapFn: (value: V) => R | Promise<R>,\n): Observable<R> {\n return new Observable<R>(observer => {\n const { next, error, complete } = observer;\n let activeNextCount = 0;\n let completed = false;\n\n const handler: Observer<V> = {\n next(value) {\n ++activeNextCount;\n new Promise(resolve => {\n resolve(mapFn(value));\n }).then(\n result => {\n --activeNextCount;\n next && next.call(observer, result);\n completed && handler.complete!();\n },\n e => {\n --activeNextCount;\n error && error.call(observer, e);\n },\n );\n },\n error(e) {\n error && error.call(observer, e);\n },\n complete() {\n completed = true;\n if (!activeNextCount) {\n complete && complete.call(observer);\n }\n },\n };\n\n const sub = observable.subscribe(handler);\n return () => sub.unsubscribe();\n });\n}\n","import { execute, ApolloLink, FetchResult } from 'apollo-link';\nimport { DocumentNode } from 'graphql';\nimport { Cache } from 'apollo-cache';\nimport {\n getDefaultValues,\n getOperationDefinition,\n getOperationName,\n hasDirectives,\n graphQLResultHasError,\n hasClientExports,\n removeConnectionDirectiveFromDocument,\n canUseWeakMap,\n} from 'apollo-utilities';\n\nimport { invariant, InvariantError } from 'ts-invariant';\n\nimport { isApolloError, ApolloError } from '../errors/ApolloError';\nimport { Observer, Subscription, Observable } from '../util/Observable';\nimport { QueryWithUpdater, DataStore } from '../data/store';\nimport { MutationStore } from '../data/mutations';\nimport { QueryStore, QueryStoreValue } from '../data/queries';\n\nimport {\n QueryOptions,\n WatchQueryOptions,\n SubscriptionOptions,\n MutationOptions,\n ErrorPolicy,\n} from './watchQueryOptions';\nimport { ObservableQuery } from './ObservableQuery';\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport {\n QueryListener,\n ApolloQueryResult,\n FetchType,\n OperationVariables,\n} from './types';\nimport { LocalState } from './LocalState';\nimport { asyncMap, multiplex } from '../util/observables';\nimport { isNonEmptyArray } from '../util/arrays';\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport interface QueryInfo {\n listeners: Set<QueryListener>;\n invalidated: boolean;\n newData: Cache.DiffResult<any> | null;\n document: DocumentNode | null;\n lastRequestId: number;\n // A map going from queryId to an observer for a query issued by watchQuery. We use\n // these to keep track of queries that are inflight and error on the observers associated\n // with them in case of some destabalizing action (e.g. reset of the Apollo store).\n observableQuery: ObservableQuery<any> | null;\n subscriptions: Set<Subscription>;\n cancel?: () => void;\n}\n\nexport class QueryManager<TStore> {\n public link: ApolloLink;\n public mutationStore: MutationStore = new MutationStore();\n public queryStore: QueryStore = new QueryStore();\n public dataStore: DataStore<TStore>;\n public readonly assumeImmutableResults: boolean;\n\n private queryDeduplication: boolean;\n private clientAwareness: Record<string, string> = {};\n private localState: LocalState<TStore>;\n\n private onBroadcast: () => void;\n\n private ssrMode: boolean;\n\n // let's not start at zero to avoid pain with bad checks\n private idCounter = 1;\n\n // XXX merge with ObservableQuery but that needs to be expanded to support mutations and\n // subscriptions as well\n private queries: Map<string, QueryInfo> = new Map();\n\n // A map of Promise reject functions for fetchQuery promises that have not\n // yet been resolved, used to keep track of in-flight queries so that we can\n // reject them in case a destabilizing event occurs (e.g. Apollo store reset).\n // The key is in the format of `query:${queryId}` or `fetchRequest:${queryId}`,\n // depending on where the promise's rejection function was created from.\n private fetchQueryRejectFns = new Map<string, Function>();\n\n constructor({\n link,\n queryDeduplication = false,\n store,\n onBroadcast = () => undefined,\n ssrMode = false,\n clientAwareness = {},\n localState,\n assumeImmutableResults,\n }: {\n link: ApolloLink;\n queryDeduplication?: boolean;\n store: DataStore<TStore>;\n onBroadcast?: () => void;\n ssrMode?: boolean;\n clientAwareness?: Record<string, string>;\n localState?: LocalState<TStore>;\n assumeImmutableResults?: boolean;\n }) {\n this.link = link;\n this.queryDeduplication = queryDeduplication;\n this.dataStore = store;\n this.onBroadcast = onBroadcast;\n this.clientAwareness = clientAwareness;\n this.localState = localState || new LocalState({ cache: store.getCache() });\n this.ssrMode = ssrMode;\n this.assumeImmutableResults = !!assumeImmutableResults;\n }\n\n /**\n * Call this method to terminate any active query processes, making it safe\n * to dispose of this QueryManager instance.\n */\n public stop() {\n this.queries.forEach((_info, queryId) => {\n this.stopQueryNoBroadcast(queryId);\n });\n\n this.fetchQueryRejectFns.forEach(reject => {\n reject(\n new InvariantError('QueryManager stopped while query was in flight'),\n );\n });\n }\n\n public async mutate<T>({\n mutation,\n variables,\n optimisticResponse,\n updateQueries: updateQueriesByName,\n refetchQueries = [],\n awaitRefetchQueries = false,\n update: updateWithProxyFn,\n errorPolicy = 'none',\n fetchPolicy,\n context = {},\n }: MutationOptions): Promise<FetchResult<T>> {\n invariant(\n mutation,\n 'mutation option is required. You must specify your GraphQL document in the mutation option.',\n );\n\n invariant(\n !fetchPolicy || fetchPolicy === 'no-cache',\n \"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.\"\n );\n\n const mutationId = this.generateQueryId();\n mutation = this.transform(mutation).document;\n\n this.setQuery(mutationId, () => ({ document: mutation }));\n\n variables = this.getVariables(mutation, variables);\n\n if (this.transform(mutation).hasClientExports) {\n variables = await this.localState.addExportedVariables(mutation, variables, context);\n }\n\n // Create a map of update queries by id to the query instead of by name.\n const generateUpdateQueriesInfo: () => {\n [queryId: string]: QueryWithUpdater;\n } = () => {\n const ret: { [queryId: string]: QueryWithUpdater } = {};\n\n if (updateQueriesByName) {\n this.queries.forEach(({ observableQuery }, queryId) => {\n if (observableQuery) {\n const { queryName } = observableQuery;\n if (\n queryName &&\n hasOwnProperty.call(updateQueriesByName, queryName)\n ) {\n ret[queryId] = {\n updater: updateQueriesByName[queryName],\n query: this.queryStore.get(queryId),\n };\n }\n }\n });\n }\n\n return ret;\n };\n\n this.mutationStore.initMutation(\n mutationId,\n mutation,\n variables,\n );\n\n this.dataStore.markMutationInit({\n mutationId,\n document: mutation,\n variables,\n updateQueries: generateUpdateQueriesInfo(),\n update: updateWithProxyFn,\n optimisticResponse,\n });\n\n this.broadcastQueries();\n\n const self = this;\n\n return new Promise((resolve, reject) => {\n let storeResult: FetchResult<T> | null;\n let error: ApolloError;\n\n self.getObservableFromLink(\n mutation,\n {\n ...context,\n optimisticResponse,\n },\n variables,\n false,\n ).subscribe({\n next(result: FetchResult<T>) {\n if (graphQLResultHasError(result) && errorPolicy === 'none') {\n error = new ApolloError({\n graphQLErrors: result.errors,\n });\n return;\n }\n\n self.mutationStore.markMutationResult(mutationId);\n\n if (fetchPolicy !== 'no-cache') {\n self.dataStore.markMutationResult({\n mutationId,\n result,\n document: mutation,\n variables,\n updateQueries: generateUpdateQueriesInfo(),\n update: updateWithProxyFn,\n });\n }\n\n storeResult = result;\n },\n\n error(err: Error) {\n self.mutationStore.markMutationError(mutationId, err);\n self.dataStore.markMutationComplete({\n mutationId,\n optimisticResponse,\n });\n self.broadcastQueries();\n self.setQuery(mutationId, () => ({ document: null }));\n reject(\n new ApolloError({\n networkError: err,\n }),\n );\n },\n\n complete() {\n if (error) {\n self.mutationStore.markMutationError(mutationId, error);\n }\n\n self.dataStore.markMutationComplete({\n mutationId,\n optimisticResponse,\n });\n\n self.broadcastQueries();\n\n if (error) {\n reject(error);\n return;\n }\n\n // allow for conditional refetches\n // XXX do we want to make this the only API one day?\n if (typeof refetchQueries === 'function') {\n refetchQueries = refetchQueries(storeResult!);\n }\n\n const refetchQueryPromises: Promise<\n ApolloQueryResult<any>[] | ApolloQueryResult<{}>\n >[] = [];\n\n if (isNonEmptyArray(refetchQueries)) {\n refetchQueries.forEach(refetchQuery => {\n if (typeof refetchQuery === 'string') {\n self.queries.forEach(({ observableQuery }) => {\n if (\n observableQuery &&\n observableQuery.queryName === refetchQuery\n ) {\n refetchQueryPromises.push(observableQuery.refetch());\n }\n });\n } else {\n const queryOptions: QueryOptions = {\n query: refetchQuery.query,\n variables: refetchQuery.variables,\n fetchPolicy: 'network-only',\n };\n\n if (refetchQuery.context) {\n queryOptions.context = refetchQuery.context;\n }\n\n refetchQueryPromises.push(self.query(queryOptions));\n }\n });\n }\n\n Promise.all(\n awaitRefetchQueries ? refetchQueryPromises : [],\n ).then(() => {\n self.setQuery(mutationId, () => ({ document: null }));\n\n if (\n errorPolicy === 'ignore' &&\n storeResult &&\n graphQLResultHasError(storeResult)\n ) {\n delete storeResult.errors;\n }\n\n resolve(storeResult!);\n });\n },\n });\n });\n }\n\n public async fetchQuery<T>(\n queryId: string,\n options: WatchQueryOptions,\n fetchType?: FetchType,\n // This allows us to track if this is a query spawned by a `fetchMore`\n // call for another query. We need this data to compute the `fetchMore`\n // network status for the query this is fetching for.\n fetchMoreForQueryId?: string,\n ): Promise<FetchResult<T>> {\n const {\n metadata = null,\n fetchPolicy = 'cache-first', // cache-first is the default fetch policy.\n context = {},\n } = options;\n\n const query = this.transform(options.query).document;\n\n let variables = this.getVariables(query, options.variables);\n\n if (this.transform(query).hasClientExports) {\n variables = await this.localState.addExportedVariables(query, variables, context);\n }\n\n options = { ...options, variables };\n\n let storeResult: any;\n const isNetworkOnly =\n fetchPolicy === 'network-only' || fetchPolicy === 'no-cache';\n let needToFetch = isNetworkOnly;\n\n // Unless we are completely skipping the cache, we want to diff the query\n // against the cache before we fetch it from the network interface.\n if (!isNetworkOnly) {\n const { complete, result } = this.dataStore.getCache().diff({\n query,\n variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n // If we're in here, only fetch if we have missing fields\n needToFetch = !complete || fetchPolicy === 'cache-and-network';\n storeResult = result;\n }\n\n let shouldFetch =\n needToFetch && fetchPolicy !== 'cache-only' && fetchPolicy !== 'standby';\n\n // we need to check to see if this is an operation that uses the @live directive\n if (hasDirectives(['live'], query)) shouldFetch = true;\n\n const requestId = this.idCounter++;\n\n // set up a watcher to listen to cache updates\n const cancel = fetchPolicy !== 'no-cache'\n ? this.updateQueryWatch(queryId, query, options)\n : undefined;\n\n // Initialize query in store with unique requestId\n this.setQuery(queryId, () => ({\n document: query,\n lastRequestId: requestId,\n invalidated: true,\n cancel,\n }));\n\n this.invalidate(fetchMoreForQueryId);\n\n this.queryStore.initQuery({\n queryId,\n document: query,\n storePreviousVariables: shouldFetch,\n variables,\n isPoll: fetchType === FetchType.poll,\n isRefetch: fetchType === FetchType.refetch,\n metadata,\n fetchMoreForQueryId,\n });\n\n this.broadcastQueries();\n\n if (shouldFetch) {\n const networkResult = this.fetchRequest<T>({\n requestId,\n queryId,\n document: query,\n options,\n fetchMoreForQueryId,\n }).catch(error => {\n // This is for the benefit of `refetch` promises, which currently don't get their errors\n // through the store like watchQuery observers do\n if (isApolloError(error)) {\n throw error;\n } else {\n if (requestId >= this.getQuery(queryId).lastRequestId) {\n this.queryStore.markQueryError(queryId, error, fetchMoreForQueryId);\n this.invalidate(queryId);\n this.invalidate(fetchMoreForQueryId);\n this.broadcastQueries();\n }\n throw new ApolloError({ networkError: error });\n }\n });\n\n // we don't return the promise for cache-and-network since it is already\n // returned below from the cache\n if (fetchPolicy !== 'cache-and-network') {\n return networkResult;\n }\n\n // however we need to catch the error so it isn't unhandled in case of\n // network error\n networkResult.catch(() => {});\n }\n\n // If there is no part of the query we need to fetch from the server (or,\n // fetchPolicy is cache-only), we just write the store result as the final result.\n this.queryStore.markQueryResultClient(queryId, !shouldFetch);\n this.invalidate(queryId);\n this.invalidate(fetchMoreForQueryId);\n\n if (this.transform(query).hasForcedResolvers) {\n return this.localState.runResolvers({\n document: query,\n remoteResult: { data: storeResult },\n context,\n variables,\n onlyRunForcedResolvers: true,\n }).then((result: FetchResult<T>) => {\n this.markQueryResult(\n queryId,\n result,\n options,\n fetchMoreForQueryId,\n );\n this.broadcastQueries();\n return result;\n });\n }\n\n this.broadcastQueries();\n\n // If we have no query to send to the server, we should return the result\n // found within the store.\n return { data: storeResult };\n }\n\n private markQueryResult<TData>(\n queryId: string,\n result: FetchResult<TData>,\n {\n fetchPolicy,\n variables,\n errorPolicy,\n }: WatchQueryOptions,\n fetchMoreForQueryId?: string,\n ) {\n if (fetchPolicy === 'no-cache') {\n this.setQuery(queryId, () => ({\n newData: { result: result.data, complete: true },\n }));\n } else {\n this.dataStore.markQueryResult(\n result,\n this.getQuery(queryId).document!,\n variables,\n fetchMoreForQueryId,\n errorPolicy === 'ignore' || errorPolicy === 'all',\n );\n }\n }\n\n // Returns a query listener that will update the given observer based on the\n // results (or lack thereof) for a particular query.\n public queryListenerForObserver<T>(\n queryId: string,\n options: WatchQueryOptions,\n observer: Observer<ApolloQueryResult<T>>,\n ): QueryListener {\n function invoke(method: 'next' | 'error', argument: any) {\n if (observer[method]) {\n try {\n observer[method]!(argument);\n } catch (e) {\n invariant.error(e);\n }\n } else if (method === 'error') {\n invariant.error(argument);\n }\n }\n\n return (\n queryStoreValue: QueryStoreValue,\n newData?: Cache.DiffResult<T>,\n ) => {\n // we're going to take a look at the data, so the query is no longer invalidated\n this.invalidate(queryId, false);\n\n // The query store value can be undefined in the event of a store\n // reset.\n if (!queryStoreValue) return;\n\n const { observableQuery, document } = this.getQuery(queryId);\n\n const fetchPolicy = observableQuery\n ? observableQuery.options.fetchPolicy\n : options.fetchPolicy;\n\n // don't watch the store for queries on standby\n if (fetchPolicy === 'standby') return;\n\n const loading = isNetworkRequestInFlight(queryStoreValue.networkStatus);\n const lastResult = observableQuery && observableQuery.getLastResult();\n\n const networkStatusChanged = !!(\n lastResult &&\n lastResult.networkStatus !== queryStoreValue.networkStatus\n );\n\n const shouldNotifyIfLoading =\n options.returnPartialData ||\n (!newData && queryStoreValue.previousVariables) ||\n (networkStatusChanged && options.notifyOnNetworkStatusChange) ||\n fetchPolicy === 'cache-only' ||\n fetchPolicy === 'cache-and-network';\n\n if (loading && !shouldNotifyIfLoading) {\n return;\n }\n\n const hasGraphQLErrors = isNonEmptyArray(queryStoreValue.graphQLErrors);\n\n const errorPolicy: ErrorPolicy = observableQuery\n && observableQuery.options.errorPolicy\n || options.errorPolicy\n || 'none';\n\n // If we have either a GraphQL error or a network error, we create\n // an error and tell the observer about it.\n if (errorPolicy === 'none' && hasGraphQLErrors || queryStoreValue.networkError) {\n return invoke('error', new ApolloError({\n graphQLErrors: queryStoreValue.graphQLErrors,\n networkError: queryStoreValue.networkError,\n }));\n }\n\n try {\n let data: any;\n let isMissing: boolean;\n\n if (newData) {\n // As long as we're using the cache, clear out the latest\n // `newData`, since it will now become the current data. We need\n // to keep the `newData` stored with the query when using\n // `no-cache` since `getCurrentQueryResult` attemps to pull from\n // `newData` first, following by trying the cache (which won't\n // find a hit for `no-cache`).\n if (fetchPolicy !== 'no-cache' && fetchPolicy !== 'network-only') {\n this.setQuery(queryId, () => ({ newData: null }));\n }\n\n data = newData.result;\n isMissing = !newData.complete;\n } else {\n const lastError = observableQuery && observableQuery.getLastError();\n const errorStatusChanged =\n errorPolicy !== 'none' &&\n (lastError && lastError.graphQLErrors) !==\n queryStoreValue.graphQLErrors;\n\n if (lastResult && lastResult.data && !errorStatusChanged) {\n data = lastResult.data;\n isMissing = false;\n } else {\n const diffResult = this.dataStore.getCache().diff({\n query: document as DocumentNode,\n variables:\n queryStoreValue.previousVariables ||\n queryStoreValue.variables,\n returnPartialData: true,\n optimistic: true,\n });\n\n data = diffResult.result;\n isMissing = !diffResult.complete;\n }\n }\n\n // If there is some data missing and the user has told us that they\n // do not tolerate partial data then we want to return the previous\n // result and mark it as stale.\n const stale = isMissing && !(\n options.returnPartialData ||\n fetchPolicy === 'cache-only'\n );\n\n const resultFromStore: ApolloQueryResult<T> = {\n data: stale ? lastResult && lastResult.data : data,\n loading,\n networkStatus: queryStoreValue.networkStatus,\n stale,\n };\n\n // if the query wants updates on errors we need to add it to the result\n if (errorPolicy === 'all' && hasGraphQLErrors) {\n resultFromStore.errors = queryStoreValue.graphQLErrors;\n }\n\n invoke('next', resultFromStore);\n\n } catch (networkError) {\n invoke('error', new ApolloError({ networkError }));\n }\n };\n }\n\n private transformCache = new (canUseWeakMap ? WeakMap : Map)<\n DocumentNode,\n Readonly<{\n document: Readonly<DocumentNode>;\n hasClientExports: boolean;\n hasForcedResolvers: boolean;\n clientQuery: Readonly<DocumentNode> | null;\n serverQuery: Readonly<DocumentNode> | null;\n defaultVars: Readonly<OperationVariables>;\n }>\n >();\n\n public transform(document: DocumentNode) {\n const { transformCache } = this;\n\n if (!transformCache.has(document)) {\n const cache = this.dataStore.getCache();\n const transformed = cache.transformDocument(document);\n const forLink = removeConnectionDirectiveFromDocument(\n cache.transformForLink(transformed));\n\n const clientQuery = this.localState.clientQuery(transformed);\n const serverQuery = this.localState.serverQuery(forLink);\n\n const cacheEntry = {\n document: transformed,\n // TODO These two calls (hasClientExports and shouldForceResolvers)\n // could probably be merged into a single traversal.\n hasClientExports: hasClientExports(transformed),\n hasForcedResolvers: this.localState.shouldForceResolvers(transformed),\n clientQuery,\n serverQuery,\n defaultVars: getDefaultValues(\n getOperationDefinition(transformed)\n ) as OperationVariables,\n };\n\n const add = (doc: DocumentNode | null) => {\n if (doc && !transformCache.has(doc)) {\n transformCache.set(doc, cacheEntry);\n }\n }\n // Add cacheEntry to the transformCache using several different keys,\n // since any one of these documents could end up getting passed to the\n // transform method again in the future.\n add(document);\n add(transformed);\n add(clientQuery);\n add(serverQuery);\n }\n\n return transformCache.get(document)!;\n }\n\n private getVariables(\n document: DocumentNode,\n variables?: OperationVariables,\n ): OperationVariables {\n return {\n ...this.transform(document).defaultVars,\n ...variables,\n };\n }\n\n // The shouldSubscribe option is a temporary fix that tells us whether watchQuery was called\n // directly (i.e. through ApolloClient) or through the query method within QueryManager.\n // Currently, the query method uses watchQuery in order to handle non-network errors correctly\n // but we don't want to keep track observables issued for the query method since those aren't\n // supposed to be refetched in the event of a store reset. Once we unify error handling for\n // network errors and non-network errors, the shouldSubscribe option will go away.\n\n public watchQuery<T, TVariables = OperationVariables>(\n options: WatchQueryOptions,\n shouldSubscribe = true,\n ): ObservableQuery<T, TVariables> {\n invariant(\n options.fetchPolicy !== 'standby',\n 'client.watchQuery cannot be called with fetchPolicy set to \"standby\"',\n );\n\n // assign variable default values if supplied\n options.variables = this.getVariables(options.query, options.variables);\n\n if (typeof options.notifyOnNetworkStatusChange === 'undefined') {\n options.notifyOnNetworkStatusChange = false;\n }\n\n let transformedOptions = { ...options } as WatchQueryOptions<TVariables>;\n\n return new ObservableQuery<T, TVariables>({\n queryManager: this,\n options: transformedOptions,\n shouldSubscribe: shouldSubscribe,\n });\n }\n\n public query<T>(options: QueryOptions): Promise<ApolloQueryResult<T>> {\n invariant(\n options.query,\n 'query option is required. You must specify your GraphQL document ' +\n 'in the query option.',\n );\n\n invariant(\n options.query.kind === 'Document',\n 'You must wrap the query string in a \"gql\" tag.',\n );\n\n invariant(\n !(options as any).returnPartialData,\n 'returnPartialData option only supported on watchQuery.',\n );\n\n invariant(\n !(options as any).pollInterval,\n 'pollInterval option only supported on watchQuery.',\n );\n\n return new Promise<ApolloQueryResult<T>>((resolve, reject) => {\n const watchedQuery = this.watchQuery<T>(options, false);\n this.fetchQueryRejectFns.set(`query:${watchedQuery.queryId}`, reject);\n watchedQuery\n .result()\n .then(resolve, reject)\n // Since neither resolve nor reject throw or return a value, this .then\n // handler is guaranteed to execute. Note that it doesn't really matter\n // when we remove the reject function from this.fetchQueryRejectFns,\n // since resolve and reject are mutually idempotent. In fact, it would\n // not be incorrect to let reject functions accumulate over time; it's\n // just a waste of memory.\n .then(() =>\n this.fetchQueryRejectFns.delete(`query:${watchedQuery.queryId}`),\n );\n });\n }\n\n public generateQueryId() {\n return String(this.idCounter++);\n }\n\n public stopQueryInStore(queryId: string) {\n this.stopQueryInStoreNoBroadcast(queryId);\n this.broadcastQueries();\n }\n\n private stopQueryInStoreNoBroadcast(queryId: string) {\n this.stopPollingQuery(queryId);\n this.queryStore.stopQuery(queryId);\n this.invalidate(queryId);\n }\n\n public addQueryListener(queryId: string, listener: QueryListener) {\n this.setQuery(queryId, ({ listeners }) => {\n listeners.add(listener);\n return { invalidated: false };\n });\n }\n\n public updateQueryWatch(\n queryId: string,\n document: DocumentNode,\n options: WatchQueryOptions,\n ) {\n const { cancel } = this.getQuery(queryId);\n if (cancel) cancel();\n const previousResult = () => {\n let previousResult = null;\n const { observableQuery } = this.getQuery(queryId);\n if (observableQuery) {\n const lastResult = observableQuery.getLastResult();\n if (lastResult) {\n previousResult = lastResult.data;\n }\n }\n\n return previousResult;\n };\n return this.dataStore.getCache().watch({\n query: document as DocumentNode,\n variables: options.variables,\n optimistic: true,\n previousResult,\n callback: newData => {\n this.setQuery(queryId, () => ({ invalidated: true, newData }));\n },\n });\n }\n\n // Adds an ObservableQuery to this.observableQueries and to this.observableQueriesByName.\n public addObservableQuery<T>(\n queryId: string,\n observableQuery: ObservableQuery<T>,\n ) {\n this.setQuery(queryId, () => ({ observableQuery }));\n }\n\n public removeObservableQuery(queryId: string) {\n const { cancel } = this.getQuery(queryId);\n this.setQuery(queryId, () => ({ observableQuery: null }));\n if (cancel) cancel();\n }\n\n public clearStore(): Promise<void> {\n // Before we have sent the reset action to the store,\n // we can no longer rely on the results returned by in-flight\n // requests since these may depend on values that previously existed\n // in the data portion of the store. So, we cancel the promises and observers\n // that we have issued so far and not yet resolved (in the case of\n // queries).\n this.fetchQueryRejectFns.forEach(reject => {\n reject(new InvariantError(\n 'Store reset while query was in flight (not completed in link chain)',\n ));\n });\n\n const resetIds: string[] = [];\n this.queries.forEach(({ observableQuery }, queryId) => {\n if (observableQuery) resetIds.push(queryId);\n });\n\n this.queryStore.reset(resetIds);\n this.mutationStore.reset();\n\n // begin removing data from the store\n return this.dataStore.reset();\n }\n\n public resetStore(): Promise<ApolloQueryResult<any>[]> {\n // Similarly, we have to have to refetch each of the queries currently being\n // observed. We refetch instead of error'ing on these since the assumption is that\n // resetting the store doesn't eliminate the need for the queries currently being\n // watched. If there is an existing query in flight when the store is reset,\n // the promise for it will be rejected and its results will not be written to the\n // store.\n return this.clearStore().then(() => {\n return this.reFetchObservableQueries();\n });\n }\n\n public reFetchObservableQueries(\n includeStandby: boolean = false,\n ): Promise<ApolloQueryResult<any>[]> {\n const observableQueryPromises: Promise<ApolloQueryResult<any>>[] = [];\n\n this.queries.forEach(({ observableQuery }, queryId) => {\n if (observableQuery) {\n const fetchPolicy = observableQuery.options.fetchPolicy;\n\n observableQuery.resetLastResults();\n if (\n fetchPolicy !== 'cache-only' &&\n (includeStandby || fetchPolicy !== 'standby')\n ) {\n observableQueryPromises.push(observableQuery.refetch());\n }\n\n this.setQuery(queryId, () => ({ newData: null }));\n this.invalidate(queryId);\n }\n });\n\n this.broadcastQueries();\n\n return Promise.all(observableQueryPromises);\n }\n\n public observeQuery<T>(\n queryId: string,\n options: WatchQueryOptions,\n observer: Observer<ApolloQueryResult<T>>,\n ) {\n this.addQueryListener(\n queryId,\n this.queryListenerForObserver(queryId, options, observer),\n );\n return this.fetchQuery<T>(queryId, options);\n }\n\n public startQuery<T>(\n queryId: string,\n options: WatchQueryOptions,\n listener: QueryListener,\n ) {\n invariant.warn(\"The QueryManager.startQuery method has been deprecated\");\n\n this.addQueryListener(queryId, listener);\n\n this.fetchQuery<T>(queryId, options)\n // `fetchQuery` returns a Promise. In case of a failure it should be caucht or else the\n // console will show an `Uncaught (in promise)` message. Ignore the error for now.\n .catch(() => undefined);\n\n return queryId;\n }\n\n public startGraphQLSubscription<T = any>({\n query,\n fetchPolicy,\n variables,\n }: SubscriptionOptions): Observable<FetchResult<T>> {\n query = this.transform(query).document;\n variables = this.getVariables(query, variables);\n\n const makeObservable = (variables: OperationVariables) =>\n this.getObservableFromLink<T>(\n query,\n {},\n variables,\n false,\n ).map(result => {\n if (!fetchPolicy || fetchPolicy !== 'no-cache') {\n this.dataStore.markSubscriptionResult(\n result,\n query,\n variables,\n );\n this.broadcastQueries();\n }\n\n if (graphQLResultHasError(result)) {\n throw new ApolloError({\n graphQLErrors: result.errors,\n });\n }\n\n return result;\n });\n\n if (this.transform(query).hasClientExports) {\n const observablePromise = this.localState.addExportedVariables(\n query,\n variables,\n ).then(makeObservable);\n\n return new Observable<FetchResult<T>>(observer => {\n let sub: Subscription | null = null;\n observablePromise.then(\n observable => sub = observable.subscribe(observer),\n observer.error,\n );\n return () => sub && sub.unsubscribe();\n });\n }\n\n return makeObservable(variables);\n }\n\n public stopQuery(queryId: string) {\n this.stopQueryNoBroadcast(queryId);\n this.broadcastQueries();\n }\n\n private stopQueryNoBroadcast(queryId: string) {\n this.stopQueryInStoreNoBroadcast(queryId);\n this.removeQuery(queryId);\n }\n\n public removeQuery(queryId: string) {\n // teardown all links\n // Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises\n // that each add their reject functions to fetchQueryRejectFns.\n // A query created with `QueryManager.query()` could trigger a `QueryManager.fetchRequest`.\n // The same queryId could have two rejection fns for two promises\n this.fetchQueryRejectFns.delete(`query:${queryId}`);\n this.fetchQueryRejectFns.delete(`fetchRequest:${queryId}`);\n this.getQuery(queryId).subscriptions.forEach(x => x.unsubscribe());\n this.queries.delete(queryId);\n }\n\n public getCurrentQueryResult<T>(\n observableQuery: ObservableQuery<T>,\n optimistic: boolean = true,\n ): {\n data: T | undefined;\n partial: boolean;\n } {\n const { variables, query, fetchPolicy, returnPartialData } = observableQuery.options;\n const lastResult = observableQuery.getLastResult();\n const { newData } = this.getQuery(observableQuery.queryId);\n\n if (newData && newData.complete) {\n return { data: newData.result, partial: false };\n }\n\n if (fetchPolicy === 'no-cache' || fetchPolicy === 'network-only') {\n return { data: undefined, partial: false };\n }\n\n const { result, complete } = this.dataStore.getCache().diff<T>({\n query,\n variables,\n previousResult: lastResult ? lastResult.data : undefined,\n returnPartialData: true,\n optimistic,\n });\n\n return {\n data: (complete || returnPartialData) ? result : void 0,\n partial: !complete,\n };\n }\n\n public getQueryWithPreviousResult<TData, TVariables = OperationVariables>(\n queryIdOrObservable: string | ObservableQuery<TData, TVariables>,\n ): {\n previousResult: any;\n variables: TVariables | undefined;\n document: DocumentNode;\n } {\n let observableQuery: ObservableQuery<TData, any>;\n if (typeof queryIdOrObservable === 'string') {\n const { observableQuery: foundObserveableQuery } = this.getQuery(\n queryIdOrObservable,\n );\n invariant(\n foundObserveableQuery,\n `ObservableQuery with this id doesn't exist: ${queryIdOrObservable}`\n );\n observableQuery = foundObserveableQuery!;\n } else {\n observableQuery = queryIdOrObservable;\n }\n\n const { variables, query } = observableQuery.options;\n return {\n previousResult: this.getCurrentQueryResult(observableQuery, false).data,\n variables,\n document: query,\n };\n }\n\n public broadcastQueries() {\n this.onBroadcast();\n this.queries.forEach((info, id) => {\n if (info.invalidated) {\n info.listeners.forEach(listener => {\n // it's possible for the listener to be undefined if the query is being stopped\n // See here for more detail: https://github.com/apollostack/apollo-client/issues/231\n if (listener) {\n listener(this.queryStore.get(id), info.newData);\n }\n });\n }\n });\n }\n\n public getLocalState(): LocalState<TStore> {\n return this.localState;\n }\n\n private inFlightLinkObservables = new Map<\n DocumentNode,\n Map<string, Observable<FetchResult>>\n >();\n\n private getObservableFromLink<T = any>(\n query: DocumentNode,\n context: any,\n variables?: OperationVariables,\n deduplication: boolean = this.queryDeduplication,\n ): Observable<FetchResult<T>> {\n let observable: Observable<FetchResult<T>>;\n\n const { serverQuery } = this.transform(query);\n if (serverQuery) {\n const { inFlightLinkObservables, link } = this;\n\n const operation = {\n query: serverQuery,\n variables,\n operationName: getOperationName(serverQuery) || void 0,\n context: this.prepareContext({\n ...context,\n forceFetch: !deduplication\n }),\n };\n\n context = operation.context;\n\n if (deduplication) {\n const byVariables = inFlightLinkObservables.get(serverQuery) || new Map();\n inFlightLinkObservables.set(serverQuery, byVariables);\n\n const varJson = JSON.stringify(variables);\n observable = byVariables.get(varJson);\n\n if (!observable) {\n byVariables.set(\n varJson,\n observable = multiplex(\n execute(link, operation) as Observable<FetchResult<T>>\n )\n );\n\n const cleanup = () => {\n byVariables.delete(varJson);\n if (!byVariables.size) inFlightLinkObservables.delete(serverQuery);\n cleanupSub.unsubscribe();\n };\n\n const cleanupSub = observable.subscribe({\n next: cleanup,\n error: cleanup,\n complete: cleanup,\n });\n }\n\n } else {\n observable = multiplex(execute(link, operation) as Observable<FetchResult<T>>);\n }\n } else {\n observable = Observable.of({ data: {} } as FetchResult<T>);\n context = this.prepareContext(context);\n }\n\n const { clientQuery } = this.transform(query);\n if (clientQuery) {\n observable = asyncMap(observable, result => {\n return this.localState.runResolvers({\n document: clientQuery,\n remoteResult: result,\n context,\n variables,\n });\n });\n }\n\n return observable;\n }\n\n // Takes a request id, query id, a query document and information associated with the query\n // and send it to the network interface. Returns\n // a promise for the result associated with that request.\n private fetchRequest<T>({\n requestId,\n queryId,\n document,\n options,\n fetchMoreForQueryId,\n }: {\n requestId: number;\n queryId: string;\n document: DocumentNode;\n options: WatchQueryOptions;\n fetchMoreForQueryId?: string;\n }): Promise<FetchResult<T>> {\n const { variables, errorPolicy = 'none', fetchPolicy } = options;\n let resultFromStore: any;\n let errorsFromStore: any;\n\n return new Promise<ApolloQueryResult<T>>((resolve, reject) => {\n const observable = this.getObservableFromLink(\n document,\n options.context,\n variables,\n );\n\n const fqrfId = `fetchRequest:${queryId}`;\n this.fetchQueryRejectFns.set(fqrfId, reject);\n\n const cleanup = () => {\n this.fetchQueryRejectFns.delete(fqrfId);\n this.setQuery(queryId, ({ subscriptions }) => {\n subscriptions.delete(subscription);\n });\n };\n\n const subscription = observable.map((result: FetchResult<T>) => {\n if (requestId >= this.getQuery(queryId).lastRequestId) {\n this.markQueryResult(\n queryId,\n result,\n options,\n fetchMoreForQueryId,\n );\n\n this.queryStore.markQueryResult(\n queryId,\n result,\n fetchMoreForQueryId,\n );\n\n this.invalidate(queryId);\n this.invalidate(fetchMoreForQueryId);\n\n this.broadcastQueries();\n }\n\n if (errorPolicy === 'none' && isNonEmptyArray(result.errors)) {\n return reject(new ApolloError({\n graphQLErrors: result.errors,\n }));\n }\n\n if (errorPolicy === 'all') {\n errorsFromStore = result.errors;\n }\n\n if (fetchMoreForQueryId || fetchPolicy === 'no-cache') {\n // We don't write fetchMore results to the store because this would overwrite\n // the original result in case an @connection directive is used.\n resultFromStore = result.data;\n } else {\n // ensure result is combined with data already in store\n const { result, complete } = this.dataStore.getCache().diff<T>({\n variables,\n query: document,\n optimistic: false,\n returnPartialData: true,\n });\n\n if (complete || options.returnPartialData) {\n resultFromStore = result;\n }\n }\n }).subscribe({\n error(error: ApolloError) {\n cleanup();\n reject(error);\n },\n\n complete() {\n cleanup();\n resolve({\n data: resultFromStore,\n errors: errorsFromStore,\n loading: false,\n networkStatus: NetworkStatus.ready,\n stale: false,\n });\n },\n });\n\n this.setQuery(queryId, ({ subscriptions }) => {\n subscriptions.add(subscription);\n });\n });\n }\n\n private getQuery(queryId: string) {\n return (\n this.queries.get(queryId) || {\n listeners: new Set<QueryListener>(),\n invalidated: false,\n document: null,\n newData: null,\n lastRequestId: 1,\n observableQuery: null,\n subscriptions: new Set<Subscription>(),\n }\n );\n }\n\n private setQuery<T extends keyof QueryInfo>(\n queryId: string,\n updater: (prev: QueryInfo) => Pick<QueryInfo, T> | void,\n ) {\n const prev = this.getQuery(queryId);\n const newInfo = { ...prev, ...updater(prev) };\n this.queries.set(queryId, newInfo);\n }\n\n private invalidate(\n queryId: string | undefined,\n invalidated = true,\n ) {\n if (queryId) {\n this.setQuery(queryId, () => ({ invalidated }));\n }\n }\n\n private prepareContext(context = {}) {\n const newContext = this.localState.prepareContext(context);\n return {\n ...newContext,\n clientAwareness: this.clientAwareness,\n };\n }\n\n public checkInFlight(queryId: string) {\n const query = this.queryStore.get(queryId);\n\n return (\n query &&\n query.networkStatus !== NetworkStatus.ready &&\n query.networkStatus !== NetworkStatus.error\n );\n }\n\n // Map from client ID to { interval, options }.\n private pollingInfoByQueryId = new Map<string, {\n interval: number;\n timeout: NodeJS.Timeout;\n options: WatchQueryOptions;\n }>();\n\n public startPollingQuery(\n options: WatchQueryOptions,\n queryId: string,\n listener?: QueryListener,\n ): string {\n const { pollInterval } = options;\n\n invariant(\n pollInterval,\n 'Attempted to start a polling query without a polling interval.',\n );\n\n // Do not poll in SSR mode\n if (!this.ssrMode) {\n let info = this.pollingInfoByQueryId.get(queryId)!;\n if (!info) {\n this.pollingInfoByQueryId.set(queryId, (info = {} as any));\n }\n\n info.interval = pollInterval!;\n info.options = {\n ...options,\n fetchPolicy: 'network-only',\n };\n\n const maybeFetch = () => {\n const info = this.pollingInfoByQueryId.get(queryId);\n if (info) {\n if (this.checkInFlight(queryId)) {\n poll();\n } else {\n this.fetchQuery(queryId, info.options, FetchType.poll).then(\n poll,\n poll,\n );\n }\n }\n };\n\n const poll = () => {\n const info = this.pollingInfoByQueryId.get(queryId);\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n if (listener) {\n this.addQueryListener(queryId, listener);\n }\n\n poll();\n }\n\n return queryId;\n }\n\n public stopPollingQuery(queryId: string) {\n this.pollingInfoByQueryId.delete(queryId);\n }\n}\n","import { ExecutionResult, DocumentNode } from 'graphql';\nimport { ApolloCache, Cache, DataProxy } from 'apollo-cache';\n\nimport { QueryStoreValue } from '../data/queries';\nimport {\n getOperationName,\n tryFunctionOrLogError,\n graphQLResultHasError,\n} from 'apollo-utilities';\nimport { MutationQueryReducer } from '../core/types';\n\nexport type QueryWithUpdater = {\n updater: MutationQueryReducer<Object>;\n query: QueryStoreValue;\n};\n\nexport interface DataWrite {\n rootId: string;\n result: any;\n document: DocumentNode;\n operationName: string | null;\n variables: Object;\n}\n\nexport class DataStore<TSerialized> {\n private cache: ApolloCache<TSerialized>;\n\n constructor(initialCache: ApolloCache<TSerialized>) {\n this.cache = initialCache;\n }\n\n public getCache(): ApolloCache<TSerialized> {\n return this.cache;\n }\n\n public markQueryResult(\n result: ExecutionResult,\n document: DocumentNode,\n variables: any,\n fetchMoreForQueryId: string | undefined,\n ignoreErrors: boolean = false,\n ) {\n let writeWithErrors = !graphQLResultHasError(result);\n if (ignoreErrors && graphQLResultHasError(result) && result.data) {\n writeWithErrors = true;\n }\n if (!fetchMoreForQueryId && writeWithErrors) {\n this.cache.write({\n result: result.data,\n dataId: 'ROOT_QUERY',\n query: document,\n variables: variables,\n });\n }\n }\n\n public markSubscriptionResult(\n result: ExecutionResult,\n document: DocumentNode,\n variables: any,\n ) {\n // the subscription interface should handle not sending us results we no longer subscribe to.\n // XXX I don't think we ever send in an object with errors, but we might in the future...\n if (!graphQLResultHasError(result)) {\n this.cache.write({\n result: result.data,\n dataId: 'ROOT_SUBSCRIPTION',\n query: document,\n variables: variables,\n });\n }\n }\n\n public markMutationInit(mutation: {\n mutationId: string;\n document: DocumentNode;\n variables: any;\n updateQueries: { [queryId: string]: QueryWithUpdater };\n update: ((proxy: DataProxy, mutationResult: Object) => void) | undefined;\n optimisticResponse: Object | Function | undefined;\n }) {\n if (mutation.optimisticResponse) {\n let optimistic: Object;\n if (typeof mutation.optimisticResponse === 'function') {\n optimistic = mutation.optimisticResponse(mutation.variables);\n } else {\n optimistic = mutation.optimisticResponse;\n }\n\n this.cache.recordOptimisticTransaction(c => {\n const orig = this.cache;\n this.cache = c;\n\n try {\n this.markMutationResult({\n mutationId: mutation.mutationId,\n result: { data: optimistic },\n document: mutation.document,\n variables: mutation.variables,\n updateQueries: mutation.updateQueries,\n update: mutation.update,\n });\n } finally {\n this.cache = orig;\n }\n }, mutation.mutationId);\n }\n }\n\n public markMutationResult(mutation: {\n mutationId: string;\n result: ExecutionResult;\n document: DocumentNode;\n variables: any;\n updateQueries: { [queryId: string]: QueryWithUpdater };\n update: ((proxy: DataProxy, mutationResult: Object) => void) | undefined;\n }) {\n // Incorporate the result from this mutation into the store\n if (!graphQLResultHasError(mutation.result)) {\n const cacheWrites: Cache.WriteOptions[] = [{\n result: mutation.result.data,\n dataId: 'ROOT_MUTATION',\n query: mutation.document,\n variables: mutation.variables,\n }];\n\n const { updateQueries } = mutation;\n if (updateQueries) {\n Object.keys(updateQueries).forEach(id => {\n const { query, updater } = updateQueries[id];\n\n // Read the current query result from the store.\n const { result: currentQueryResult, complete } = this.cache.diff({\n query: query.document,\n variables: query.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n if (complete) {\n // Run our reducer using the current query result and the mutation result.\n const nextQueryResult = tryFunctionOrLogError(() =>\n updater(currentQueryResult, {\n mutationResult: mutation.result,\n queryName: getOperationName(query.document) || undefined,\n queryVariables: query.variables,\n }),\n );\n\n // Write the modified result back into the store if we got a new result.\n if (nextQueryResult) {\n cacheWrites.push({\n result: nextQueryResult,\n dataId: 'ROOT_QUERY',\n query: query.document,\n variables: query.variables,\n });\n }\n }\n });\n }\n\n this.cache.performTransaction(c => {\n cacheWrites.forEach(write => c.write(write));\n\n // If the mutation has some writes associated with it then we need to\n // apply those writes to the store by running this reducer again with a\n // write action.\n const { update } = mutation;\n if (update) {\n tryFunctionOrLogError(() => update(c, mutation.result));\n }\n });\n }\n }\n\n public markMutationComplete({\n mutationId,\n optimisticResponse,\n }: {\n mutationId: string;\n optimisticResponse?: any;\n }) {\n if (optimisticResponse) {\n this.cache.removeOptimistic(mutationId);\n }\n }\n\n public markUpdateQueryResult(\n document: DocumentNode,\n variables: any,\n newResult: any,\n ) {\n this.cache.write({\n result: newResult,\n dataId: 'ROOT_QUERY',\n variables,\n query: document,\n });\n }\n\n public reset(): Promise<void> {\n return this.cache.reset();\n }\n}\n","export const version = \"2.6.10\"","import {\n ApolloLink,\n FetchResult,\n GraphQLRequest,\n execute,\n} from 'apollo-link';\nimport { ExecutionResult, DocumentNode } from 'graphql';\nimport { ApolloCache, DataProxy } from 'apollo-cache';\n\nimport { invariant, InvariantError } from 'ts-invariant';\n\nimport { QueryManager } from './core/QueryManager';\nimport {\n ApolloQueryResult,\n OperationVariables,\n Resolvers,\n} from './core/types';\nimport { ObservableQuery } from './core/ObservableQuery';\nimport { LocalState, FragmentMatcher } from './core/LocalState';\nimport { Observable } from './util/Observable';\n\nimport {\n QueryOptions,\n WatchQueryOptions,\n SubscriptionOptions,\n MutationOptions,\n WatchQueryFetchPolicy,\n} from './core/watchQueryOptions';\n\nimport { DataStore } from './data/store';\n\nimport { version } from './version';\n\nexport interface DefaultOptions {\n watchQuery?: Partial<WatchQueryOptions>;\n query?: Partial<QueryOptions>;\n mutate?: Partial<MutationOptions>;\n}\n\nlet hasSuggestedDevtools = false;\n\nexport type ApolloClientOptions<TCacheShape> = {\n link?: ApolloLink;\n cache: ApolloCache<TCacheShape>;\n ssrForceFetchDelay?: number;\n ssrMode?: boolean;\n connectToDevTools?: boolean;\n queryDeduplication?: boolean;\n defaultOptions?: DefaultOptions;\n assumeImmutableResults?: boolean;\n resolvers?: Resolvers | Resolvers[];\n typeDefs?: string | string[] | DocumentNode | DocumentNode[];\n fragmentMatcher?: FragmentMatcher;\n name?: string;\n version?: string;\n};\n\n/**\n * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries\n * and mutations) to a GraphQL spec-compliant server over a {@link NetworkInterface} instance,\n * receive results from the server and cache the results in a store. It also delivers updates\n * to GraphQL queries through {@link Observable} instances.\n */\nexport default class ApolloClient<TCacheShape> implements DataProxy {\n public link: ApolloLink;\n public store: DataStore<TCacheShape>;\n public cache: ApolloCache<TCacheShape>;\n public readonly queryManager: QueryManager<TCacheShape>;\n public disableNetworkFetches: boolean;\n public version: string;\n public queryDeduplication: boolean;\n public defaultOptions: DefaultOptions = {};\n public readonly typeDefs: ApolloClientOptions<TCacheShape>['typeDefs'];\n\n private devToolsHookCb: Function;\n private resetStoreCallbacks: Array<() => Promise<any>> = [];\n private clearStoreCallbacks: Array<() => Promise<any>> = [];\n private localState: LocalState<TCacheShape>;\n\n /**\n * Constructs an instance of {@link ApolloClient}.\n *\n * @param link The {@link ApolloLink} over which GraphQL documents will be resolved into a response.\n *\n * @param cache The initial cache to use in the data store.\n *\n * @param ssrMode Determines whether this is being run in Server Side Rendering (SSR) mode.\n *\n * @param ssrForceFetchDelay Determines the time interval before we force fetch queries for a\n * server side render.\n *\n * @param queryDeduplication If set to false, a query will still be sent to the server even if a query\n * with identical parameters (query, variables, operationName) is already in flight.\n *\n * @param defaultOptions Used to set application wide defaults for the\n * options supplied to `watchQuery`, `query`, or\n * `mutate`.\n *\n * @param assumeImmutableResults When this option is true, the client will assume results\n * read from the cache are never mutated by application code,\n * which enables substantial performance optimizations. Passing\n * `{ freezeResults: true }` to the `InMemoryCache` constructor\n * can help enforce this immutability.\n *\n * @param name A custom name that can be used to identify this client, when\n * using Apollo client awareness features. E.g. \"iOS\".\n *\n * @param version A custom version that can be used to identify this client,\n * when using Apollo client awareness features. This is the\n * version of your client, which you may want to increment on\n * new builds. This is NOT the version of Apollo Client that\n * you are using.\n */\n constructor(options: ApolloClientOptions<TCacheShape>) {\n const {\n cache,\n ssrMode = false,\n ssrForceFetchDelay = 0,\n connectToDevTools,\n queryDeduplication = true,\n defaultOptions,\n assumeImmutableResults = false,\n resolvers,\n typeDefs,\n fragmentMatcher,\n name: clientAwarenessName,\n version: clientAwarenessVersion,\n } = options;\n\n let { link } = options;\n\n // If a link hasn't been defined, but local state resolvers have been set,\n // setup a default empty link.\n if (!link && resolvers) {\n link = ApolloLink.empty();\n }\n\n if (!link || !cache) {\n throw new InvariantError(\n \"In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\\n\" +\n \"These options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\\n\" +\n \"For more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup\"\n );\n }\n\n // remove apollo-client supported directives\n this.link = link;\n this.cache = cache;\n this.store = new DataStore(cache);\n this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;\n this.queryDeduplication = queryDeduplication;\n this.defaultOptions = defaultOptions || {};\n this.typeDefs = typeDefs;\n\n if (ssrForceFetchDelay) {\n setTimeout(\n () => (this.disableNetworkFetches = false),\n ssrForceFetchDelay,\n );\n }\n\n this.watchQuery = this.watchQuery.bind(this);\n this.query = this.query.bind(this);\n this.mutate = this.mutate.bind(this);\n this.resetStore = this.resetStore.bind(this);\n this.reFetchObservableQueries = this.reFetchObservableQueries.bind(this);\n\n // Attach the client instance to window to let us be found by chrome devtools, but only in\n // development mode\n const defaultConnectToDevTools =\n process.env.NODE_ENV !== 'production' &&\n typeof window !== 'undefined' &&\n !(window as any).__APOLLO_CLIENT__;\n\n if (\n typeof connectToDevTools === 'undefined'\n ? defaultConnectToDevTools\n : connectToDevTools && typeof window !== 'undefined'\n ) {\n (window as any).__APOLLO_CLIENT__ = this;\n }\n\n /**\n * Suggest installing the devtools for developers who don't have them\n */\n if (!hasSuggestedDevtools && process.env.NODE_ENV !== 'production') {\n hasSuggestedDevtools = true;\n if (\n typeof window !== 'undefined' &&\n window.document &&\n window.top === window.self\n ) {\n // First check if devtools is not installed\n if (\n typeof (window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__ === 'undefined'\n ) {\n // Only for Chrome\n if (\n window.navigator &&\n window.navigator.userAgent &&\n window.navigator.userAgent.indexOf('Chrome') > -1\n ) {\n // tslint:disable-next-line\n console.debug(\n 'Download the Apollo DevTools ' +\n 'for a better development experience: ' +\n 'https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm',\n );\n }\n }\n }\n }\n\n this.version = version;\n\n this.localState = new LocalState({\n cache,\n client: this,\n resolvers,\n fragmentMatcher,\n });\n\n this.queryManager = new QueryManager({\n link: this.link,\n store: this.store,\n queryDeduplication,\n ssrMode,\n clientAwareness: {\n name: clientAwarenessName!,\n version: clientAwarenessVersion!,\n },\n localState: this.localState,\n assumeImmutableResults,\n onBroadcast: () => {\n if (this.devToolsHookCb) {\n this.devToolsHookCb({\n action: {},\n state: {\n queries: this.queryManager.queryStore.getStore(),\n mutations: this.queryManager.mutationStore.getStore(),\n },\n dataWithOptimisticResults: this.cache.extract(true),\n });\n }\n },\n });\n }\n\n /**\n * Call this method to terminate any active client processes, making it safe\n * to dispose of this `ApolloClient` instance.\n */\n public stop() {\n this.queryManager.stop();\n }\n\n /**\n * This watches the cache store of the query according to the options specified and\n * returns an {@link ObservableQuery}. We can subscribe to this {@link ObservableQuery} and\n * receive updated results through a GraphQL observer when the cache store changes.\n * <p /><p />\n * Note that this method is not an implementation of GraphQL subscriptions. Rather,\n * it uses Apollo's store in order to reactively deliver updates to your query results.\n * <p /><p />\n * For example, suppose you call watchQuery on a GraphQL query that fetches a person's\n * first and last name and this person has a particular object identifer, provided by\n * dataIdFromObject. Later, a different query fetches that same person's\n * first and last name and the first name has now changed. Then, any observers associated\n * with the results of the first query will be updated with a new result object.\n * <p /><p />\n * Note that if the cache does not change, the subscriber will *not* be notified.\n * <p /><p />\n * See [here](https://medium.com/apollo-stack/the-concepts-of-graphql-bc68bd819be3#.3mb0cbcmc) for\n * a description of store reactivity.\n */\n public watchQuery<T = any, TVariables = OperationVariables>(\n options: WatchQueryOptions<TVariables>,\n ): ObservableQuery<T, TVariables> {\n if (this.defaultOptions.watchQuery) {\n options = {\n ...this.defaultOptions.watchQuery,\n ...options,\n } as WatchQueryOptions<TVariables>;\n }\n\n // XXX Overwriting options is probably not the best way to do this long term...\n if (\n this.disableNetworkFetches &&\n (options.fetchPolicy === 'network-only' ||\n options.fetchPolicy === 'cache-and-network')\n ) {\n options = { ...options, fetchPolicy: 'cache-first' };\n }\n\n return this.queryManager.watchQuery<T, TVariables>(options);\n }\n\n /**\n * This resolves a single query according to the options specified and\n * returns a {@link Promise} which is either resolved with the resulting data\n * or rejected with an error.\n *\n * @param options An object of type {@link QueryOptions} that allows us to\n * describe how this query should be treated e.g. whether it should hit the\n * server at all or just resolve from the cache, etc.\n */\n public query<T = any, TVariables = OperationVariables>(\n options: QueryOptions<TVariables>,\n ): Promise<ApolloQueryResult<T>> {\n if (this.defaultOptions.query) {\n options = { ...this.defaultOptions.query, ...options } as QueryOptions<\n TVariables\n >;\n }\n\n invariant(\n (options.fetchPolicy as WatchQueryFetchPolicy) !== 'cache-and-network',\n 'The cache-and-network fetchPolicy does not work with client.query, because ' +\n 'client.query can only return a single result. Please use client.watchQuery ' +\n 'to receive multiple results from the cache and the network, or consider ' +\n 'using a different fetchPolicy, such as cache-first or network-only.'\n );\n\n if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {\n options = { ...options, fetchPolicy: 'cache-first' };\n }\n\n return this.queryManager.query<T>(options);\n }\n\n /**\n * This resolves a single mutation according to the options specified and returns a\n * {@link Promise} which is either resolved with the resulting data or rejected with an\n * error.\n *\n * It takes options as an object with the following keys and values:\n */\n public mutate<T = any, TVariables = OperationVariables>(\n options: MutationOptions<T, TVariables>,\n ): Promise<FetchResult<T>> {\n if (this.defaultOptions.mutate) {\n options = {\n ...this.defaultOptions.mutate,\n ...options,\n } as MutationOptions<T, TVariables>;\n }\n\n return this.queryManager.mutate<T>(options);\n }\n\n /**\n * This subscribes to a graphql subscription according to the options specified and returns an\n * {@link Observable} which either emits received data or an error.\n */\n public subscribe<T = any, TVariables = OperationVariables>(\n options: SubscriptionOptions<TVariables>,\n ): Observable<FetchResult<T>> {\n return this.queryManager.startGraphQLSubscription<T>(options);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL query without making a network request. This method will start at\n * the root query. To start at a specific id returned by `dataIdFromObject`\n * use `readFragment`.\n *\n * @param optimistic Set to `true` to allow `readQuery` to return\n * optimistic results. Is `false` by default.\n */\n public readQuery<T = any, TVariables = OperationVariables>(\n options: DataProxy.Query<TVariables>,\n optimistic: boolean = false,\n ): T | null {\n return this.cache.readQuery<T, TVariables>(options, optimistic);\n }\n\n /**\n * Tries to read some data from the store in the shape of the provided\n * GraphQL fragment without making a network request. This method will read a\n * GraphQL fragment from any arbitrary id that is currently cached, unlike\n * `readQuery` which will only read from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are reading. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n *\n * @param optimistic Set to `true` to allow `readFragment` to return\n * optimistic results. Is `false` by default.\n */\n public readFragment<T = any, TVariables = OperationVariables>(\n options: DataProxy.Fragment<TVariables>,\n optimistic: boolean = false,\n ): T | null {\n return this.cache.readFragment<T, TVariables>(options, optimistic);\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL query directly to\n * the store. This method will start at the root query. To start at a\n * specific id returned by `dataIdFromObject` then use `writeFragment`.\n */\n public writeQuery<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteQueryOptions<TData, TVariables>,\n ): void {\n const result = this.cache.writeQuery<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\n return result;\n }\n\n /**\n * Writes some data in the shape of the provided GraphQL fragment directly to\n * the store. This method will write to a GraphQL fragment from any arbitrary\n * id that is currently cached, unlike `writeQuery` which will only write\n * from the root query.\n *\n * You must pass in a GraphQL document with a single fragment or a document\n * with multiple fragments that represent what you are writing. If you pass\n * in a document with multiple fragments then you must also specify a\n * `fragmentName`.\n */\n public writeFragment<TData = any, TVariables = OperationVariables>(\n options: DataProxy.WriteFragmentOptions<TData, TVariables>,\n ): void {\n const result = this.cache.writeFragment<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\n return result;\n }\n\n /**\n * Sugar for writeQuery & writeFragment\n * This method will construct a query from the data object passed in.\n * If no id is supplied, writeData will write the data to the root.\n * If an id is supplied, writeData will write a fragment to the object\n * specified by the id in the store.\n *\n * Since you aren't passing in a query to check the shape of the data,\n * you must pass in an object that conforms to the shape of valid GraphQL data.\n */\n public writeData<TData = any>(\n options: DataProxy.WriteDataOptions<TData>,\n ): void {\n const result = this.cache.writeData<TData>(options);\n this.queryManager.broadcastQueries();\n return result;\n }\n\n public __actionHookForDevTools(cb: () => any) {\n this.devToolsHookCb = cb;\n }\n\n public __requestRaw(payload: GraphQLRequest): Observable<ExecutionResult> {\n return execute(this.link, payload);\n }\n\n /**\n * This initializes the query manager that tracks queries and the cache\n */\n public initQueryManager(): QueryManager<TCacheShape> {\n invariant.warn(\n 'Calling the initQueryManager method is no longer necessary, ' +\n 'and it will be removed from ApolloClient in version 3.0.',\n );\n return this.queryManager;\n }\n\n /**\n * Resets your entire store by clearing out your cache and then re-executing\n * all of your active queries. This makes it so that you may guarantee that\n * there is no data left in your store from a time before you called this\n * method.\n *\n * `resetStore()` is useful when your user just logged out. You’ve removed the\n * user session, and you now want to make sure that any references to data you\n * might have fetched while the user session was active is gone.\n *\n * It is important to remember that `resetStore()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n */\n public resetStore(): Promise<ApolloQueryResult<any>[] | null> {\n return Promise.resolve()\n .then(() => this.queryManager.clearStore())\n .then(() => Promise.all(this.resetStoreCallbacks.map(fn => fn())))\n .then(() => this.reFetchObservableQueries());\n }\n\n /**\n * Remove all data from the store. Unlike `resetStore`, `clearStore` will\n * not refetch any active queries.\n */\n public clearStore(): Promise<any[]> {\n return Promise.resolve()\n .then(() => this.queryManager.clearStore())\n .then(() => Promise.all(this.clearStoreCallbacks.map(fn => fn())));\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * reset. `onResetStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onResetStore(cb: () => Promise<any>): () => void {\n this.resetStoreCallbacks.push(cb);\n return () => {\n this.resetStoreCallbacks = this.resetStoreCallbacks.filter(c => c !== cb);\n };\n }\n\n /**\n * Allows callbacks to be registered that are executed when the store is\n * cleared. `onClearStore` returns an unsubscribe function that can be used\n * to remove registered callbacks.\n */\n public onClearStore(cb: () => Promise<any>): () => void {\n this.clearStoreCallbacks.push(cb);\n return () => {\n this.clearStoreCallbacks = this.clearStoreCallbacks.filter(c => c !== cb);\n };\n }\n\n /**\n * Refetches all of your active queries.\n *\n * `reFetchObservableQueries()` is useful if you want to bring the client back to proper state in case of a network outage\n *\n * It is important to remember that `reFetchObservableQueries()` *will* refetch any active\n * queries. This means that any components that might be mounted will execute\n * their queries again using your network interface. If you do not want to\n * re-execute any queries then you should make sure to stop watching any\n * active queries.\n * Takes optional parameter `includeStandby` which will include queries in standby-mode when refetching.\n */\n public reFetchObservableQueries(\n includeStandby?: boolean,\n ): Promise<ApolloQueryResult<any>[]> {\n return this.queryManager.reFetchObservableQueries(includeStandby);\n }\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public extract(optimistic?: boolean): TCacheShape {\n return this.cache.extract(optimistic);\n }\n\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public restore(serializedState: TCacheShape): ApolloCache<TCacheShape> {\n return this.cache.restore(serializedState);\n }\n\n /**\n * Add additional local resolvers.\n */\n public addResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.addResolvers(resolvers);\n }\n\n /**\n * Set (override existing) local resolvers.\n */\n public setResolvers(resolvers: Resolvers | Resolvers[]) {\n this.localState.setResolvers(resolvers);\n }\n\n /**\n * Get all registered local resolvers.\n */\n public getResolvers() {\n return this.localState.getResolvers();\n }\n\n /**\n * Set a custom local state fragment matcher.\n */\n public setLocalStateFragmentMatcher(fragmentMatcher: FragmentMatcher) {\n this.localState.setFragmentMatcher(fragmentMatcher);\n }\n}\n"]} |