@apollo/client 3.4.10 → 3.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/apollo-client.cjs.js +85 -55
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -0
- package/cache/cache.cjs.js +46 -36
- package/cache/cache.cjs.js.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/index.d.ts +3 -3
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +2 -2
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +10 -1
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +31 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +2 -8
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +10 -16
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -2
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +1 -18
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +7 -4
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +8 -1
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +2 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +2 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +5 -4
- package/core/core.cjs.js.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/persisted-queries/index.d.ts +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +1 -1
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.js +3 -0
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
- package/package.json +13 -13
- package/react/context/ApolloContext.d.ts +2 -1
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +11 -5
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/context.cjs.js +10 -4
- package/react/context/context.cjs.js.map +1 -1
- package/react/hoc/hoc.cjs.js +8 -5
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -5
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/parser/index.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +2 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +14 -3
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.js +1 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/globals.cjs.js +1 -0
- package/utilities/globals/globals.cjs.js.map +1 -1
- package/utilities/globals/index.js +1 -0
- package/utilities/globals/index.js.map +1 -1
- package/utilities/graphql/fragments.js +1 -1
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/transform.js +1 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/subclassing.d.ts.map +1 -1
- package/utilities/observables/subclassing.js +2 -1
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -4
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/testing/mocking/mockFetch.js +1 -1
- package/utilities/testing/mocking/mockFetch.js.map +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
- package/utilities/testing/observableToPromise.js +1 -1
- package/utilities/testing/observableToPromise.js.map +1 -1
- package/utilities/utilities.cjs.js +34 -15
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/apollo-core.cjs.js +0 -5778
- package/apollo-core.cjs.js.map +0 -1
- package/apollo-core.cjs.min.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readFromStore.js","sourceRoot":"","sources":["../../../src/cache/inmemory/readFromStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOpE,OAAO,EAAE,IAAI,EAA6B,MAAM,UAAU,CAAC;AAE3D,OAAO,EACL,OAAO,EACP,sBAAsB,EAEtB,WAAW,EACX,aAAa,EAEb,iBAAiB,EAEjB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUhE,CAAC;AAOF,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AAC;AAAD,CAAC,AAvYD,IAuYC;;AAED,SAAS,4BAA4B,CACnC,KAAsB,EACtB,KAAgB,EAChB,UAAe;IAEf,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACvB,IAAM,SAAO,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACtC,SAAO,CAAC,OAAO,CAAC,UAAA,KAAK;YACnB,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBAC1B,SAAS,CACP,CAAC,WAAW,CAAC,KAAK,CAAC,EACnB,8CACE,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,kCACb,KAAK,CAAC,IAAI,CAAC,KAAO,CAChD,CAAC;gBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAO,CAAC,GAAG,EAAE,SAAO,CAAC,CAAC;aACpD;QACH,CAAC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import { invariant, InvariantError } from '../../utilities/globals';\n\nimport {\n DocumentNode,\n FieldNode,\n SelectionSetNode,\n} from 'graphql';\nimport { wrap, OptimisticWrapperFunction } from 'optimism';\n\nimport {\n isField,\n resultKeyNameFromField,\n Reference,\n isReference,\n makeReference,\n StoreObject,\n createFragmentMap,\n FragmentMap,\n shouldInclude,\n addTypenameToDocument,\n getDefaultValues,\n getFragmentDefinitions,\n getMainDefinition,\n getQueryDefinition,\n mergeDeepArray,\n getFragmentFromSelection,\n maybeDeepFreeze,\n isNonNullObject,\n canUseWeakMap,\n} from '../../utilities';\nimport { Cache } from '../core/types/Cache';\nimport {\n DiffQueryAgainstStoreOptions,\n NormalizedCache,\n ReadMergeModifyContext,\n} from './types';\nimport { maybeDependOnExistenceOfEntity, supportsResultCaching } from './entityStore';\nimport { getTypenameFromStoreObject } from './helpers';\nimport { Policies } from './policies';\nimport { InMemoryCache } from './inMemoryCache';\nimport { MissingFieldError } from '../core/types/common';\nimport { canonicalStringify, ObjectCanon } from './object-canon';\n\nexport type VariableMap = { [name: string]: any };\n\ninterface ReadContext extends ReadMergeModifyContext {\n query: DocumentNode;\n policies: Policies;\n canonizeResults: boolean;\n fragmentMap: FragmentMap;\n path: (string | number)[];\n};\n\nexport type ExecResult<R = any> = {\n result: R;\n missing?: MissingFieldError[];\n};\n\nfunction missingFromInvariant(\n err: InvariantError,\n context: ReadContext,\n) {\n return new MissingFieldError(\n err.message,\n context.path.slice(),\n context.query,\n context.variables,\n );\n}\n\ntype ExecSelectionSetOptions = {\n selectionSet: SelectionSetNode;\n objectOrReference: StoreObject | Reference;\n enclosingRef: Reference;\n context: ReadContext;\n};\n\ntype ExecSubSelectedArrayOptions = {\n field: FieldNode;\n array: any[];\n enclosingRef: Reference;\n context: ReadContext;\n};\n\nexport interface StoreReaderConfig {\n cache: InMemoryCache,\n addTypename?: boolean;\n resultCacheMaxSize?: number;\n canon?: ObjectCanon;\n}\n\n// Arguments type after keyArgs translation.\ntype ExecSelectionSetKeyArgs = [\n SelectionSetNode,\n StoreObject | Reference,\n ReadMergeModifyContext,\n boolean,\n];\n\nfunction execSelectionSetKeyArgs(\n options: ExecSelectionSetOptions,\n): ExecSelectionSetKeyArgs {\n return [\n options.selectionSet,\n options.objectOrReference,\n options.context,\n // We split out this property so we can pass different values\n // independently without modifying options.context itself.\n options.context.canonizeResults,\n ];\n}\n\nexport class StoreReader {\n // cached version of executeSelectionset\n private executeSelectionSet: OptimisticWrapperFunction<\n [ExecSelectionSetOptions], // Actual arguments tuple type.\n ExecResult, // Actual return type.\n ExecSelectionSetKeyArgs\n >;\n\n // cached version of executeSubSelectedArray\n private executeSubSelectedArray: OptimisticWrapperFunction<\n [ExecSubSelectedArrayOptions],\n ExecResult<any>,\n [ExecSubSelectedArrayOptions]>;\n\n private config: {\n cache: InMemoryCache,\n addTypename: boolean;\n resultCacheMaxSize?: number;\n };\n\n private knownResults = new (\n canUseWeakMap ? WeakMap : Map\n )<Record<string, any>, SelectionSetNode>();\n\n public canon: ObjectCanon;\n public resetCanon() {\n this.canon = new ObjectCanon;\n }\n\n constructor(config: StoreReaderConfig) {\n this.config = {\n ...config,\n addTypename: config.addTypename !== false,\n };\n\n this.canon = config.canon || new ObjectCanon;\n\n this.executeSelectionSet = wrap(options => {\n const { canonizeResults } = options.context;\n\n const peekArgs = execSelectionSetKeyArgs(options);\n\n // Negate this boolean option so we can find out if we've already read\n // this result using the other boolean value.\n peekArgs[3] = !canonizeResults;\n\n const other = this.executeSelectionSet.peek(...peekArgs);\n\n if (other) {\n if (canonizeResults) {\n return {\n ...other,\n // If we previously read this result without canonizing it, we can\n // reuse that result simply by canonizing it now.\n result: this.canon.admit(other.result),\n };\n }\n // If we previously read this result with canonization enabled, we can\n // return that canonized result as-is.\n return other;\n }\n\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref,\n );\n\n // Finally, if we didn't find any useful previous results, run the real\n // execSelectionSetImpl method with the given options.\n return this.execSelectionSetImpl(options);\n\n }, {\n max: this.config.resultCacheMaxSize,\n keyArgs: execSelectionSetKeyArgs,\n // Note that the parameters of makeCacheKey are determined by the\n // array returned by keyArgs.\n makeCacheKey(selectionSet, parent, context, canonizeResults) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n selectionSet,\n isReference(parent) ? parent.__ref : parent,\n context.varString,\n canonizeResults,\n );\n }\n }\n });\n\n this.executeSubSelectedArray = wrap((options: ExecSubSelectedArrayOptions) => {\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref,\n );\n return this.execSubSelectedArrayImpl(options);\n }, {\n max: this.config.resultCacheMaxSize,\n makeCacheKey({ field, array, context }) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n field,\n array,\n context.varString,\n );\n }\n }\n });\n }\n\n /**\n * Given a store and a query, return as much of the result as possible and\n * identify if any data was missing from the store.\n * @param {DocumentNode} query A parsed GraphQL query document\n * @param {Store} store The Apollo Client store object\n * @return {result: Object, complete: [boolean]}\n */\n public diffQueryAgainstStore<T>({\n store,\n query,\n rootId = 'ROOT_QUERY',\n variables,\n returnPartialData = true,\n canonizeResults = true,\n }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> {\n const policies = this.config.cache.policies;\n\n variables = {\n ...getDefaultValues(getQueryDefinition(query)),\n ...variables!,\n };\n\n const rootRef = makeReference(rootId);\n const execResult = this.executeSelectionSet({\n selectionSet: getMainDefinition(query).selectionSet,\n objectOrReference: rootRef,\n enclosingRef: rootRef,\n context: {\n store,\n query,\n policies,\n variables,\n varString: canonicalStringify(variables),\n canonizeResults,\n fragmentMap: createFragmentMap(getFragmentDefinitions(query)),\n path: [],\n },\n });\n\n const hasMissingFields =\n execResult.missing && execResult.missing.length > 0;\n if (hasMissingFields && !returnPartialData) {\n throw execResult.missing![0];\n }\n\n return {\n result: execResult.result,\n missing: execResult.missing,\n complete: !hasMissingFields,\n };\n }\n\n public isFresh(\n result: Record<string, any>,\n parent: StoreObject | Reference,\n selectionSet: SelectionSetNode,\n context: ReadMergeModifyContext,\n ): boolean {\n if (supportsResultCaching(context.store) &&\n this.knownResults.get(result) === selectionSet) {\n const latest = this.executeSelectionSet.peek(\n selectionSet,\n parent,\n context,\n // If result is canonical, then it could only have been previously\n // cached by the canonizing version of executeSelectionSet, so we can\n // avoid checking both possibilities here.\n this.canon.isKnown(result),\n );\n if (latest && result === latest.result) {\n return true;\n }\n }\n return false;\n }\n\n // Uncached version of executeSelectionSet.\n private execSelectionSetImpl({\n selectionSet,\n objectOrReference,\n enclosingRef,\n context,\n }: ExecSelectionSetOptions): ExecResult {\n if (isReference(objectOrReference) &&\n !context.policies.rootTypenamesById[objectOrReference.__ref] &&\n !context.store.has(objectOrReference.__ref)) {\n return {\n result: this.canon.empty,\n missing: [missingFromInvariant(\n new InvariantError(\n `Dangling reference to missing ${objectOrReference.__ref} object`\n ),\n context,\n )],\n };\n }\n\n const { variables, policies, store } = context;\n const objectsToMerge: { [key: string]: any }[] = [];\n const finalResult: ExecResult = { result: null };\n const typename = store.getFieldValue<string>(objectOrReference, \"__typename\");\n\n if (this.config.addTypename &&\n typeof typename === \"string\" &&\n !policies.rootIdsByTypename[typename]) {\n // Ensure we always include a default value for the __typename\n // field, if we have one, and this.config.addTypename is true. Note\n // that this field can be overridden by other merged objects.\n objectsToMerge.push({ __typename: typename });\n }\n\n function getMissing() {\n return finalResult.missing || (finalResult.missing = []);\n }\n\n function handleMissing<T>(result: ExecResult<T>): T {\n if (result.missing) getMissing().push(...result.missing);\n return result.result;\n }\n\n const workSet = new Set(selectionSet.selections);\n\n workSet.forEach(selection => {\n // Omit fields with directives @skip(if: <truthy value>) or\n // @include(if: <falsy value>).\n if (!shouldInclude(selection, variables)) return;\n\n if (isField(selection)) {\n let fieldValue = policies.readField({\n fieldName: selection.name.value,\n field: selection,\n variables: context.variables,\n from: objectOrReference,\n }, context);\n\n const resultName = resultKeyNameFromField(selection);\n context.path.push(resultName);\n\n if (fieldValue === void 0) {\n if (!addTypenameToDocument.added(selection)) {\n getMissing().push(\n missingFromInvariant(\n new InvariantError(`Can't find field '${\n selection.name.value\n }' on ${\n isReference(objectOrReference)\n ? objectOrReference.__ref + \" object\"\n : \"object \" + JSON.stringify(objectOrReference, null, 2)\n }`),\n context,\n ),\n );\n }\n\n } else if (Array.isArray(fieldValue)) {\n fieldValue = handleMissing(this.executeSubSelectedArray({\n field: selection,\n array: fieldValue,\n enclosingRef,\n context,\n }));\n\n } else if (!selection.selectionSet) {\n // If the field does not have a selection set, then we handle it\n // as a scalar value. To keep this.canon from canonicalizing\n // this value, we use this.canon.pass to wrap fieldValue in a\n // Pass object that this.canon.admit will later unwrap as-is.\n if (context.canonizeResults) {\n fieldValue = this.canon.pass(fieldValue);\n }\n\n } else if (fieldValue != null) {\n // In this case, because we know the field has a selection set,\n // it must be trying to query a GraphQLObjectType, which is why\n // fieldValue must be != null.\n fieldValue = handleMissing(this.executeSelectionSet({\n selectionSet: selection.selectionSet,\n objectOrReference: fieldValue as StoreObject | Reference,\n enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,\n context,\n }));\n }\n\n if (fieldValue !== void 0) {\n objectsToMerge.push({ [resultName]: fieldValue });\n }\n\n invariant(context.path.pop() === resultName);\n\n } else {\n const fragment = getFragmentFromSelection(\n selection,\n context.fragmentMap,\n );\n\n if (fragment && policies.fragmentMatches(fragment, typename)) {\n fragment.selectionSet.selections.forEach(workSet.add, workSet);\n }\n }\n });\n\n // Perform a single merge at the end so that we can avoid making more\n // defensive shallow copies than necessary.\n const merged = mergeDeepArray(objectsToMerge);\n finalResult.result = context.canonizeResults\n ? this.canon.admit(merged)\n // Since this.canon is normally responsible for freezing results (only in\n // development), freeze them manually if canonization is disabled.\n : maybeDeepFreeze(merged);\n\n // Store this result with its selection set so that we can quickly\n // recognize it again in the StoreReader#isFresh method.\n this.knownResults.set(finalResult.result, selectionSet);\n\n return finalResult;\n }\n\n // Uncached version of executeSubSelectedArray.\n private execSubSelectedArrayImpl({\n field,\n array,\n enclosingRef,\n context,\n }: ExecSubSelectedArrayOptions): ExecResult {\n let missing: MissingFieldError[] | undefined;\n\n function handleMissing<T>(childResult: ExecResult<T>, i: number): T {\n if (childResult.missing) {\n missing = missing || [];\n missing.push(...childResult.missing);\n }\n\n invariant(context.path.pop() === i);\n\n return childResult.result;\n }\n\n if (field.selectionSet) {\n array = array.filter(context.store.canRead);\n }\n\n array = array.map((item, i) => {\n // null value in array\n if (item === null) {\n return null;\n }\n\n context.path.push(i);\n\n // This is a nested array, recurse\n if (Array.isArray(item)) {\n return handleMissing(this.executeSubSelectedArray({\n field,\n array: item,\n enclosingRef,\n context,\n }), i);\n }\n\n // This is an object, run the selection set on it\n if (field.selectionSet) {\n return handleMissing(this.executeSelectionSet({\n selectionSet: field.selectionSet,\n objectOrReference: item,\n enclosingRef: isReference(item) ? item : enclosingRef,\n context,\n }), i);\n }\n\n if (__DEV__) {\n assertSelectionSetForIdValue(context.store, field, item);\n }\n\n invariant(context.path.pop() === i);\n\n return item;\n });\n\n return {\n result: context.canonizeResults ? this.canon.admit(array) : array,\n missing,\n };\n }\n}\n\nfunction assertSelectionSetForIdValue(\n store: NormalizedCache,\n field: FieldNode,\n fieldValue: any,\n) {\n if (!field.selectionSet) {\n const workSet = new Set([fieldValue]);\n workSet.forEach(value => {\n if (isNonNullObject(value)) {\n invariant(\n !isReference(value),\n `Missing selection set for object of type ${\n getTypenameFromStoreObject(store, value)\n } returned for query field ${field.name.value}`,\n );\n Object.values(value).forEach(workSet.add, workSet);\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"readFromStore.js","sourceRoot":"","sources":["../../../src/cache/inmemory/readFromStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOpE,OAAO,EAAE,IAAI,EAA6B,MAAM,UAAU,CAAC;AAE3D,OAAO,EACL,OAAO,EACP,sBAAsB,EAEtB,WAAW,EACX,aAAa,EAEb,iBAAiB,EAEjB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,aAAa,EACb,OAAO,GACR,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUhE,CAAC;AAOF,SAAS,oBAAoB,CAC3B,GAAmB,EACnB,OAAoB;IAEpB,OAAO,IAAI,iBAAiB,CAC1B,GAAG,CAAC,OAAO,EACX,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EACpB,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,SAA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AAe;IAEf,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACvB,IAAM,SAAO,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACtC,SAAO,CAAC,OAAO,CAAC,UAAA,KAAK;YACnB,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBAC1B,SAAS,CACP,CAAC,WAAW,CAAC,KAAK,CAAC,EACnB,8CACE,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,kCACb,KAAK,CAAC,IAAI,CAAC,KAAO,CAChD,CAAC;gBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAO,CAAC,GAAG,EAAE,SAAO,CAAC,CAAC;aACpD;QACH,CAAC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import { invariant, InvariantError } from '../../utilities/globals';\n\nimport {\n DocumentNode,\n FieldNode,\n SelectionSetNode,\n} from 'graphql';\nimport { wrap, OptimisticWrapperFunction } from 'optimism';\n\nimport {\n isField,\n resultKeyNameFromField,\n Reference,\n isReference,\n makeReference,\n StoreObject,\n createFragmentMap,\n FragmentMap,\n shouldInclude,\n addTypenameToDocument,\n getDefaultValues,\n getFragmentDefinitions,\n getMainDefinition,\n getQueryDefinition,\n mergeDeepArray,\n getFragmentFromSelection,\n maybeDeepFreeze,\n isNonNullObject,\n canUseWeakMap,\n compact,\n} from '../../utilities';\nimport { Cache } from '../core/types/Cache';\nimport {\n DiffQueryAgainstStoreOptions,\n NormalizedCache,\n ReadMergeModifyContext,\n} from './types';\nimport { maybeDependOnExistenceOfEntity, supportsResultCaching } from './entityStore';\nimport { getTypenameFromStoreObject, shouldCanonizeResults } from './helpers';\nimport { Policies } from './policies';\nimport { InMemoryCache } from './inMemoryCache';\nimport { MissingFieldError } from '../core/types/common';\nimport { canonicalStringify, ObjectCanon } from './object-canon';\n\nexport type VariableMap = { [name: string]: any };\n\ninterface ReadContext extends ReadMergeModifyContext {\n query: DocumentNode;\n policies: Policies;\n canonizeResults: boolean;\n fragmentMap: FragmentMap;\n path: (string | number)[];\n};\n\nexport type ExecResult<R = any> = {\n result: R;\n missing?: MissingFieldError[];\n};\n\nfunction missingFromInvariant(\n err: InvariantError,\n context: ReadContext,\n) {\n return new MissingFieldError(\n err.message,\n context.path.slice(),\n context.query,\n context.variables,\n );\n}\n\ntype ExecSelectionSetOptions = {\n selectionSet: SelectionSetNode;\n objectOrReference: StoreObject | Reference;\n enclosingRef: Reference;\n context: ReadContext;\n};\n\ntype ExecSubSelectedArrayOptions = {\n field: FieldNode;\n array: any[];\n enclosingRef: Reference;\n context: ReadContext;\n};\n\nexport interface StoreReaderConfig {\n cache: InMemoryCache,\n addTypename?: boolean;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n canon?: ObjectCanon;\n}\n\n// Arguments type after keyArgs translation.\ntype ExecSelectionSetKeyArgs = [\n SelectionSetNode,\n StoreObject | Reference,\n ReadMergeModifyContext,\n boolean,\n];\n\nfunction execSelectionSetKeyArgs(\n options: ExecSelectionSetOptions,\n): ExecSelectionSetKeyArgs {\n return [\n options.selectionSet,\n options.objectOrReference,\n options.context,\n // We split out this property so we can pass different values\n // independently without modifying options.context itself.\n options.context.canonizeResults,\n ];\n}\n\nexport class StoreReader {\n // cached version of executeSelectionSet\n private executeSelectionSet: OptimisticWrapperFunction<\n [ExecSelectionSetOptions], // Actual arguments tuple type.\n ExecResult, // Actual return type.\n ExecSelectionSetKeyArgs\n >;\n\n // cached version of executeSubSelectedArray\n private executeSubSelectedArray: OptimisticWrapperFunction<\n [ExecSubSelectedArrayOptions],\n ExecResult<any>,\n [ExecSubSelectedArrayOptions]>;\n\n private config: {\n cache: InMemoryCache,\n addTypename: boolean;\n resultCacheMaxSize?: number;\n canonizeResults: boolean;\n };\n\n private knownResults = new (\n canUseWeakMap ? WeakMap : Map\n )<Record<string, any>, SelectionSetNode>();\n\n public canon: ObjectCanon;\n public resetCanon() {\n this.canon = new ObjectCanon;\n }\n\n constructor(config: StoreReaderConfig) {\n this.config = compact(config, {\n addTypename: config.addTypename !== false,\n canonizeResults: shouldCanonizeResults(config),\n });\n\n this.canon = config.canon || new ObjectCanon;\n\n this.executeSelectionSet = wrap(options => {\n const { canonizeResults } = options.context;\n\n const peekArgs = execSelectionSetKeyArgs(options);\n\n // Negate this boolean option so we can find out if we've already read\n // this result using the other boolean value.\n peekArgs[3] = !canonizeResults;\n\n const other = this.executeSelectionSet.peek(...peekArgs);\n\n if (other) {\n if (canonizeResults) {\n return {\n ...other,\n // If we previously read this result without canonizing it, we can\n // reuse that result simply by canonizing it now.\n result: this.canon.admit(other.result),\n };\n }\n // If we previously read this result with canonization enabled, we can\n // return that canonized result as-is.\n return other;\n }\n\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref,\n );\n\n // Finally, if we didn't find any useful previous results, run the real\n // execSelectionSetImpl method with the given options.\n return this.execSelectionSetImpl(options);\n\n }, {\n max: this.config.resultCacheMaxSize,\n keyArgs: execSelectionSetKeyArgs,\n // Note that the parameters of makeCacheKey are determined by the\n // array returned by keyArgs.\n makeCacheKey(selectionSet, parent, context, canonizeResults) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n selectionSet,\n isReference(parent) ? parent.__ref : parent,\n context.varString,\n canonizeResults,\n );\n }\n }\n });\n\n this.executeSubSelectedArray = wrap((options: ExecSubSelectedArrayOptions) => {\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref,\n );\n return this.execSubSelectedArrayImpl(options);\n }, {\n max: this.config.resultCacheMaxSize,\n makeCacheKey({ field, array, context }) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n field,\n array,\n context.varString,\n );\n }\n }\n });\n }\n\n /**\n * Given a store and a query, return as much of the result as possible and\n * identify if any data was missing from the store.\n * @param {DocumentNode} query A parsed GraphQL query document\n * @param {Store} store The Apollo Client store object\n * @return {result: Object, complete: [boolean]}\n */\n public diffQueryAgainstStore<T>({\n store,\n query,\n rootId = 'ROOT_QUERY',\n variables,\n returnPartialData = true,\n canonizeResults = this.config.canonizeResults,\n }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> {\n const policies = this.config.cache.policies;\n\n variables = {\n ...getDefaultValues(getQueryDefinition(query)),\n ...variables!,\n };\n\n const rootRef = makeReference(rootId);\n const execResult = this.executeSelectionSet({\n selectionSet: getMainDefinition(query).selectionSet,\n objectOrReference: rootRef,\n enclosingRef: rootRef,\n context: {\n store,\n query,\n policies,\n variables,\n varString: canonicalStringify(variables),\n canonizeResults,\n fragmentMap: createFragmentMap(getFragmentDefinitions(query)),\n path: [],\n },\n });\n\n const hasMissingFields =\n execResult.missing && execResult.missing.length > 0;\n if (hasMissingFields && !returnPartialData) {\n throw execResult.missing![0];\n }\n\n return {\n result: execResult.result,\n missing: execResult.missing,\n complete: !hasMissingFields,\n };\n }\n\n public isFresh(\n result: Record<string, any>,\n parent: StoreObject | Reference,\n selectionSet: SelectionSetNode,\n context: ReadMergeModifyContext,\n ): boolean {\n if (supportsResultCaching(context.store) &&\n this.knownResults.get(result) === selectionSet) {\n const latest = this.executeSelectionSet.peek(\n selectionSet,\n parent,\n context,\n // If result is canonical, then it could only have been previously\n // cached by the canonizing version of executeSelectionSet, so we can\n // avoid checking both possibilities here.\n this.canon.isKnown(result),\n );\n if (latest && result === latest.result) {\n return true;\n }\n }\n return false;\n }\n\n // Uncached version of executeSelectionSet.\n private execSelectionSetImpl({\n selectionSet,\n objectOrReference,\n enclosingRef,\n context,\n }: ExecSelectionSetOptions): ExecResult {\n if (isReference(objectOrReference) &&\n !context.policies.rootTypenamesById[objectOrReference.__ref] &&\n !context.store.has(objectOrReference.__ref)) {\n return {\n result: this.canon.empty,\n missing: [missingFromInvariant(\n new InvariantError(\n `Dangling reference to missing ${objectOrReference.__ref} object`\n ),\n context,\n )],\n };\n }\n\n const { variables, policies, store } = context;\n const objectsToMerge: { [key: string]: any }[] = [];\n const finalResult: ExecResult = { result: null };\n const typename = store.getFieldValue<string>(objectOrReference, \"__typename\");\n\n if (this.config.addTypename &&\n typeof typename === \"string\" &&\n !policies.rootIdsByTypename[typename]) {\n // Ensure we always include a default value for the __typename\n // field, if we have one, and this.config.addTypename is true. Note\n // that this field can be overridden by other merged objects.\n objectsToMerge.push({ __typename: typename });\n }\n\n function getMissing() {\n return finalResult.missing || (finalResult.missing = []);\n }\n\n function handleMissing<T>(result: ExecResult<T>): T {\n if (result.missing) getMissing().push(...result.missing);\n return result.result;\n }\n\n const workSet = new Set(selectionSet.selections);\n\n workSet.forEach(selection => {\n // Omit fields with directives @skip(if: <truthy value>) or\n // @include(if: <falsy value>).\n if (!shouldInclude(selection, variables)) return;\n\n if (isField(selection)) {\n let fieldValue = policies.readField({\n fieldName: selection.name.value,\n field: selection,\n variables: context.variables,\n from: objectOrReference,\n }, context);\n\n const resultName = resultKeyNameFromField(selection);\n context.path.push(resultName);\n\n if (fieldValue === void 0) {\n if (!addTypenameToDocument.added(selection)) {\n getMissing().push(\n missingFromInvariant(\n new InvariantError(`Can't find field '${\n selection.name.value\n }' on ${\n isReference(objectOrReference)\n ? objectOrReference.__ref + \" object\"\n : \"object \" + JSON.stringify(objectOrReference, null, 2)\n }`),\n context,\n ),\n );\n }\n\n } else if (Array.isArray(fieldValue)) {\n fieldValue = handleMissing(this.executeSubSelectedArray({\n field: selection,\n array: fieldValue,\n enclosingRef,\n context,\n }));\n\n } else if (!selection.selectionSet) {\n // If the field does not have a selection set, then we handle it\n // as a scalar value. To keep this.canon from canonicalizing\n // this value, we use this.canon.pass to wrap fieldValue in a\n // Pass object that this.canon.admit will later unwrap as-is.\n if (context.canonizeResults) {\n fieldValue = this.canon.pass(fieldValue);\n }\n\n } else if (fieldValue != null) {\n // In this case, because we know the field has a selection set,\n // it must be trying to query a GraphQLObjectType, which is why\n // fieldValue must be != null.\n fieldValue = handleMissing(this.executeSelectionSet({\n selectionSet: selection.selectionSet,\n objectOrReference: fieldValue as StoreObject | Reference,\n enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,\n context,\n }));\n }\n\n if (fieldValue !== void 0) {\n objectsToMerge.push({ [resultName]: fieldValue });\n }\n\n invariant(context.path.pop() === resultName);\n\n } else {\n const fragment = getFragmentFromSelection(\n selection,\n context.fragmentMap,\n );\n\n if (fragment && policies.fragmentMatches(fragment, typename)) {\n fragment.selectionSet.selections.forEach(workSet.add, workSet);\n }\n }\n });\n\n // Perform a single merge at the end so that we can avoid making more\n // defensive shallow copies than necessary.\n const merged = mergeDeepArray(objectsToMerge);\n finalResult.result = context.canonizeResults\n ? this.canon.admit(merged)\n // Since this.canon is normally responsible for freezing results (only in\n // development), freeze them manually if canonization is disabled.\n : maybeDeepFreeze(merged);\n\n // Store this result with its selection set so that we can quickly\n // recognize it again in the StoreReader#isFresh method.\n this.knownResults.set(finalResult.result, selectionSet);\n\n return finalResult;\n }\n\n // Uncached version of executeSubSelectedArray.\n private execSubSelectedArrayImpl({\n field,\n array,\n enclosingRef,\n context,\n }: ExecSubSelectedArrayOptions): ExecResult {\n let missing: MissingFieldError[] | undefined;\n\n function handleMissing<T>(childResult: ExecResult<T>, i: number): T {\n if (childResult.missing) {\n missing = missing || [];\n missing.push(...childResult.missing);\n }\n\n invariant(context.path.pop() === i);\n\n return childResult.result;\n }\n\n if (field.selectionSet) {\n array = array.filter(context.store.canRead);\n }\n\n array = array.map((item, i) => {\n // null value in array\n if (item === null) {\n return null;\n }\n\n context.path.push(i);\n\n // This is a nested array, recurse\n if (Array.isArray(item)) {\n return handleMissing(this.executeSubSelectedArray({\n field,\n array: item,\n enclosingRef,\n context,\n }), i);\n }\n\n // This is an object, run the selection set on it\n if (field.selectionSet) {\n return handleMissing(this.executeSelectionSet({\n selectionSet: field.selectionSet,\n objectOrReference: item,\n enclosingRef: isReference(item) ? item : enclosingRef,\n context,\n }), i);\n }\n\n if (__DEV__) {\n assertSelectionSetForIdValue(context.store, field, item);\n }\n\n invariant(context.path.pop() === i);\n\n return item;\n });\n\n return {\n result: context.canonizeResults ? this.canon.admit(array) : array,\n missing,\n };\n }\n}\n\nfunction assertSelectionSetForIdValue(\n store: NormalizedCache,\n field: FieldNode,\n fieldValue: any,\n) {\n if (!field.selectionSet) {\n const workSet = new Set([fieldValue]);\n workSet.forEach(value => {\n if (isNonNullObject(value)) {\n invariant(\n !isReference(value),\n `Missing selection set for object of type ${\n getTypenameFromStoreObject(store, value)\n } returned for query field ${field.name.value}`,\n );\n Object.values(value).forEach(workSet.add, workSet);\n }\n });\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { DocumentNode, FieldNode } from 'graphql';
|
|
|
2
2
|
import { Transaction } from '../core/cache';
|
|
3
3
|
import { StoreObject, StoreValue, Reference } from '../../utilities';
|
|
4
4
|
import { FieldValueGetter } from './entityStore';
|
|
5
|
-
import { KeyFieldsFunction, StorageType, FieldMergeFunction } from './policies';
|
|
5
|
+
import { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction } from './policies';
|
|
6
6
|
import { Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
|
|
7
7
|
export { StoreObject, StoreValue, Reference };
|
|
8
8
|
export interface IdGetterObj extends Object {
|
|
@@ -55,6 +55,13 @@ export declare type ApolloReducerConfig = {
|
|
|
55
55
|
dataIdFromObject?: KeyFieldsFunction;
|
|
56
56
|
addTypename?: boolean;
|
|
57
57
|
};
|
|
58
|
+
export interface InMemoryCacheConfig extends ApolloReducerConfig {
|
|
59
|
+
resultCaching?: boolean;
|
|
60
|
+
possibleTypes?: PossibleTypesMap;
|
|
61
|
+
typePolicies?: TypePolicies;
|
|
62
|
+
resultCacheMaxSize?: number;
|
|
63
|
+
canonizeResults?: boolean;
|
|
64
|
+
}
|
|
58
65
|
export interface MergeInfo {
|
|
59
66
|
field: FieldNode;
|
|
60
67
|
typename: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA;AAE7C,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,CAC7B,KAAK,EAAE,WAAW,KACf,MAAM,GAAG,SAAS,CAAC;AAMxB,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAA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B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,oBAAY,4BAA4B,GAAG,gBAAgB,GAAG;IAC5D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,oBAAY,mBAAmB,GAAG;IAChC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"AA0IC,CAAC;AAKD,CAAC","sourcesContent":["import { DocumentNode, FieldNode } from 'graphql';\n\nimport { Transaction } from '../core/cache';\nimport {\n StoreObject,\n StoreValue,\n Reference,\n} from '../../utilities';\nimport { FieldValueGetter } from './entityStore';\nimport {\n TypePolicies,\n PossibleTypesMap,\n KeyFieldsFunction,\n StorageType,\n FieldMergeFunction,\n} from './policies';\nimport {\n Modifier,\n Modifiers,\n ToReferenceFunction,\n CanReadFunction,\n} from '../core/types/common';\n\nexport { StoreObject, StoreValue, Reference }\n\nexport interface IdGetterObj extends Object {\n __typename?: string;\n id?: string;\n _id?: string;\n}\n\nexport declare type IdGetter = (\n value: IdGetterObj,\n) => string | undefined;\n\n/**\n * This is an interface used to access, set and remove\n * StoreObjects from the cache\n */\nexport interface NormalizedCache {\n has(dataId: string): boolean;\n get(dataId: string, fieldName: string): StoreValue;\n\n // The store.merge method allows either argument to be a string ID, but\n // the other argument has to be a StoreObject. Either way, newer fields\n // always take precedence over older fields.\n merge(olderId: string, newerObject: StoreObject): void;\n merge(olderObject: StoreObject, newerId: string): void;\n\n modify(dataId: string, fields: Modifiers | Modifier<any>): boolean;\n delete(dataId: string, fieldName?: string): boolean;\n clear(): void;\n\n // non-Map elements:\n /**\n * returns an Object with key-value pairs matching the contents of the store\n */\n toObject(): NormalizedCacheObject;\n /**\n * replace the state of the store\n */\n replace(newData: NormalizedCacheObject): void;\n\n /**\n * Retain (or release) a given root ID to protect (or expose) it and its\n * transitive child entities from (or to) garbage collection. The current\n * retainment count is returned by both methods. Note that releasing a root\n * ID does not cause that entity to be garbage collected, but merely removes\n * it from the set of root IDs that will be considered during the next\n * mark-and-sweep collection.\n */\n retain(rootId: string): number;\n release(rootId: string): number;\n\n getFieldValue: FieldValueGetter;\n toReference: ToReferenceFunction;\n canRead: CanReadFunction;\n\n getStorage(\n idOrObj: string | StoreObject,\n ...storeFieldNames: (string | number)[]\n ): StorageType;\n}\n\n/**\n * This is a normalized representation of the Apollo query result cache. It consists of\n * a flattened representation of query result trees.\n */\nexport interface NormalizedCacheObject {\n __META?: {\n // Well-known singleton IDs like ROOT_QUERY and ROOT_MUTATION are\n // always considered to be root IDs during cache.gc garbage\n // collection, but other IDs can become roots if they are written\n // directly with cache.writeFragment or retained explicitly with\n // cache.retain. When such IDs exist, we include them in the __META\n // section so that they can survive cache.{extract,restore}.\n extraRootIds: string[];\n };\n [dataId: string]: StoreObject | undefined;\n}\n\nexport type OptimisticStoreItem = {\n id: string;\n data: NormalizedCacheObject;\n transaction: Transaction<NormalizedCacheObject>;\n};\n\nexport type ReadQueryOptions = {\n store: NormalizedCache;\n query: DocumentNode;\n variables?: Object;\n previousResult?: any;\n canonizeResults?: boolean;\n rootId?: string;\n config?: ApolloReducerConfig;\n};\n\nexport type DiffQueryAgainstStoreOptions = ReadQueryOptions & {\n returnPartialData?: boolean;\n};\n\nexport type ApolloReducerConfig = {\n dataIdFromObject?: KeyFieldsFunction;\n addTypename?: boolean;\n};\n\nexport interface InMemoryCacheConfig extends ApolloReducerConfig {\n resultCaching?: boolean;\n possibleTypes?: PossibleTypesMap;\n typePolicies?: TypePolicies;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n}\n\nexport interface MergeInfo {\n field: FieldNode;\n typename: string | undefined;\n merge: FieldMergeFunction;\n};\n\nexport interface MergeTree {\n info?: MergeInfo;\n map: Map<string | number, MergeTree>;\n};\n\nexport interface ReadMergeModifyContext {\n store: NormalizedCache;\n variables?: Record<string, any>;\n // A JSON.stringify-serialized version of context.variables.\n varString?: string;\n}\n"]}
|
package/core/ApolloClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloClient.js","sourceRoot":"","sources":["../../src/core/ApolloClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,EAAE,UAAU,EAA+B,OAAO,EAA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from 'graphql';\n\nimport { ApolloLink, FetchResult, GraphQLRequest, execute } from '../link/core';\nimport { ApolloCache, DataProxy } from '../cache';\nimport { Observable, compact } from '../utilities';\nimport { version } from '../version';\nimport { HttpLink, UriFunction } from '../link/http';\n\nimport { QueryManager } from './QueryManager';\nimport { ObservableQuery } from './ObservableQuery';\n\nimport {\n ApolloQueryResult,\n DefaultContext,\n OperationVariables,\n Resolvers,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n InternalRefetchQueriesResult,\n RefetchQueriesInclude,\n} from './types';\n\nimport {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n WatchQueryFetchPolicy,\n} from './watchQueryOptions';\n\nimport {\n LocalState,\n FragmentMatcher,\n} from './LocalState';\n\nexport interface DefaultOptions {\n watchQuery?: Partial<WatchQueryOptions<any, any>>;\n query?: Partial<QueryOptions<any, any>>;\n mutate?: Partial<MutationOptions<any, any, any>>;\n}\n\nlet hasSuggestedDevtools = false;\n\nexport type ApolloClientOptions<TCacheShape> = {\n uri?: string | UriFunction;\n credentials?: string;\n headers?: Record<string, string>;\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\ntype OptionsUnion<TData, TVariables, TContext> =\n | WatchQueryOptions<TVariables, TData>\n | QueryOptions<TVariables, TData>\n | MutationOptions<TData, TVariables, TContext>;\n\nexport function mergeOptions<\n TOptions extends OptionsUnion<any, any, any>\n>(\n defaults: Partial<TOptions>,\n options: TOptions,\n): TOptions {\n return compact(defaults, options, options.variables && {\n variables: {\n ...defaults.variables,\n ...options.variables,\n },\n });\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 class ApolloClient<TCacheShape> implements DataProxy {\n public link: ApolloLink;\n public cache: ApolloCache<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 queryManager: QueryManager<TCacheShape>;\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 uri The GraphQL endpoint that Apollo Client will connect to. If\n * `link` is configured, this option is ignored.\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 uri,\n credentials,\n headers,\n cache,\n ssrMode = false,\n ssrForceFetchDelay = 0,\n connectToDevTools =\n // Expose the client instance as window.__APOLLO_CLIENT__ and call\n // onBroadcast in queryManager.broadcastQueries to enable browser\n // devtools, but disable them by default in production.\n typeof window === 'object' &&\n !(window as any).__APOLLO_CLIENT__ &&\n __DEV__,\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 (!link) {\n link = uri\n ? new HttpLink({ uri, credentials, headers })\n : ApolloLink.empty();\n }\n\n if (!cache) {\n throw new InvariantError(\n \"To initialize Apollo Client, you must specify a 'cache' property \" +\n \"in the options object. \\n\" +\n \"For more information, please visit: https://go.apollo.dev/c/docs\"\n );\n }\n\n this.link = link;\n this.cache = 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 if (connectToDevTools && typeof window === 'object') {\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 && __DEV__) {\n hasSuggestedDevtools = true;\n if (\n typeof window !== 'undefined' &&\n window.document &&\n window.top === window.self &&\n !(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__\n ) {\n const nav = window.navigator;\n const ua = nav && nav.userAgent;\n let url: string | undefined;\n if (typeof ua === \"string\") {\n if (ua.indexOf(\"Chrome/\") > -1) {\n url = \"https://chrome.google.com/webstore/detail/\" +\n \"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm\";\n } else if (ua.indexOf(\"Firefox/\") > -1) {\n url = \"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/\";\n }\n }\n if (url) {\n invariant.log(\n \"Download the Apollo DevTools for a better development \" +\n \"experience: \" + url\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 cache: this.cache,\n link: this.link,\n queryDeduplication,\n ssrMode,\n clientAwareness: {\n name: clientAwarenessName!,\n version: clientAwarenessVersion!,\n },\n localState: this.localState,\n assumeImmutableResults,\n onBroadcast: connectToDevTools ? () => {\n if (this.devToolsHookCb) {\n this.devToolsHookCb({\n action: {},\n state: {\n queries: this.queryManager.getQueryStore(),\n mutations: this.queryManager.mutationStore || {},\n },\n dataWithOptimisticResults: this.cache.extract(true),\n });\n }\n } : void 0,\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, T>,\n ): ObservableQuery<T, TVariables> {\n if (this.defaultOptions.watchQuery) {\n options = mergeOptions(this.defaultOptions.watchQuery, options);\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, T>,\n ): Promise<ApolloQueryResult<T>> {\n if (this.defaultOptions.query) {\n options = mergeOptions(this.defaultOptions.query, options);\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, TVariables>(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<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>\n >(\n options: MutationOptions<TData, TVariables, TContext>,\n ): Promise<FetchResult<TData>> {\n if (this.defaultOptions.mutate) {\n options = mergeOptions(this.defaultOptions.mutate, options);\n }\n return this.queryManager.mutate<TData, TVariables, TContext, TCache>(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, T>,\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, T>,\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, T>,\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 this.cache.writeQuery<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\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 this.cache.writeFragment<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\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 * 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 * Refetches specified active queries. Similar to \"reFetchObservableQueries()\" but with a specific list of queries.\n *\n * `refetchQueries()` is useful for use cases to imperatively refresh a selection of queries.\n *\n * It is important to remember that `refetchQueries()` *will* refetch specified 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 refetchQueries<\n TCache extends ApolloCache<any> = ApolloCache<TCacheShape>,\n TResult = Promise<ApolloQueryResult<any>>,\n >(\n options: RefetchQueriesOptions<TCache, TResult>,\n ): RefetchQueriesResult<TResult> {\n const map = this.queryManager.refetchQueries(options);\n const queries: ObservableQuery<any>[] = [];\n const results: InternalRefetchQueriesResult<TResult>[] = [];\n\n map.forEach((result, obsQuery) => {\n queries.push(obsQuery);\n results.push(result);\n });\n\n const result = Promise.all<TResult>(\n results as TResult[]\n ) as RefetchQueriesResult<TResult>;\n\n // In case you need the raw results immediately, without awaiting\n // Promise.all(results):\n result.queries = queries;\n result.results = results;\n\n // If you decide to ignore the result Promise because you're using\n // result.queries and result.results instead, you shouldn't have to worry\n // about preventing uncaught rejections for the Promise.all result.\n result.catch(error => {\n invariant.debug(`In client.refetchQueries, Promise.all promise rejected with error ${error}`);\n });\n\n return result;\n }\n\n /**\n * Get all currently active `ObservableQuery` objects, in a `Map` keyed by\n * query ID strings. An \"active\" query is one that has observers and a\n * `fetchPolicy` other than \"standby\" or \"cache-only\". You can include all\n * `ObservableQuery` objects (including the inactive ones) by passing \"all\"\n * instead of \"active\", or you can include just a subset of active queries by\n * passing an array of query names or DocumentNode objects.\n */\n public getObservableQueries(\n include: RefetchQueriesInclude = \"active\",\n ): Map<string, ObservableQuery<any>> {\n return this.queryManager.getObservableQueries(include);\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 /**\n * Define a new ApolloLink (or link chain) that Apollo Client will use.\n */\n public setLink(newLink: ApolloLink) {\n this.link = this.queryManager.link = newLink;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApolloClient.js","sourceRoot":"","sources":["../../src/core/ApolloClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,EAAE,UAAU,EAA+B,OAAO,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAc,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ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EAAqE,KAAO,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAUM,2CAAoB,GAA3B,UACE,OAAyC;QAAzC,wBAAA,EAAA,kBAAyC;QAEzC,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAKM,8BAAO,GAAd,UAAe,UAAoB;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IASM,8BAAO,GAAd,UAAe,eAA4B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,CAAC;IAKM,mCAAY,GAAnB,UAAoB,SAAkC;QACpD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAKM,mCAAY,GAAnB,UAAoB,SAAkC;QACpD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAKM,mCAAY,GAAnB;QACE,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAKM,mDAA4B,GAAnC,UAAoC,eAAgC;QAClE,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACtD,CAAC;IAKM,8BAAO,GAAd,UAAe,OAAmB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC;IAC/C,CAAC;IACH,mBAAC;AAAD,CAAC,AAviBD,IAuiBC","sourcesContent":["import { invariant, InvariantError } from '../utilities/globals';\n\nimport { ExecutionResult, DocumentNode } from 'graphql';\n\nimport { ApolloLink, FetchResult, GraphQLRequest, execute } from '../link/core';\nimport { ApolloCache, DataProxy } from '../cache';\nimport { Observable, compact } from '../utilities';\nimport { version } from '../version';\nimport { HttpLink, UriFunction } from '../link/http';\n\nimport { QueryManager } from './QueryManager';\nimport { ObservableQuery } from './ObservableQuery';\n\nimport {\n ApolloQueryResult,\n DefaultContext,\n OperationVariables,\n Resolvers,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n InternalRefetchQueriesResult,\n RefetchQueriesInclude,\n} from './types';\n\nimport {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n WatchQueryFetchPolicy,\n} from './watchQueryOptions';\n\nimport {\n LocalState,\n FragmentMatcher,\n} from './LocalState';\n\nexport interface DefaultOptions {\n watchQuery?: Partial<WatchQueryOptions<any, any>>;\n query?: Partial<QueryOptions<any, any>>;\n mutate?: Partial<MutationOptions<any, any, any>>;\n}\n\nlet hasSuggestedDevtools = false;\n\nexport type ApolloClientOptions<TCacheShape> = {\n uri?: string | UriFunction;\n credentials?: string;\n headers?: Record<string, string>;\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\ntype OptionsUnion<TData, TVariables, TContext> =\n | WatchQueryOptions<TVariables, TData>\n | QueryOptions<TVariables, TData>\n | MutationOptions<TData, TVariables, TContext>;\n\nexport function mergeOptions<\n TOptions extends OptionsUnion<any, any, any>\n>(\n defaults: Partial<TOptions>,\n options: TOptions,\n): TOptions {\n return compact(defaults, options, options.variables && {\n variables: {\n ...defaults.variables,\n ...options.variables,\n },\n });\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 class ApolloClient<TCacheShape> implements DataProxy {\n public link: ApolloLink;\n public cache: ApolloCache<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 queryManager: QueryManager<TCacheShape>;\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 uri The GraphQL endpoint that Apollo Client will connect to. If\n * `link` is configured, this option is ignored.\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 uri,\n credentials,\n headers,\n cache,\n ssrMode = false,\n ssrForceFetchDelay = 0,\n connectToDevTools =\n // Expose the client instance as window.__APOLLO_CLIENT__ and call\n // onBroadcast in queryManager.broadcastQueries to enable browser\n // devtools, but disable them by default in production.\n typeof window === 'object' &&\n !(window as any).__APOLLO_CLIENT__ &&\n __DEV__,\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 (!link) {\n link = uri\n ? new HttpLink({ uri, credentials, headers })\n : ApolloLink.empty();\n }\n\n if (!cache) {\n throw new InvariantError(\n \"To initialize Apollo Client, you must specify a 'cache' property \" +\n \"in the options object. \\n\" +\n \"For more information, please visit: https://go.apollo.dev/c/docs\"\n );\n }\n\n this.link = link;\n this.cache = 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 if (connectToDevTools && typeof window === 'object') {\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 && __DEV__) {\n hasSuggestedDevtools = true;\n if (\n typeof window !== 'undefined' &&\n window.document &&\n window.top === window.self &&\n !(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__\n ) {\n const nav = window.navigator;\n const ua = nav && nav.userAgent;\n let url: string | undefined;\n if (typeof ua === \"string\") {\n if (ua.indexOf(\"Chrome/\") > -1) {\n url = \"https://chrome.google.com/webstore/detail/\" +\n \"apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm\";\n } else if (ua.indexOf(\"Firefox/\") > -1) {\n url = \"https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/\";\n }\n }\n if (url) {\n invariant.log(\n \"Download the Apollo DevTools for a better development \" +\n \"experience: \" + url\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 cache: this.cache,\n link: this.link,\n queryDeduplication,\n ssrMode,\n clientAwareness: {\n name: clientAwarenessName!,\n version: clientAwarenessVersion!,\n },\n localState: this.localState,\n assumeImmutableResults,\n onBroadcast: connectToDevTools ? () => {\n if (this.devToolsHookCb) {\n this.devToolsHookCb({\n action: {},\n state: {\n queries: this.queryManager.getQueryStore(),\n mutations: this.queryManager.mutationStore || {},\n },\n dataWithOptimisticResults: this.cache.extract(true),\n });\n }\n } : void 0,\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 identifier, 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, T>,\n ): ObservableQuery<T, TVariables> {\n if (this.defaultOptions.watchQuery) {\n options = mergeOptions(this.defaultOptions.watchQuery, options);\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, T>,\n ): Promise<ApolloQueryResult<T>> {\n if (this.defaultOptions.query) {\n options = mergeOptions(this.defaultOptions.query, options);\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, TVariables>(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<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>\n >(\n options: MutationOptions<TData, TVariables, TContext>,\n ): Promise<FetchResult<TData>> {\n if (this.defaultOptions.mutate) {\n options = mergeOptions(this.defaultOptions.mutate, options);\n }\n return this.queryManager.mutate<TData, TVariables, TContext, TCache>(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, T>,\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, T>,\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, T>,\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 this.cache.writeQuery<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\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 this.cache.writeFragment<TData, TVariables>(options);\n this.queryManager.broadcastQueries();\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 * 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 * Refetches specified active queries. Similar to \"reFetchObservableQueries()\" but with a specific list of queries.\n *\n * `refetchQueries()` is useful for use cases to imperatively refresh a selection of queries.\n *\n * It is important to remember that `refetchQueries()` *will* refetch specified 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 refetchQueries<\n TCache extends ApolloCache<any> = ApolloCache<TCacheShape>,\n TResult = Promise<ApolloQueryResult<any>>,\n >(\n options: RefetchQueriesOptions<TCache, TResult>,\n ): RefetchQueriesResult<TResult> {\n const map = this.queryManager.refetchQueries(options);\n const queries: ObservableQuery<any>[] = [];\n const results: InternalRefetchQueriesResult<TResult>[] = [];\n\n map.forEach((result, obsQuery) => {\n queries.push(obsQuery);\n results.push(result);\n });\n\n const result = Promise.all<TResult>(\n results as TResult[]\n ) as RefetchQueriesResult<TResult>;\n\n // In case you need the raw results immediately, without awaiting\n // Promise.all(results):\n result.queries = queries;\n result.results = results;\n\n // If you decide to ignore the result Promise because you're using\n // result.queries and result.results instead, you shouldn't have to worry\n // about preventing uncaught rejections for the Promise.all result.\n result.catch(error => {\n invariant.debug(`In client.refetchQueries, Promise.all promise rejected with error ${error}`);\n });\n\n return result;\n }\n\n /**\n * Get all currently active `ObservableQuery` objects, in a `Map` keyed by\n * query ID strings. An \"active\" query is one that has observers and a\n * `fetchPolicy` other than \"standby\" or \"cache-only\". You can include all\n * `ObservableQuery` objects (including the inactive ones) by passing \"all\"\n * instead of \"active\", or you can include just a subset of active queries by\n * passing an array of query names or DocumentNode objects.\n */\n public getObservableQueries(\n include: RefetchQueriesInclude = \"active\",\n ): Map<string, ObservableQuery<any>> {\n return this.queryManager.getObservableQueries(include);\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 /**\n * Define a new ApolloLink (or link chain) that Apollo Client will use.\n */\n public setLink(newLink: ApolloLink) {\n this.link = this.queryManager.link = newLink;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAEL,OAAO,EACP,SAAS,EACT,sBAAsB,EACtB,UAAU,EAGV,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAcpB,IAAA,MAAM,GAEJ,MAAM,OAFF,EACN,cAAc,GACZ,MAA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,EAAE;QACvC,SAAS,CAAC,KAAK,CAAC,kCACd,OAAO,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAhB,CAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAC5C,EAAE,OAAO,CAAC,CAAC;KACd;AACH,CAAC;AAMD,MAAM,UAAU,oBAAoB,CAClC,OAIC;IAGC,IAAA,KAEE,OAAO,YAFkB,EAA3B,WAAW,mBAAG,aAAa,KAAA,EAC3B,eAAe,GACb,OAAO,gBADM,CACL;IAEZ,IAAI,eAAe,EAAE;QAWnB,OAAO,CAAC,WAAW,GAAG,OAAO,eAAe,KAAK,UAAU;YACzD,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;YAC5C,CAAC,CAAC,eAAe,CAAC;KACrB;AACH,CAAC","sourcesContent":["import { invariant } from '../utilities/globals';\n\nimport { equal } from '@wry/equality';\n\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport {\n Concast,\n compact,\n cloneDeep,\n getOperationDefinition,\n Observable,\n Observer,\n ObservableSubscription,\n iterateObserversSafely,\n isNonEmptyArray,\n fixObservableSubclass,\n getQueryDefinition,\n} from '../utilities';\nimport { ApolloError } from '../errors';\nimport { QueryManager } from './QueryManager';\nimport { ApolloQueryResult, OperationVariables } from './types';\nimport {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n WatchQueryFetchPolicy,\n} from './watchQueryOptions';\nimport { QueryInfo } from './QueryInfo';\nimport { MissingFieldError } from '../cache';\n\nconst {\n assign,\n hasOwnProperty,\n} = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n },\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\nlet warnedAboutUpdateQuery = false;\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables = OperationVariables\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n // Original value of this.options.fetchPolicy (defaulting to \"cache-first\"),\n // from whenever the ObservableQuery was first created.\n private initialFetchPolicy: WatchQueryFetchPolicy;\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private last?: Last<TData, TVariables>;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // active state\n this.isTornDown = false;\n\n // query information\n this.options = options;\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(options.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n\n this.initialFetchPolicy = options.fetchPolicy || \"cache-first\";\n\n // related classes\n this.queryManager = queryManager;\n this.queryInfo = queryInfo;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n // The presence of lastResult means a result has been received and\n // this.options.variables haven't changed since then, so its absence means\n // either there hasn't been a result yet (so these policies definitely\n // should skip the cache) or there's been a result but it was for different\n // variables (again, skipping the cache seems right).\n const shouldReturnCachedData = lastResult || (\n fetchPolicy !== 'network-only' &&\n fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'standby'\n );\n if (\n shouldReturnCachedData &&\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n !this.queryManager.transform(this.options.query).hasForcedResolvers\n ) {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next\n // result we receive will have NetworkStatus.ready and !loading.\n if (result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === 'cache-first' ||\n fetchPolicy === 'cache-only')) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n delete result.partial;\n } else if (fetchPolicy !== \"no-cache\") {\n // Since result.partial comes from diff.complete, and we shouldn't be\n // using cache data to provide a DiffResult when the fetchPolicy is\n // \"no-cache\", avoid annotating result.partial for \"no-cache\" results.\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(newResult: ApolloQueryResult<TData>) {\n return !this.last || !equal(this.last.result, newResult);\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean,\n ) {\n const last = this.last;\n if (last &&\n last[key] &&\n (!variablesMustMatch || equal(last!.variables, this.variables))) {\n return last[key];\n }\n }\n\n public getLastResult(variablesMustMatch?: boolean): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(variables?: Partial<TVariables>): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === 'no-cache') {\n reobserveOptions.fetchPolicy = 'no-cache';\n } else if (fetchPolicy !== 'cache-and-network') {\n reobserveOptions.fetchPolicy = 'network-only';\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.options.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some(v => v.variable.name.value === \"variables\")) {\n invariant.warn(`Called refetch(${\n JSON.stringify(variables)\n }) for query ${\n queryDef.name?.value || JSON.stringify(queryDef)\n }, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`);\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore(\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> &\n FetchMoreOptions<TData, TVariables>,\n ): Promise<ApolloQueryResult<TData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : {\n ...this.options,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions;\n\n const qid = this.queryManager.generateQueryId();\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.queryInfo.networkStatus = NetworkStatus.fetchMore;\n this.observe();\n }\n\n return this.queryManager.fetchQuery(\n qid,\n combinedOptions,\n NetworkStatus.fetchMore,\n ).then(fetchMoreResult => {\n const data = fetchMoreResult.data as TData;\n const { updateQuery } = fetchMoreOptions;\n\n if (updateQuery) {\n if (__DEV__ &&\n !warnedAboutUpdateQuery) {\n invariant.warn(\n`The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore.`);\n warnedAboutUpdateQuery = true;\n }\n this.updateQuery(previous => updateQuery(previous, {\n fetchMoreResult: data,\n variables: combinedOptions.variables as TVariables,\n }));\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n this.queryManager.cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data,\n });\n }\n\n return fetchMoreResult as ApolloQueryResult<TData>;\n\n }).finally(() => {\n this.queryManager.stopQuery(qid);\n this.reobserve();\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >,\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n }),\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error('Unhandled GraphQL subscription error', err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>,\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n /**\n * This is for *internal* use only. Most users should instead use `refetch`\n * in order to be properly notified of results even when they come from cache.\n *\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. If you want to force new results, use `refetch`.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables,\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size\n ? this.result()\n : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve({\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.initialFetchPolicy,\n variables,\n }, NetworkStatus.setVariables);\n }\n\n public updateQuery<TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">,\n ) => TData,\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n ): Concast<ApolloQueryResult<TData>> {\n this.queryManager.setObservableQuery(this);\n return this.queryManager.fetchQueryObservable(\n this.queryId,\n options,\n newNetworkStatus,\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: {\n pollInterval,\n },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo &&\n pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n 'Attempted to start a polling query without a polling interval.',\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {\n this.reobserve({\n fetchPolicy: \"network-only\",\n }, NetworkStatus.poll).then(poll, poll);\n } else {\n poll();\n }\n };\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables,\n ) {\n this.last = {\n ...this.last,\n result: this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult),\n variables,\n };\n if (!isNonEmptyArray(newResult.errors)) {\n delete this.last.error;\n }\n return this.last;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus,\n ): Promise<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n\n const options = useDisposableConcast\n // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n ? compact(this.options, newOptions)\n : assign(this.options, compact(newOptions));\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !newOptions.fetchPolicy &&\n !equal(newOptions.variables, oldVariables)\n ) {\n options.fetchPolicy = this.initialFetchPolicy;\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n const variables = options.variables && { ...options.variables };\n const concast = this.fetch(options, newNetworkStatus);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: result => {\n this.reportResult(result, variables);\n },\n error: error => {\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object, in part so\n // that we can remove it here without triggering any unsubscriptions,\n // because we just want to ignore the old observable, not prematurely shut\n // it down, since other consumers may be awaiting this.concast.promise.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer, true);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast.promise;\n }\n\n // Pass the current result to this.observer.next without applying any\n // fetch policies.\n private observe() {\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.observer.next.\n this.reportResult(\n this.getCurrentResult(false),\n this.variables,\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined,\n ) {\n if (this.getLastError() || this.isDifferentFromLastResult(result)) {\n this.updateLastResult(result, variables);\n iterateObserversSafely(this.observers, 'next', result);\n }\n }\n\n private reportError(\n error: ApolloError,\n variables: TVariables | undefined,\n ) {\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 const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, 'error', this.last!.error = error);\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach(sub => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error('Unhandled error', error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | undefined,\n) {\n if (__DEV__ && isNonEmptyArray(missing)) {\n invariant.debug(`Missing cache result fields: ${\n missing.map(m => m.path.join('.')).join(', ')\n }`, missing);\n }\n}\n\n// Adopt options.nextFetchPolicy (if defined) as a replacement for\n// options.fetchPolicy. Since this method also removes options.nextFetchPolicy\n// from options, the adoption tends to be idempotent, unless nextFetchPolicy\n// is a function that keeps setting options.nextFetchPolicy (uncommon).\nexport function applyNextFetchPolicy<TData, TVars>(\n options: Pick<\n WatchQueryOptions<TVars, TData>,\n | \"fetchPolicy\"\n | \"nextFetchPolicy\"\n >,\n) {\n const {\n fetchPolicy = \"cache-first\",\n nextFetchPolicy,\n } = options;\n\n if (nextFetchPolicy) {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would seem\n // to imply. Instead, when the cache reports an update after the initial\n // network request, it may be desirable for subsequent network requests to\n // be triggered only if the cache result is incomplete. To that end, the\n // options.nextFetchPolicy option provides an easy way to update\n // options.fetchPolicy after the intial network request, without having to\n // call observableQuery.setOptions.\n options.fetchPolicy = typeof nextFetchPolicy === \"function\"\n ? nextFetchPolicy.call(options, fetchPolicy)\n : nextFetchPolicy;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE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AAD,CAAC,AA1uBD,CAGU,UAAU,GAuuBnB;;AAID,qBAAqB,CAAC,eAAe,CAAC,CAAC;AAEvC,SAAS,wCAAwC,CAAC,KAAkB;IAClE,SAAS,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAwC;IAExC,IAAI,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE;QACvC,SAAS,CAAC,KAAK,CAAC,kCACd,OAAO,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAhB,CAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAC5C,EAAE,OAAO,CAAC,CAAC;KACd;AACH,CAAC;AAMD,MAAM,UAAU,oBAAoB,CAClC,OAIC;IAGC,IAAA,KAEE,OAAO,YAFkB,EAA3B,WAAW,mBAAG,aAAa,KAAA,EAC3B,eAAe,GACb,OAAO,gBADM,CACL;IAEZ,IAAI,eAAe,EAAE;QAWnB,OAAO,CAAC,WAAW,GAAG,OAAO,eAAe,KAAK,UAAU;YACzD,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;YAC5C,CAAC,CAAC,eAAe,CAAC;KACrB;AACH,CAAC","sourcesContent":["import { invariant } from '../utilities/globals';\n\nimport { equal } from '@wry/equality';\n\nimport { NetworkStatus, isNetworkRequestInFlight } from './networkStatus';\nimport {\n Concast,\n compact,\n cloneDeep,\n getOperationDefinition,\n Observable,\n Observer,\n ObservableSubscription,\n iterateObserversSafely,\n isNonEmptyArray,\n fixObservableSubclass,\n getQueryDefinition,\n} from '../utilities';\nimport { ApolloError } from '../errors';\nimport { QueryManager } from './QueryManager';\nimport { ApolloQueryResult, OperationVariables } from './types';\nimport {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n WatchQueryFetchPolicy,\n} from './watchQueryOptions';\nimport { QueryInfo } from './QueryInfo';\nimport { MissingFieldError } from '../cache';\n\nconst {\n assign,\n hasOwnProperty,\n} = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n },\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\nlet warnedAboutUpdateQuery = false;\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables = OperationVariables\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n // Original value of this.options.fetchPolicy (defaulting to \"cache-first\"),\n // from whenever the ObservableQuery was first created.\n private initialFetchPolicy: WatchQueryFetchPolicy;\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private last?: Last<TData, TVariables>;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // active state\n this.isTornDown = false;\n\n // query information\n this.options = options;\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(options.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n\n this.initialFetchPolicy = options.fetchPolicy || \"cache-first\";\n\n // related classes\n this.queryManager = queryManager;\n this.queryInfo = queryInfo;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n // The presence of lastResult means a result has been received and\n // this.options.variables haven't changed since then, so its absence means\n // either there hasn't been a result yet (so these policies definitely\n // should skip the cache) or there's been a result but it was for different\n // variables (again, skipping the cache seems right).\n const shouldReturnCachedData = lastResult || (\n fetchPolicy !== 'network-only' &&\n fetchPolicy !== 'no-cache' &&\n fetchPolicy !== 'standby'\n );\n if (\n shouldReturnCachedData &&\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n !this.queryManager.transform(this.options.query).hasForcedResolvers\n ) {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next\n // result we receive will have NetworkStatus.ready and !loading.\n if (result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === 'cache-first' ||\n fetchPolicy === 'cache-only')) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n delete result.partial;\n } else if (fetchPolicy !== \"no-cache\") {\n // Since result.partial comes from diff.complete, and we shouldn't be\n // using cache data to provide a DiffResult when the fetchPolicy is\n // \"no-cache\", avoid annotating result.partial for \"no-cache\" results.\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(newResult: ApolloQueryResult<TData>) {\n return !this.last || !equal(this.last.result, newResult);\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean,\n ) {\n const last = this.last;\n if (last &&\n last[key] &&\n (!variablesMustMatch || equal(last!.variables, this.variables))) {\n return last[key];\n }\n }\n\n public getLastResult(variablesMustMatch?: boolean): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(variables?: Partial<TVariables>): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === 'no-cache') {\n reobserveOptions.fetchPolicy = 'no-cache';\n } else if (fetchPolicy !== 'cache-and-network') {\n reobserveOptions.fetchPolicy = 'network-only';\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.options.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some(v => v.variable.name.value === \"variables\")) {\n invariant.warn(`Called refetch(${\n JSON.stringify(variables)\n }) for query ${\n queryDef.name?.value || JSON.stringify(queryDef)\n }, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`);\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore(\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> &\n FetchMoreOptions<TData, TVariables>,\n ): Promise<ApolloQueryResult<TData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : {\n ...this.options,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions;\n\n const qid = this.queryManager.generateQueryId();\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.queryInfo.networkStatus = NetworkStatus.fetchMore;\n this.observe();\n }\n\n return this.queryManager.fetchQuery(\n qid,\n combinedOptions,\n NetworkStatus.fetchMore,\n ).then(fetchMoreResult => {\n const data = fetchMoreResult.data as TData;\n const { updateQuery } = fetchMoreOptions;\n\n if (updateQuery) {\n if (__DEV__ &&\n !warnedAboutUpdateQuery) {\n invariant.warn(\n`The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore.`);\n warnedAboutUpdateQuery = true;\n }\n this.updateQuery(previous => updateQuery(previous, {\n fetchMoreResult: data,\n variables: combinedOptions.variables as TVariables,\n }));\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n this.queryManager.cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data,\n });\n }\n\n return fetchMoreResult as ApolloQueryResult<TData>;\n\n }).finally(() => {\n this.queryManager.stopQuery(qid);\n this.reobserve();\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables = TVariables\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >,\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n }),\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error('Unhandled GraphQL subscription error', err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>,\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n /**\n * This is for *internal* use only. Most users should instead use `refetch`\n * in order to be properly notified of results even when they come from cache.\n *\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. If you want to force new results, use `refetch`.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables,\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size\n ? this.result()\n : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve({\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.initialFetchPolicy,\n variables,\n }, NetworkStatus.setVariables);\n }\n\n public updateQuery<TVars = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">,\n ) => TData,\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n ): Concast<ApolloQueryResult<TData>> {\n this.queryManager.setObservableQuery(this);\n return this.queryManager.fetchQueryObservable(\n this.queryId,\n options,\n newNetworkStatus,\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: {\n pollInterval,\n },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo &&\n pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n 'Attempted to start a polling query without a polling interval.',\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {\n this.reobserve({\n fetchPolicy: \"network-only\",\n }, NetworkStatus.poll).then(poll, poll);\n } else {\n poll();\n }\n };\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables,\n ) {\n this.last = {\n ...this.last,\n result: this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult),\n variables,\n };\n if (!isNonEmptyArray(newResult.errors)) {\n delete this.last.error;\n }\n return this.last;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus,\n ): Promise<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n\n const options = useDisposableConcast\n // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n ? compact(this.options, newOptions)\n : assign(this.options, compact(newOptions));\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !newOptions.fetchPolicy &&\n !equal(newOptions.variables, oldVariables)\n ) {\n options.fetchPolicy = this.initialFetchPolicy;\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n const variables = options.variables && { ...options.variables };\n const concast = this.fetch(options, newNetworkStatus);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: result => {\n this.reportResult(result, variables);\n },\n error: error => {\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object, in part so\n // that we can remove it here without triggering any unsubscriptions,\n // because we just want to ignore the old observable, not prematurely shut\n // it down, since other consumers may be awaiting this.concast.promise.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer, true);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast.promise;\n }\n\n // Pass the current result to this.observer.next without applying any\n // fetch policies.\n private observe() {\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.observer.next.\n this.reportResult(\n this.getCurrentResult(false),\n this.variables,\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined,\n ) {\n if (this.getLastError() || this.isDifferentFromLastResult(result)) {\n this.updateLastResult(result, variables);\n iterateObserversSafely(this.observers, 'next', result);\n }\n }\n\n private reportError(\n error: ApolloError,\n variables: TVariables | undefined,\n ) {\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 const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, 'error', this.last!.error = error);\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach(sub => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error('Unhandled error', error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | undefined,\n) {\n if (__DEV__ && isNonEmptyArray(missing)) {\n invariant.debug(`Missing cache result fields: ${\n missing.map(m => m.path.join('.')).join(', ')\n }`, missing);\n }\n}\n\n// Adopt options.nextFetchPolicy (if defined) as a replacement for\n// options.fetchPolicy. Since this method also removes options.nextFetchPolicy\n// from options, the adoption tends to be idempotent, unless nextFetchPolicy\n// is a function that keeps setting options.nextFetchPolicy (uncommon).\nexport function applyNextFetchPolicy<TData, TVars>(\n options: Pick<\n WatchQueryOptions<TVars, TData>,\n | \"fetchPolicy\"\n | \"nextFetchPolicy\"\n >,\n) {\n const {\n fetchPolicy = \"cache-first\",\n nextFetchPolicy,\n } = options;\n\n if (nextFetchPolicy) {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would seem\n // to imply. Instead, when the cache reports an update after the initial\n // network request, it may be desirable for subsequent network requests to\n // be triggered only if the cache result is incomplete. To that end, the\n // options.nextFetchPolicy option provides an easy way to update\n // options.fetchPolicy after the initial network request, without having to\n // call observableQuery.setOptions.\n options.fetchPolicy = typeof nextFetchPolicy === \"function\"\n ? nextFetchPolicy.call(options, fetchPolicy)\n : nextFetchPolicy;\n }\n}\n"]}
|
package/core/QueryInfo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInfo.d.ts","sourceRoot":"","sources":["../../src/core/QueryInfo.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrD,OAAO,EAAE,KAAK,EAAe,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,OAAO,EACL,aAAa,EAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,oBAAY,eAAe,GAAG,IAAI,CAAC,SAAS,EACxC,WAAW,GACX,eAAe,GACf,cAAc,GACd,eAAe,CAChB,CAAC;AAEJ,0BAAkB,kBAAkB;IAClC,MAAM,IAAA;IACN,SAAS,IAAA;IACT,KAAK,IAAA;CACN;AA6CD,qBAAa,SAAS;aAeF,OAAO;IAdzB,SAAS,qBAA4B;IACrC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAQ;IACrC,aAAa,SAAK;IAClB,aAAa,kCAAqC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,KAAK,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