UNPKG

82.4 kBSource Map (JSON)View Raw
1{"version":3,"file":"bundle.esm.js","sources":["../src/fragmentMatcher.ts","../src/depTrackingCache.ts","../src/readFromStore.ts","../src/objectCache.ts","../src/writeToStore.ts","../src/inMemoryCache.ts"],"sourcesContent":["import { isTest, IdValue } from 'apollo-utilities';\nimport { invariant } from 'ts-invariant';\n\nimport {\n ReadStoreContext,\n FragmentMatcherInterface,\n PossibleTypesMap,\n IntrospectionResultData,\n} from './types';\n\nlet haveWarned = false;\n\nfunction shouldWarn() {\n const answer = !haveWarned;\n /* istanbul ignore if */\n if (!isTest()) {\n haveWarned = true;\n }\n return answer;\n}\n\n/**\n * This fragment matcher is very basic and unable to match union or interface type conditions\n */\nexport class HeuristicFragmentMatcher implements FragmentMatcherInterface {\n constructor() {\n // do nothing\n }\n\n public ensureReady() {\n return Promise.resolve();\n }\n\n public canBypassInit() {\n return true; // we don't need to initialize this fragment matcher.\n }\n\n public match(\n idValue: IdValue,\n typeCondition: string,\n context: ReadStoreContext,\n ): boolean | 'heuristic' {\n const obj = context.store.get(idValue.id);\n const isRootQuery = idValue.id === 'ROOT_QUERY';\n\n if (!obj) {\n // https://github.com/apollographql/apollo-client/pull/3507\n return isRootQuery;\n }\n\n const { __typename = isRootQuery && 'Query' } = obj;\n\n if (!__typename) {\n if (shouldWarn()) {\n invariant.warn(`You're using fragments in your queries, but either don't have the addTypename:\n true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.\n Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client\n can accurately match fragments.`);\n invariant.warn(\n 'Could not find __typename on Fragment ',\n typeCondition,\n obj,\n );\n invariant.warn(\n `DEPRECATION WARNING: using fragments without __typename is unsupported behavior ` +\n `and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.`,\n );\n }\n\n return 'heuristic';\n }\n\n if (__typename === typeCondition) {\n return true;\n }\n\n // At this point we don't know if this fragment should match or not. It's\n // either:\n //\n // 1. (GOOD) A fragment on a matching interface or union.\n // 2. (BAD) A fragment on a non-matching concrete type or interface or union.\n //\n // If it's 2, we don't want it to match. If it's 1, we want it to match. We\n // can't tell the difference, so we warn the user, but still try to match\n // it (for backwards compatibility reasons). This unfortunately means that\n // using the `HeuristicFragmentMatcher` with unions and interfaces is\n // very unreliable. This will be addressed in a future major version of\n // Apollo Client, but for now the recommendation is to use the\n // `IntrospectionFragmentMatcher` when working with unions/interfaces.\n\n if (shouldWarn()) {\n invariant.error(\n 'You are using the simple (heuristic) fragment matcher, but your ' +\n 'queries contain union or interface types. Apollo Client will not be ' +\n 'able to accurately map fragments. To make this error go away, use ' +\n 'the `IntrospectionFragmentMatcher` as described in the docs: ' +\n 'https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher',\n );\n }\n\n return 'heuristic';\n }\n}\n\nexport class IntrospectionFragmentMatcher implements FragmentMatcherInterface {\n private isReady: boolean;\n private possibleTypesMap: PossibleTypesMap;\n\n constructor(options?: {\n introspectionQueryResultData?: IntrospectionResultData;\n }) {\n if (options && options.introspectionQueryResultData) {\n this.possibleTypesMap = this.parseIntrospectionResult(\n options.introspectionQueryResultData,\n );\n this.isReady = true;\n } else {\n this.isReady = false;\n }\n\n this.match = this.match.bind(this);\n }\n\n public match(\n idValue: IdValue,\n typeCondition: string,\n context: ReadStoreContext,\n ) {\n invariant(\n this.isReady,\n 'FragmentMatcher.match() was called before FragmentMatcher.init()',\n );\n\n const obj = context.store.get(idValue.id);\n const isRootQuery = idValue.id === 'ROOT_QUERY';\n\n if (!obj) {\n // https://github.com/apollographql/apollo-client/pull/4620\n return isRootQuery;\n }\n\n const { __typename = isRootQuery && 'Query' } = obj;\n\n invariant(\n __typename,\n `Cannot match fragment because __typename property is missing: ${JSON.stringify(\n obj,\n )}`,\n );\n\n if (__typename === typeCondition) {\n return true;\n }\n\n const implementingTypes = this.possibleTypesMap[typeCondition];\n if (\n __typename &&\n implementingTypes &&\n implementingTypes.indexOf(__typename) > -1\n ) {\n return true;\n }\n\n return false;\n }\n\n private parseIntrospectionResult(\n introspectionResultData: IntrospectionResultData,\n ): PossibleTypesMap {\n const typeMap: PossibleTypesMap = {};\n introspectionResultData.__schema.types.forEach(type => {\n if (type.kind === 'UNION' || type.kind === 'INTERFACE') {\n typeMap[type.name] = type.possibleTypes.map(\n implementingType => implementingType.name,\n );\n }\n });\n return typeMap;\n }\n}\n","import { NormalizedCache, NormalizedCacheObject, StoreObject } from './types';\nimport { wrap, OptimisticWrapperFunction } from 'optimism';\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nexport class DepTrackingCache implements NormalizedCache {\n // Wrapper function produced by the optimism library, used to depend on\n // dataId strings, for easy invalidation of specific IDs.\n private depend: OptimisticWrapperFunction<[string], StoreObject | undefined>;\n\n constructor(private data: NormalizedCacheObject = Object.create(null)) {\n this.depend = wrap((dataId: string) => this.data[dataId], {\n disposable: true,\n makeCacheKey(dataId: string) {\n return dataId;\n },\n });\n }\n\n public toObject(): NormalizedCacheObject {\n return this.data;\n }\n\n public get(dataId: string): StoreObject {\n this.depend(dataId);\n return this.data[dataId]!;\n }\n\n public set(dataId: string, value?: StoreObject) {\n const oldValue = this.data[dataId];\n if (value !== oldValue) {\n this.data[dataId] = value;\n this.depend.dirty(dataId);\n }\n }\n\n public delete(dataId: string): void {\n if (hasOwn.call(this.data, dataId)) {\n delete this.data[dataId];\n this.depend.dirty(dataId);\n }\n }\n\n public clear(): void {\n this.replace(null);\n }\n\n public replace(newData: NormalizedCacheObject | null): void {\n if (newData) {\n Object.keys(newData).forEach(dataId => {\n this.set(dataId, newData[dataId]);\n });\n Object.keys(this.data).forEach(dataId => {\n if (!hasOwn.call(newData, dataId)) {\n this.delete(dataId);\n }\n });\n } else {\n Object.keys(this.data).forEach(dataId => {\n this.delete(dataId);\n });\n }\n }\n}\n\nexport function defaultNormalizedCacheFactory(\n seed?: NormalizedCacheObject,\n): NormalizedCache {\n return new DepTrackingCache(seed);\n}\n","import {\n argumentsObjectFromField,\n assign,\n canUseWeakMap,\n createFragmentMap,\n DirectiveInfo,\n FragmentMap,\n getDefaultValues,\n getDirectiveInfoFromField,\n getFragmentDefinitions,\n getMainDefinition,\n getQueryDefinition,\n getStoreKeyName,\n IdValue,\n isEqual,\n isField,\n isIdValue,\n isInlineFragment,\n isJsonValue,\n maybeDeepFreeze,\n mergeDeepArray,\n resultKeyNameFromField,\n shouldInclude,\n StoreValue,\n toIdValue,\n} from 'apollo-utilities';\n\nimport { Cache } from 'apollo-cache';\n\nimport {\n ReadStoreContext,\n DiffQueryAgainstStoreOptions,\n ReadQueryOptions,\n StoreObject,\n} from './types';\n\nimport {\n DocumentNode,\n FieldNode,\n FragmentDefinitionNode,\n InlineFragmentNode,\n SelectionSetNode,\n} from 'graphql';\n\nimport { wrap, KeyTrie } from 'optimism';\nimport { DepTrackingCache } from './depTrackingCache';\nimport { invariant, InvariantError } from 'ts-invariant';\n\nexport type VariableMap = { [name: string]: any };\n\nexport type FragmentMatcher = (\n rootValue: any,\n typeCondition: string,\n context: ReadStoreContext,\n) => boolean | 'heuristic';\n\ntype ExecContext = {\n query: DocumentNode;\n fragmentMap: FragmentMap;\n contextValue: ReadStoreContext;\n variableValues: VariableMap;\n fragmentMatcher: FragmentMatcher;\n};\n\ntype ExecInfo = {\n resultKey: string;\n directives: DirectiveInfo;\n};\n\nexport type ExecResultMissingField = {\n object: StoreObject;\n fieldName: string;\n tolerable: boolean;\n};\n\nexport type ExecResult<R = any> = {\n result: R;\n // Empty array if no missing fields encountered while computing result.\n missing?: ExecResultMissingField[];\n};\n\ntype ExecStoreQueryOptions = {\n query: DocumentNode;\n rootValue: IdValue;\n contextValue: ReadStoreContext;\n variableValues: VariableMap;\n // Default matcher always matches all fragments\n fragmentMatcher?: FragmentMatcher;\n};\n\ntype ExecSelectionSetOptions = {\n selectionSet: SelectionSetNode;\n rootValue: any;\n execContext: ExecContext;\n};\n\ntype ExecSubSelectedArrayOptions = {\n field: FieldNode;\n array: any[];\n execContext: ExecContext;\n};\n\nexport interface StoreReaderConfig {\n cacheKeyRoot?: KeyTrie<object>;\n freezeResults?: boolean;\n}\n\nexport class StoreReader {\n private freezeResults: boolean;\n\n constructor({\n cacheKeyRoot = new KeyTrie<object>(canUseWeakMap),\n freezeResults = false,\n }: StoreReaderConfig = {}) {\n const {\n executeStoreQuery,\n executeSelectionSet,\n executeSubSelectedArray,\n } = this;\n\n this.freezeResults = freezeResults;\n\n this.executeStoreQuery = wrap((options: ExecStoreQueryOptions) => {\n return executeStoreQuery.call(this, options);\n }, {\n makeCacheKey({\n query,\n rootValue,\n contextValue,\n variableValues,\n fragmentMatcher,\n }: ExecStoreQueryOptions) {\n // The result of executeStoreQuery can be safely cached only if the\n // underlying store is capable of tracking dependencies and invalidating\n // the cache when relevant data have changed.\n if (contextValue.store instanceof DepTrackingCache) {\n return cacheKeyRoot.lookup(\n contextValue.store,\n query,\n fragmentMatcher,\n JSON.stringify(variableValues),\n rootValue.id,\n );\n }\n }\n });\n\n this.executeSelectionSet = wrap((options: ExecSelectionSetOptions) => {\n return executeSelectionSet.call(this, options);\n }, {\n makeCacheKey({\n selectionSet,\n rootValue,\n execContext,\n }: ExecSelectionSetOptions) {\n if (execContext.contextValue.store instanceof DepTrackingCache) {\n return cacheKeyRoot.lookup(\n execContext.contextValue.store,\n selectionSet,\n execContext.fragmentMatcher,\n JSON.stringify(execContext.variableValues),\n rootValue.id,\n );\n }\n }\n });\n\n this.executeSubSelectedArray = wrap((options: ExecSubSelectedArrayOptions) => {\n return executeSubSelectedArray.call(this, options);\n }, {\n makeCacheKey({ field, array, execContext }) {\n if (execContext.contextValue.store instanceof DepTrackingCache) {\n return cacheKeyRoot.lookup(\n execContext.contextValue.store,\n field,\n array,\n JSON.stringify(execContext.variableValues),\n );\n }\n }\n });\n }\n\n /**\n * Resolves the result of a query solely from the store (i.e. never hits the server).\n *\n * @param {Store} store The {@link NormalizedCache} used by Apollo for the `data` portion of the\n * store.\n *\n * @param {DocumentNode} query The query document to resolve from the data available in the store.\n *\n * @param {Object} [variables] A map from the name of a variable to its value. These variables can\n * be referenced by the query document.\n *\n * @param {any} previousResult The previous result returned by this function for the same query.\n * If nothing in the store changed since that previous result then values from the previous result\n * will be returned to preserve referential equality.\n */\n public readQueryFromStore<QueryType>(\n options: ReadQueryOptions,\n ): QueryType | undefined {\n return this.diffQueryAgainstStore<QueryType>({\n ...options,\n returnPartialData: false,\n }).result;\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 * @param {any} previousResult The previous result returned by this function for the same query\n * @return {result: Object, complete: [boolean]}\n */\n public diffQueryAgainstStore<T>({\n store,\n query,\n variables,\n previousResult,\n returnPartialData = true,\n rootId = 'ROOT_QUERY',\n fragmentMatcherFunction,\n config,\n }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> {\n // Throw the right validation error by trying to find a query in the document\n const queryDefinition = getQueryDefinition(query);\n\n variables = assign({}, getDefaultValues(queryDefinition), variables);\n\n const context: ReadStoreContext = {\n // Global settings\n store,\n dataIdFromObject: config && config.dataIdFromObject,\n cacheRedirects: (config && config.cacheRedirects) || {},\n };\n\n const execResult = this.executeStoreQuery({\n query,\n rootValue: {\n type: 'id',\n id: rootId,\n generated: true,\n typename: 'Query',\n },\n contextValue: context,\n variableValues: variables,\n fragmentMatcher: fragmentMatcherFunction,\n });\n\n const hasMissingFields =\n execResult.missing && execResult.missing.length > 0;\n\n if (hasMissingFields && ! returnPartialData) {\n execResult.missing!.forEach(info => {\n if (info.tolerable) return;\n throw new InvariantError(\n `Can't find field ${info.fieldName} on object ${JSON.stringify(\n info.object,\n null,\n 2,\n )}.`,\n );\n });\n }\n\n if (previousResult) {\n if (isEqual(previousResult, execResult.result)) {\n execResult.result = previousResult;\n }\n }\n\n return {\n result: execResult.result,\n complete: !hasMissingFields,\n };\n }\n\n /**\n * Based on graphql function from graphql-js:\n *\n * graphql(\n * schema: GraphQLSchema,\n * requestString: string,\n * rootValue?: ?any,\n * contextValue?: ?any,\n * variableValues?: ?{[key: string]: any},\n * operationName?: ?string\n * ): Promise<GraphQLResult>\n *\n * The default export as of graphql-anywhere is sync as of 4.0,\n * but below is an exported alternative that is async.\n * In the 5.0 version, this will be the only export again\n * and it will be async\n *\n */\n private executeStoreQuery({\n query,\n rootValue,\n contextValue,\n variableValues,\n // Default matcher always matches all fragments\n fragmentMatcher = defaultFragmentMatcher,\n }: ExecStoreQueryOptions): ExecResult {\n const mainDefinition = getMainDefinition(query);\n const fragments = getFragmentDefinitions(query);\n const fragmentMap = createFragmentMap(fragments);\n const execContext: ExecContext = {\n query,\n fragmentMap,\n contextValue,\n variableValues,\n fragmentMatcher,\n };\n\n return this.executeSelectionSet({\n selectionSet: mainDefinition.selectionSet,\n rootValue,\n execContext,\n });\n }\n\n private executeSelectionSet({\n selectionSet,\n rootValue,\n execContext,\n }: ExecSelectionSetOptions): ExecResult {\n const { fragmentMap, contextValue, variableValues: variables } = execContext;\n const finalResult: ExecResult = { result: null };\n\n const objectsToMerge: { [key: string]: any }[] = [];\n\n const object: StoreObject = contextValue.store.get(rootValue.id);\n\n const typename =\n (object && object.__typename) ||\n (rootValue.id === 'ROOT_QUERY' && 'Query') ||\n void 0;\n\n function handleMissing<T>(result: ExecResult<T>): T {\n if (result.missing) {\n finalResult.missing = finalResult.missing || [];\n finalResult.missing.push(...result.missing);\n }\n return result.result;\n }\n\n selectionSet.selections.forEach(selection => {\n if (!shouldInclude(selection, variables)) {\n // Skip this entirely\n return;\n }\n\n if (isField(selection)) {\n const fieldResult = handleMissing(\n this.executeField(object, typename, selection, execContext),\n );\n\n if (typeof fieldResult !== 'undefined') {\n objectsToMerge.push({\n [resultKeyNameFromField(selection)]: fieldResult,\n });\n }\n\n } else {\n let fragment: InlineFragmentNode | FragmentDefinitionNode;\n\n if (isInlineFragment(selection)) {\n fragment = selection;\n } else {\n // This is a named fragment\n fragment = fragmentMap[selection.name.value];\n\n if (!fragment) {\n throw new InvariantError(`No fragment named ${selection.name.value}`);\n }\n }\n\n const typeCondition =\n fragment.typeCondition && fragment.typeCondition.name.value;\n\n const match =\n !typeCondition ||\n execContext.fragmentMatcher(rootValue, typeCondition, contextValue);\n\n if (match) {\n let fragmentExecResult = this.executeSelectionSet({\n selectionSet: fragment.selectionSet,\n rootValue,\n execContext,\n });\n\n if (match === 'heuristic' && fragmentExecResult.missing) {\n fragmentExecResult = {\n ...fragmentExecResult,\n missing: fragmentExecResult.missing.map(info => {\n return { ...info, tolerable: true };\n }),\n };\n }\n\n objectsToMerge.push(handleMissing(fragmentExecResult));\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 finalResult.result = mergeDeepArray(objectsToMerge);\n\n if (this.freezeResults && process.env.NODE_ENV !== 'production') {\n Object.freeze(finalResult.result);\n }\n\n return finalResult;\n }\n\n private executeField(\n object: StoreObject,\n typename: string | void,\n field: FieldNode,\n execContext: ExecContext,\n ): ExecResult {\n const { variableValues: variables, contextValue } = execContext;\n const fieldName = field.name.value;\n const args = argumentsObjectFromField(field, variables);\n\n const info: ExecInfo = {\n resultKey: resultKeyNameFromField(field),\n directives: getDirectiveInfoFromField(field, variables),\n };\n\n const readStoreResult = readStoreResolver(\n object,\n typename,\n fieldName,\n args,\n contextValue,\n info,\n );\n\n if (Array.isArray(readStoreResult.result)) {\n return this.combineExecResults(\n readStoreResult,\n this.executeSubSelectedArray({\n field,\n array: readStoreResult.result,\n execContext,\n }),\n );\n }\n\n // Handle all scalar types here\n if (!field.selectionSet) {\n assertSelectionSetForIdValue(field, readStoreResult.result);\n if (this.freezeResults && process.env.NODE_ENV !== 'production') {\n maybeDeepFreeze(readStoreResult);\n }\n return readStoreResult;\n }\n\n // From here down, the field has a selection set, which means it's trying to\n // query a GraphQLObjectType\n if (readStoreResult.result == null) {\n // Basically any field in a GraphQL response can be null, or missing\n return readStoreResult;\n }\n\n // Returned value is an object, and the query has a sub-selection. Recurse.\n return this.combineExecResults(\n readStoreResult,\n this.executeSelectionSet({\n selectionSet: field.selectionSet,\n rootValue: readStoreResult.result,\n execContext,\n }),\n );\n }\n\n private combineExecResults<T>(\n ...execResults: ExecResult<T>[]\n ): ExecResult<T> {\n let missing: ExecResultMissingField[] | undefined;\n execResults.forEach(execResult => {\n if (execResult.missing) {\n missing = missing || [];\n missing.push(...execResult.missing);\n }\n });\n return {\n result: execResults.pop()!.result,\n missing,\n };\n }\n\n private executeSubSelectedArray({\n field,\n array,\n execContext,\n }: ExecSubSelectedArrayOptions): ExecResult {\n let missing: ExecResultMissingField[] | undefined;\n\n function handleMissing<T>(childResult: ExecResult<T>): T {\n if (childResult.missing) {\n missing = missing || [];\n missing.push(...childResult.missing);\n }\n\n return childResult.result;\n }\n\n array = array.map(item => {\n // null value in array\n if (item === null) {\n return null;\n }\n\n // This is a nested array, recurse\n if (Array.isArray(item)) {\n return handleMissing(this.executeSubSelectedArray({\n field,\n array: item,\n execContext,\n }));\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 rootValue: item,\n execContext,\n }));\n }\n\n assertSelectionSetForIdValue(field, item);\n\n return item;\n });\n\n if (this.freezeResults && process.env.NODE_ENV !== 'production') {\n Object.freeze(array);\n }\n\n return { result: array, missing };\n }\n}\n\nfunction assertSelectionSetForIdValue(\n field: FieldNode,\n value: any,\n) {\n if (!field.selectionSet && isIdValue(value)) {\n throw new InvariantError(\n `Missing selection set for object of type ${\n value.typename\n } returned for query field ${field.name.value}`\n );\n }\n}\n\nfunction defaultFragmentMatcher() {\n return true;\n}\n\nexport function assertIdValue(idValue: IdValue) {\n invariant(isIdValue(idValue), `\\\nEncountered a sub-selection on the query, but the store doesn't have \\\nan object reference. This should never happen during normal use unless you have custom code \\\nthat is directly manipulating the store; please file an issue.`);\n}\n\nfunction readStoreResolver(\n object: StoreObject,\n typename: string | void,\n fieldName: string,\n args: any,\n context: ReadStoreContext,\n { resultKey, directives }: ExecInfo,\n): ExecResult<StoreValue> {\n let storeKeyName = fieldName;\n if (args || directives) {\n // We happen to know here that getStoreKeyName returns its first\n // argument unmodified if there are no args or directives, so we can\n // avoid calling the function at all in that case, as a small but\n // important optimization to this frequently executed code.\n storeKeyName = getStoreKeyName(storeKeyName, args, directives);\n }\n\n let fieldValue: StoreValue | void = void 0;\n\n if (object) {\n fieldValue = object[storeKeyName];\n\n if (\n typeof fieldValue === 'undefined' &&\n context.cacheRedirects &&\n typeof typename === 'string'\n ) {\n // Look for the type in the custom resolver map\n const type = context.cacheRedirects[typename];\n if (type) {\n // Look for the field in the custom resolver map\n const resolver = type[fieldName];\n if (resolver) {\n fieldValue = resolver(object, args, {\n getCacheKey(storeObj: StoreObject) {\n const id = context.dataIdFromObject!(storeObj);\n return id && toIdValue({\n id,\n typename: storeObj.__typename,\n });\n },\n });\n }\n }\n }\n }\n\n if (typeof fieldValue === 'undefined') {\n return {\n result: fieldValue,\n missing: [{\n object,\n fieldName: storeKeyName,\n tolerable: false,\n }],\n };\n }\n\n if (isJsonValue(fieldValue)) {\n fieldValue = fieldValue.json;\n }\n\n return {\n result: fieldValue,\n };\n}\n","import { NormalizedCache, NormalizedCacheObject, StoreObject } from './types';\n\nexport class ObjectCache implements NormalizedCache {\n constructor(protected data: NormalizedCacheObject = Object.create(null)) {}\n\n public toObject() {\n return this.data;\n }\n\n public get(dataId: string) {\n return this.data[dataId]!;\n }\n\n public set(dataId: string, value: StoreObject) {\n this.data[dataId] = value;\n }\n\n public delete(dataId: string) {\n this.data[dataId] = void 0;\n }\n\n public clear() {\n this.data = Object.create(null);\n }\n\n public replace(newData: NormalizedCacheObject) {\n this.data = newData || Object.create(null);\n }\n}\n\nexport function defaultNormalizedCacheFactory(\n seed?: NormalizedCacheObject,\n): NormalizedCache {\n return new ObjectCache(seed);\n}\n","import {\n SelectionSetNode,\n FieldNode,\n DocumentNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n} from 'graphql';\nimport { FragmentMatcher } from './readFromStore';\n\nimport {\n assign,\n createFragmentMap,\n FragmentMap,\n getDefaultValues,\n getFragmentDefinitions,\n getOperationDefinition,\n IdValue,\n isField,\n isIdValue,\n isInlineFragment,\n isProduction,\n resultKeyNameFromField,\n shouldInclude,\n storeKeyNameFromField,\n StoreValue,\n toIdValue,\n isEqual,\n} from 'apollo-utilities';\n\nimport { invariant } from 'ts-invariant';\n\nimport { ObjectCache } from './objectCache';\nimport { defaultNormalizedCacheFactory } from './depTrackingCache';\n\nimport {\n IdGetter,\n NormalizedCache,\n ReadStoreContext,\n StoreObject,\n} from './types';\n\nexport class WriteError extends Error {\n public type = 'WriteError';\n}\n\nexport function enhanceErrorWithDocument(error: Error, document: DocumentNode) {\n // XXX A bit hacky maybe ...\n const enhancedError = new WriteError(\n `Error writing result to store for query:\\n ${JSON.stringify(document)}`,\n );\n enhancedError.message += '\\n' + error.message;\n enhancedError.stack = error.stack;\n return enhancedError;\n}\n\nexport type WriteContext = {\n readonly store: NormalizedCache;\n readonly processedData?: { [x: string]: FieldNode[] };\n readonly variables?: any;\n readonly dataIdFromObject?: IdGetter;\n readonly fragmentMap?: FragmentMap;\n readonly fragmentMatcherFunction?: FragmentMatcher;\n};\n\nexport class StoreWriter {\n /**\n * Writes the result of a query to the store.\n *\n * @param result The result object returned for the query document.\n *\n * @param query The query document whose result we are writing to the store.\n *\n * @param store The {@link NormalizedCache} used by Apollo for the `data` portion of the store.\n *\n * @param variables A map from the name of a variable to its value. These variables can be\n * referenced by the query document.\n *\n * @param dataIdFromObject A function that returns an object identifier given a particular result\n * object. See the store documentation for details and an example of this function.\n *\n * @param fragmentMatcherFunction A function to use for matching fragment conditions in GraphQL documents\n */\n public writeQueryToStore({\n query,\n result,\n store = defaultNormalizedCacheFactory(),\n variables,\n dataIdFromObject,\n fragmentMatcherFunction,\n }: {\n query: DocumentNode;\n result: Object;\n store?: NormalizedCache;\n variables?: Object;\n dataIdFromObject?: IdGetter;\n fragmentMatcherFunction?: FragmentMatcher;\n }): NormalizedCache {\n return this.writeResultToStore({\n dataId: 'ROOT_QUERY',\n result,\n document: query,\n store,\n variables,\n dataIdFromObject,\n fragmentMatcherFunction,\n });\n }\n\n public writeResultToStore({\n dataId,\n result,\n document,\n store = defaultNormalizedCacheFactory(),\n variables,\n dataIdFromObject,\n fragmentMatcherFunction,\n }: {\n dataId: string;\n result: any;\n document: DocumentNode;\n store?: NormalizedCache;\n variables?: Object;\n dataIdFromObject?: IdGetter;\n fragmentMatcherFunction?: FragmentMatcher;\n }): NormalizedCache {\n // XXX TODO REFACTOR: this is a temporary workaround until query normalization is made to work with documents.\n const operationDefinition = getOperationDefinition(document)!;\n\n try {\n return this.writeSelectionSetToStore({\n result,\n dataId,\n selectionSet: operationDefinition.selectionSet,\n context: {\n store,\n processedData: {},\n variables: assign(\n {},\n getDefaultValues(operationDefinition),\n variables,\n ),\n dataIdFromObject,\n fragmentMap: createFragmentMap(getFragmentDefinitions(document)),\n fragmentMatcherFunction,\n },\n });\n } catch (e) {\n throw enhanceErrorWithDocument(e, document);\n }\n }\n\n public writeSelectionSetToStore({\n result,\n dataId,\n selectionSet,\n context,\n }: {\n dataId: string;\n result: any;\n selectionSet: SelectionSetNode;\n context: WriteContext;\n }): NormalizedCache {\n const { variables, store, fragmentMap } = context;\n\n selectionSet.selections.forEach(selection => {\n if (!shouldInclude(selection, variables)) {\n return;\n }\n\n if (isField(selection)) {\n const resultFieldKey: string = resultKeyNameFromField(selection);\n const value: any = result[resultFieldKey];\n\n if (typeof value !== 'undefined') {\n this.writeFieldToStore({\n dataId,\n value,\n field: selection,\n context,\n });\n } else {\n let isDefered = false;\n let isClient = false;\n if (selection.directives && selection.directives.length) {\n // If this is a defered field we don't need to throw / warn.\n isDefered = selection.directives.some(\n directive => directive.name && directive.name.value === 'defer',\n );\n\n // When using the @client directive, it might be desirable in\n // some cases to want to write a selection set to the store,\n // without having all of the selection set values available.\n // This is because the @client field values might have already\n // been written to the cache separately (e.g. via Apollo\n // Cache's `writeData` capabilities). Because of this, we'll\n // skip the missing field warning for fields with @client\n // directives.\n isClient = selection.directives.some(\n directive => directive.name && directive.name.value === 'client',\n );\n }\n\n if (!isDefered && !isClient && context.fragmentMatcherFunction) {\n // XXX We'd like to throw an error, but for backwards compatibility's sake\n // we just print a warning for the time being.\n //throw new WriteError(`Missing field ${resultFieldKey} in ${JSON.stringify(result, null, 2).substring(0, 100)}`);\n invariant.warn(\n `Missing field ${resultFieldKey} in ${JSON.stringify(\n result,\n null,\n 2,\n ).substring(0, 100)}`,\n );\n }\n }\n } else {\n // This is not a field, so it must be a fragment, either inline or named\n let fragment: InlineFragmentNode | FragmentDefinitionNode;\n\n if (isInlineFragment(selection)) {\n fragment = selection;\n } else {\n // Named fragment\n fragment = (fragmentMap || {})[selection.name.value];\n invariant(fragment, `No fragment named ${selection.name.value}.`);\n }\n\n let matches = true;\n if (context.fragmentMatcherFunction && fragment.typeCondition) {\n // TODO we need to rewrite the fragment matchers for this to work properly and efficiently\n // Right now we have to pretend that we're passing in an idValue and that there's a store\n // on the context.\n const id = dataId || 'self';\n const idValue = toIdValue({ id, typename: undefined });\n const fakeContext: ReadStoreContext = {\n // NOTE: fakeContext always uses ObjectCache\n // since this is only to ensure the return value of 'matches'\n store: new ObjectCache({ [id]: result }),\n cacheRedirects: {},\n };\n const match = context.fragmentMatcherFunction(\n idValue,\n fragment.typeCondition.name.value,\n fakeContext,\n );\n if (!isProduction() && match === 'heuristic') {\n invariant.error('WARNING: heuristic fragment matching going on!');\n }\n matches = !!match;\n }\n\n if (matches) {\n this.writeSelectionSetToStore({\n result,\n selectionSet: fragment.selectionSet,\n dataId,\n context,\n });\n }\n }\n });\n\n return store;\n }\n\n private writeFieldToStore({\n field,\n value,\n dataId,\n context,\n }: {\n field: FieldNode;\n value: any;\n dataId: string;\n context: WriteContext;\n }) {\n const { variables, dataIdFromObject, store } = context;\n\n let storeValue: StoreValue;\n let storeObject: StoreObject;\n\n const storeFieldName: string = storeKeyNameFromField(field, variables);\n\n // If this is a scalar value...\n if (!field.selectionSet || value === null) {\n storeValue =\n value != null && typeof value === 'object'\n ? // If the scalar value is a JSON blob, we have to \"escape\" it so it can’t pretend to be\n // an id.\n { type: 'json', json: value }\n : // Otherwise, just store the scalar directly in the store.\n value;\n } else if (Array.isArray(value)) {\n const generatedId = `${dataId}.${storeFieldName}`;\n\n storeValue = this.processArrayValue(\n value,\n generatedId,\n field.selectionSet,\n context,\n );\n } else {\n // It's an object\n let valueDataId = `${dataId}.${storeFieldName}`;\n let generated = true;\n\n // We only prepend the '$' if the valueDataId isn't already a generated\n // id.\n if (!isGeneratedId(valueDataId)) {\n valueDataId = '$' + valueDataId;\n }\n\n if (dataIdFromObject) {\n const semanticId = dataIdFromObject(value);\n\n // We throw an error if the first character of the id is '$. This is\n // because we use that character to designate an Apollo-generated id\n // and we use the distinction between user-desiginated and application-provided\n // ids when managing overwrites.\n invariant(\n !semanticId || !isGeneratedId(semanticId),\n 'IDs returned by dataIdFromObject cannot begin with the \"$\" character.',\n );\n\n if (\n semanticId ||\n (typeof semanticId === 'number' && semanticId === 0)\n ) {\n valueDataId = semanticId;\n generated = false;\n }\n }\n\n if (!isDataProcessed(valueDataId, field, context.processedData)) {\n this.writeSelectionSetToStore({\n dataId: valueDataId,\n result: value,\n selectionSet: field.selectionSet,\n context,\n });\n }\n\n // We take the id and escape it (i.e. wrap it with an enclosing object).\n // This allows us to distinguish IDs from normal scalars.\n const typename = value.__typename;\n storeValue = toIdValue({ id: valueDataId, typename }, generated);\n\n // check if there was a generated id at the location where we're\n // about to place this new id. If there was, we have to merge the\n // data from that id with the data we're about to write in the store.\n storeObject = store.get(dataId);\n const escapedId =\n storeObject && (storeObject[storeFieldName] as IdValue | undefined);\n if (escapedId !== storeValue && isIdValue(escapedId)) {\n const hadTypename = escapedId.typename !== undefined;\n const hasTypename = typename !== undefined;\n const typenameChanged =\n hadTypename && hasTypename && escapedId.typename !== typename;\n\n // If there is already a real id in the store and the current id we\n // are dealing with is generated, we throw an error.\n // One exception we allow is when the typename has changed, which occurs\n // when schema defines a union, both with and without an ID in the same place.\n // checks if we \"lost\" the read id\n invariant(\n !generated || escapedId.generated || typenameChanged,\n `Store error: the application attempted to write an object with no provided id but the store already contains an id of ${\n escapedId.id\n } for this object. The selectionSet that was trying to be written is:\\n${\n JSON.stringify(field)\n }`,\n );\n\n // checks if we \"lost\" the typename\n invariant(\n !hadTypename || hasTypename,\n `Store error: the application attempted to write an object with no provided typename but the store already contains an object with typename of ${\n escapedId.typename\n } for the object of id ${escapedId.id}. The selectionSet that was trying to be written is:\\n${\n JSON.stringify(field)\n }`,\n );\n\n if (escapedId.generated) {\n // We should only merge if it's an object of the same type,\n // otherwise we should delete the generated object\n if (typenameChanged) {\n // Only delete the generated object when the old object was\n // inlined, and the new object is not. This is indicated by\n // the old id being generated, and the new id being real.\n if (!generated) {\n store.delete(escapedId.id);\n }\n } else {\n mergeWithGenerated(escapedId.id, (storeValue as IdValue).id, store);\n }\n }\n }\n }\n\n storeObject = store.get(dataId);\n if (!storeObject || !isEqual(storeValue, storeObject[storeFieldName])) {\n store.set(dataId, {\n ...storeObject,\n [storeFieldName]: storeValue,\n });\n }\n }\n\n private processArrayValue(\n value: any[],\n generatedId: string,\n selectionSet: SelectionSetNode,\n context: WriteContext,\n ): any[] {\n return value.map((item: any, index: any) => {\n if (item === null) {\n return null;\n }\n\n let itemDataId = `${generatedId}.${index}`;\n\n if (Array.isArray(item)) {\n return this.processArrayValue(item, itemDataId, selectionSet, context);\n }\n\n let generated = true;\n\n if (context.dataIdFromObject) {\n const semanticId = context.dataIdFromObject(item);\n\n if (semanticId) {\n itemDataId = semanticId;\n generated = false;\n }\n }\n\n if (!isDataProcessed(itemDataId, selectionSet, context.processedData)) {\n this.writeSelectionSetToStore({\n dataId: itemDataId,\n result: item,\n selectionSet,\n context,\n });\n }\n\n return toIdValue(\n { id: itemDataId, typename: item.__typename },\n generated,\n );\n });\n }\n}\n\n// Checks if the id given is an id that was generated by Apollo\n// rather than by dataIdFromObject.\nfunction isGeneratedId(id: string): boolean {\n return id[0] === '$';\n}\n\nfunction mergeWithGenerated(\n generatedKey: string,\n realKey: string,\n cache: NormalizedCache,\n): boolean {\n if (generatedKey === realKey) {\n return false;\n }\n\n const generated = cache.get(generatedKey);\n const real = cache.get(realKey);\n let madeChanges = false;\n\n Object.keys(generated).forEach(key => {\n const value = generated[key];\n const realValue = real[key];\n\n if (\n isIdValue(value) &&\n isGeneratedId(value.id) &&\n isIdValue(realValue) &&\n !isEqual(value, realValue) &&\n mergeWithGenerated(value.id, realValue.id, cache)\n ) {\n madeChanges = true;\n }\n });\n\n cache.delete(generatedKey);\n const newRealValue = { ...generated, ...real };\n\n if (isEqual(newRealValue, real)) {\n return madeChanges;\n }\n\n cache.set(realKey, newRealValue);\n return true;\n}\n\nfunction isDataProcessed(\n dataId: string,\n field: FieldNode | SelectionSetNode,\n processedData?: { [x: string]: (FieldNode | SelectionSetNode)[] },\n): boolean {\n if (!processedData) {\n return false;\n }\n\n if (processedData[dataId]) {\n if (processedData[dataId].indexOf(field) >= 0) {\n return true;\n } else {\n processedData[dataId].push(field);\n }\n } else {\n processedData[dataId] = [field];\n }\n\n return false;\n}\n","// Make builtins like Map and Set safe to use with non-extensible objects.\nimport './fixPolyfills';\n\nimport { DocumentNode } from 'graphql';\n\nimport { Cache, ApolloCache, Transaction } from 'apollo-cache';\n\nimport { addTypenameToDocument, canUseWeakMap } from 'apollo-utilities';\n\nimport { wrap } from 'optimism';\n\nimport { invariant, InvariantError } from 'ts-invariant';\n\nimport { HeuristicFragmentMatcher } from './fragmentMatcher';\nimport {\n ApolloReducerConfig,\n NormalizedCache,\n NormalizedCacheObject,\n} from './types';\n\nimport { StoreReader } from './readFromStore';\nimport { StoreWriter } from './writeToStore';\nimport { DepTrackingCache } from './depTrackingCache';\nimport { KeyTrie } from 'optimism';\nimport { ObjectCache } from './objectCache';\n\nexport interface InMemoryCacheConfig extends ApolloReducerConfig {\n resultCaching?: boolean;\n freezeResults?: boolean;\n}\n\nconst defaultConfig: InMemoryCacheConfig = {\n fragmentMatcher: new HeuristicFragmentMatcher(),\n dataIdFromObject: defaultDataIdFromObject,\n addTypename: true,\n resultCaching: true,\n freezeResults: false,\n};\n\nexport function defaultDataIdFromObject(result: any): string | null {\n if (result.__typename) {\n if (result.id !== undefined) {\n return `${result.__typename}:${result.id}`;\n }\n if (result._id !== undefined) {\n return `${result.__typename}:${result._id}`;\n }\n }\n return null;\n}\n\nconst hasOwn = Object.prototype.hasOwnProperty;\n\nexport class OptimisticCacheLayer extends ObjectCache {\n constructor(\n public readonly optimisticId: string,\n // OptimisticCacheLayer objects always wrap some other parent cache, so\n // this.parent should never be null.\n public readonly parent: NormalizedCache,\n public readonly transaction: Transaction<NormalizedCacheObject>,\n ) {\n super(Object.create(null));\n }\n\n public toObject(): NormalizedCacheObject {\n return {\n ...this.parent.toObject(),\n ...this.data,\n };\n }\n\n // All the other accessor methods of ObjectCache work without knowing about\n // this.parent, but the get method needs to be overridden to implement the\n // fallback this.parent.get(dataId) behavior.\n public get(dataId: string) {\n return hasOwn.call(this.data, dataId)\n ? this.data[dataId]\n : this.parent.get(dataId);\n }\n}\n\nexport class InMemoryCache extends ApolloCache<NormalizedCacheObject> {\n private data: NormalizedCache;\n private optimisticData: NormalizedCache;\n\n protected config: InMemoryCacheConfig;\n private watches = new Set<Cache.WatchOptions>();\n private addTypename: boolean;\n private typenameDocumentCache = new Map<DocumentNode, DocumentNode>();\n private storeReader: StoreReader;\n private storeWriter: StoreWriter;\n private cacheKeyRoot = new KeyTrie<object>(canUseWeakMap);\n\n // Set this while in a transaction to prevent broadcasts...\n // don't forget to turn it back on!\n private silenceBroadcast: boolean = false;\n\n constructor(config: InMemoryCacheConfig = {}) {\n super();\n this.config = { ...defaultConfig, ...config };\n\n // backwards compat\n if ((this.config as any).customResolvers) {\n invariant.warn(\n 'customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version.',\n );\n this.config.cacheRedirects = (this.config as any).customResolvers;\n }\n\n if ((this.config as any).cacheResolvers) {\n invariant.warn(\n 'cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version.',\n );\n this.config.cacheRedirects = (this.config as any).cacheResolvers;\n }\n\n this.addTypename = !!this.config.addTypename;\n\n // Passing { resultCaching: false } in the InMemoryCache constructor options\n // will completely disable dependency tracking, which will improve memory\n // usage but worsen the performance of repeated reads.\n this.data = this.config.resultCaching\n ? new DepTrackingCache()\n : new ObjectCache();\n\n // When no optimistic writes are currently active, cache.optimisticData ===\n // cache.data, so there are no additional layers on top of the actual data.\n // When an optimistic update happens, this.optimisticData will become a\n // linked list of OptimisticCacheLayer objects that terminates with the\n // original this.data cache object.\n this.optimisticData = this.data;\n\n this.storeWriter = new StoreWriter();\n this.storeReader = new StoreReader({\n cacheKeyRoot: this.cacheKeyRoot,\n freezeResults: config.freezeResults,\n });\n\n const cache = this;\n const { maybeBroadcastWatch } = cache;\n this.maybeBroadcastWatch = wrap((c: Cache.WatchOptions) => {\n return maybeBroadcastWatch.call(this, c);\n }, {\n makeCacheKey(c: Cache.WatchOptions) {\n if (c.optimistic) {\n // If we're reading optimistic data, it doesn't matter if this.data\n // is a DepTrackingCache, since it will be ignored.\n return;\n }\n\n if (c.previousResult) {\n // If a previousResult was provided, assume the caller would prefer\n // to compare the previous data to the new data to determine whether\n // to broadcast, so we should disable caching by returning here, to\n // give maybeBroadcastWatch a chance to do that comparison.\n return;\n }\n\n if (cache.data instanceof DepTrackingCache) {\n // Return a cache key (thus enabling caching) only if we're currently\n // using a data store that can track cache dependencies.\n return cache.cacheKeyRoot.lookup(\n c.query,\n JSON.stringify(c.variables),\n );\n }\n }\n });\n }\n\n public restore(data: NormalizedCacheObject): this {\n if (data) this.data.replace(data);\n return this;\n }\n\n public extract(optimistic: boolean = false): NormalizedCacheObject {\n return (optimistic ? this.optimisticData : this.data).toObject();\n }\n\n public read<T>(options: Cache.ReadOptions): T | null {\n if (typeof options.rootId === 'string' &&\n typeof this.data.get(options.rootId) === 'undefined') {\n return null;\n }\n\n const { fragmentMatcher } = this.config;\n const fragmentMatcherFunction = fragmentMatcher && fragmentMatcher.match;\n\n return this.storeReader.readQueryFromStore({\n store: options.optimistic ? this.optimisticData : this.data,\n query: this.transformDocument(options.query),\n variables: options.variables,\n rootId: options.rootId,\n fragmentMatcherFunction,\n previousResult: options.previousResult,\n config: this.config,\n }) || null;\n }\n\n public write(write: Cache.WriteOptions): void {\n const { fragmentMatcher } = this.config;\n const fragmentMatcherFunction = fragmentMatcher && fragmentMatcher.match;\n\n this.storeWriter.writeResultToStore({\n dataId: write.dataId,\n result: write.result,\n variables: write.variables,\n document: this.transformDocument(write.query),\n store: this.data,\n dataIdFromObject: this.config.dataIdFromObject,\n fragmentMatcherFunction,\n });\n\n this.broadcastWatches();\n }\n\n public diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T> {\n const { fragmentMatcher } = this.config;\n const fragmentMatcherFunction = fragmentMatcher && fragmentMatcher.match;\n\n return this.storeReader.diffQueryAgainstStore({\n store: query.optimistic ? this.optimisticData : this.data,\n query: this.transformDocument(query.query),\n variables: query.variables,\n returnPartialData: query.returnPartialData,\n previousResult: query.previousResult,\n fragmentMatcherFunction,\n config: this.config,\n });\n }\n\n public watch(watch: Cache.WatchOptions): () => void {\n this.watches.add(watch);\n\n return () => {\n this.watches.delete(watch);\n };\n }\n\n public evict(query: Cache.EvictOptions): Cache.EvictionResult {\n throw new InvariantError(`eviction is not implemented on InMemory Cache`);\n }\n\n public reset(): Promise<void> {\n this.data.clear();\n this.broadcastWatches();\n\n return Promise.resolve();\n }\n\n public removeOptimistic(idToRemove: string) {\n const toReapply: OptimisticCacheLayer[] = [];\n let removedCount = 0;\n let layer = this.optimisticData;\n\n while (layer instanceof OptimisticCacheLayer) {\n if (layer.optimisticId === idToRemove) {\n ++removedCount;\n } else {\n toReapply.push(layer);\n }\n layer = layer.parent;\n }\n\n if (removedCount > 0) {\n // Reset this.optimisticData to the first non-OptimisticCacheLayer object,\n // which is almost certainly this.data.\n this.optimisticData = layer;\n\n // Reapply the layers whose optimistic IDs do not match the removed ID.\n while (toReapply.length > 0) {\n const layer = toReapply.pop()!;\n this.performTransaction(layer.transaction, layer.optimisticId);\n }\n\n this.broadcastWatches();\n }\n }\n\n public performTransaction(\n transaction: Transaction<NormalizedCacheObject>,\n // This parameter is not part of the performTransaction signature inherited\n // from the ApolloCache abstract class, but it's useful because it saves us\n // from duplicating this implementation in recordOptimisticTransaction.\n optimisticId?: string,\n ) {\n const { data, silenceBroadcast } = this;\n this.silenceBroadcast = true;\n\n if (typeof optimisticId === 'string') {\n // Add a new optimistic layer and temporarily make this.data refer to\n // that layer for the duration of the transaction.\n this.data = this.optimisticData = new OptimisticCacheLayer(\n // Note that there can be multiple layers with the same optimisticId.\n // When removeOptimistic(id) is called for that id, all matching layers\n // will be removed, and the remaining layers will be reapplied.\n optimisticId,\n this.optimisticData,\n transaction,\n );\n }\n\n try {\n transaction(this);\n } finally {\n this.silenceBroadcast = silenceBroadcast;\n this.data = data;\n }\n\n // This broadcast does nothing if this.silenceBroadcast is true.\n this.broadcastWatches();\n }\n\n public recordOptimisticTransaction(\n transaction: Transaction<NormalizedCacheObject>,\n id: string,\n ) {\n return this.performTransaction(transaction, id);\n }\n\n public transformDocument(document: DocumentNode): DocumentNode {\n if (this.addTypename) {\n let result = this.typenameDocumentCache.get(document);\n if (!result) {\n result = addTypenameToDocument(document);\n this.typenameDocumentCache.set(document, result);\n // If someone calls transformDocument and then mistakenly passes the\n // result back into an API that also calls transformDocument, make sure\n // we don't keep creating new query documents.\n this.typenameDocumentCache.set(result, result);\n }\n return result;\n }\n return document;\n }\n\n protected broadcastWatches() {\n if (!this.silenceBroadcast) {\n this.watches.forEach(c => this.maybeBroadcastWatch(c));\n }\n }\n\n // This method is wrapped in the constructor so that it will be called only\n // if the data that would be broadcast has changed.\n private maybeBroadcastWatch(c: Cache.WatchOptions) {\n c.callback(\n this.diff({\n query: c.query,\n variables: c.variables,\n previousResult: c.previousResult && c.previousResult(),\n optimistic: c.optimistic,\n }),\n );\n }\n}\n"],"names":["defaultNormalizedCacheFactory","hasOwn"],"mappings":";;;;;;AAUA,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,SAAS,UAAU;IACjB,IAAM,MAAM,GAAG,CAAC,UAAU,CAAC;IAE3B,IAAI,CAAC,MAAM,EAAE,EAAE;QACb,UAAU,GAAG,IAAI,CAAC;KACnB;IACD,OAAO,MAAM,CAAC;CACf;AAKD;IACE;KAEC;IAEM,8CAAW,GAAlB;QACE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;KAC1B;IAEM,gDAAa,GAApB;QACE,OAAO,IAAI,CAAC;KACb;IAEM,wCAAK,GAAZ,UACE,OAAgB,EAChB,aAAqB,EACrB,OAAyB;QAEzB,IAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC1C,IAAM,WAAW,GAAG,OAAO,CAAC,EAAE,KAAK,YAAY,CAAC;QAEhD,IAAI,CAAC,GAAG,EAAE;YAER,OAAO,WAAW,CAAC;SACpB;QAEO,IAAA,mBAAmC,EAAnC,wDAAmC,CAAS;QAEpD,IAAI,CAAC,UAAU,EAAE;YACf,IAAI,UAAU,EAAE,EAAE;gBAChB;gBAIA,uDAC0C;gBAI1C;oBAEI,+GAA+G,CAClH,CAAC;aACH;YAED,OAAO,WAAW,CAAC;SACpB;QAED,IAAI,UAAU,KAAK,aAAa,EAAE;YAChC,OAAO,IAAI,CAAC;SACb;QAgBD,IAAI,UAAU,EAAE,EAAE;YAChB;gBAEI,sEAAsE;gBACtE,oEAAoE;gBACpE,+DAA+D;gBAC/D,mFAAmF,CACtF,CAAC;SACH;QAED,OAAO,WAAW,CAAC;KACpB;IACH,+BAAC;CAAA,IAAA;;IAMC,sCAAY,OAEX;QACC,IAAI,OAAO,IAAI,OAAO,CAAC,4BAA4B,EAAE;Y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