@graphitation/supermassive 3.15.1 → 3.15.2

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/executeWithoutSchema.ts"],
4
- "sourcesContent": ["import {\n GraphQLError,\n GraphQLLeafType,\n Kind,\n locatedError,\n DocumentNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n OperationTypeDefinitionNode,\n} from \"graphql\";\nimport {\n collectFields,\n collectSubfields as _collectSubfields,\n FieldGroup,\n GroupedFieldSet,\n} from \"./collectFields\";\nimport { devAssert } from \"./jsutils/devAssert\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { invariant } from \"./jsutils/invariant\";\nimport { isIterableObject } from \"./jsutils/isIterableObject\";\nimport { isObjectLike } from \"./jsutils/isObjectLike\";\nimport { isPromise } from \"./jsutils/isPromise\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport type { Path } from \"./jsutils/Path\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport { promiseForObject } from \"./jsutils/promiseForObject\";\nimport type { PromiseOrValue } from \"./jsutils/PromiseOrValue\";\nimport { promiseReduce } from \"./jsutils/promiseReduce\";\nimport type {\n ExecutionWithoutSchemaArgs,\n FunctionFieldResolver,\n ResolveInfo,\n TypeResolver,\n ExecutionResult,\n TotalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalResult,\n IncrementalStreamResult,\n IncrementalExecutionResult,\n SchemaFragment,\n SchemaFragmentLoader,\n SchemaFragmentRequest,\n} from \"./types\";\nimport {\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n} from \"./values\";\nimport type { ExecutionHooks } from \"./hooks/types\";\nimport { arraysAreEqual } from \"./utilities/array\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\nimport { GraphQLStreamDirective } from \"./schema/directives\";\nimport { memoize3 } from \"./jsutils/memoize3\";\nimport {\n inspectTypeReference,\n isListType,\n isNonNullType,\n typeNameFromReference,\n unwrap,\n} from \"./schema/reference\";\nimport type { TypeReference } from \"./schema/reference\";\nimport type { FieldDefinition } from \"./schema/definition\";\nimport * as Definitions from \"./schema/definition\";\nimport * as Resolvers from \"./schema/resolvers\";\n\n/**\n * A memoized collection of relevant subfields with regard to the return\n * type. Memoizing ensures the subfields are not repeatedly calculated, which\n * saves overhead when resolving lists of values.\n */\nconst collectSubfields = memoize3(\n (\n exeContext: ExecutionContext,\n // HAX??\n returnTypeName: { name: string },\n fieldGroup: FieldGroup,\n ) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup),\n);\n\n/**\n * Terminology\n *\n * \"Definitions\" are the generic name for top-level statements in the document.\n * Examples of this include:\n * 1) Operations (such as a query)\n * 2) Fragments\n *\n * \"Operations\" are a generic name for requests in the document.\n * Examples of this include:\n * 1) query,\n * 2) mutation\n *\n * \"Selections\" are the definitions that can appear legally and at\n * single level of the query. These include:\n * 1) field references e.g \"a\"\n * 2) fragment \"spreads\" e.g. \"...c\"\n * 3) inline fragment \"spreads\" e.g. \"...on Type { a }\"\n */\n\n/**\n * Data that must be available at all points during query execution.\n *\n * Namely, schema of the type system that is currently executing,\n * and the fragments defined in the query document\n */\nexport interface ExecutionContext {\n schemaFragment: SchemaFragment;\n schemaFragmentLoader?: SchemaFragmentLoader;\n fragments: ObjMap<FragmentDefinitionNode>;\n rootValue: unknown;\n contextValue: unknown;\n buildContextValue?: (contextValue?: unknown) => unknown;\n operation: OperationDefinitionNode;\n variableValues: { [variable: string]: unknown };\n fieldResolver: FunctionFieldResolver<unknown, unknown>;\n typeResolver: TypeResolver<unknown, unknown>;\n subscribeFieldResolver: FunctionFieldResolver<unknown, unknown>;\n errors: Array<GraphQLError>;\n fieldExecutionHooks?: ExecutionHooks;\n subsequentPayloads: Set<IncrementalDataRecord>;\n enablePerEventContext: boolean;\n}\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification.\n *\n * Returns either a synchronous ExecutionResult (if all encountered resolvers\n * are synchronous), or a Promise of an ExecutionResult that will eventually be\n * resolved and never rejected.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n */\nexport function executeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): PromiseOrValue<ExecutionResult> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const exeContext = buildExecutionContext(args);\n\n // Return early errors if execution context failed.\n if (!(\"schemaFragment\" in exeContext)) {\n return { errors: exeContext };\n } else {\n return executeOperationWithBeforeHook(exeContext);\n }\n}\n\n/**\n * Essential assertions before executing to provide developer feedback for\n * improper use of the GraphQL library.\n *\n * @internal\n */\nexport function assertValidExecutionArguments(\n document: DocumentNode,\n rawVariableValues: Maybe<{ [variable: string]: unknown }>,\n): void {\n devAssert(document, \"Must provide document.\");\n\n // Variables, if provided, must be an object.\n devAssert(\n rawVariableValues == null || isObjectLike(rawVariableValues),\n \"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.\",\n );\n}\n\n/**\n * Constructs a ExecutionContext object from the arguments passed to\n * execute, which we will pass throughout the other execution methods.\n *\n * Throws a GraphQLError if a valid execution context cannot be created.\n *\n * @internal\n */\nfunction buildExecutionContext(\n args: ExecutionWithoutSchemaArgs,\n): Array<GraphQLError> | ExecutionContext {\n const {\n schemaFragment,\n schemaFragmentLoader,\n document,\n rootValue,\n contextValue,\n buildContextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n subscribeFieldResolver,\n fieldExecutionHooks,\n enablePerEventContext,\n } = args;\n\n assertValidExecutionArguments(document, variableValues);\n\n let operation: OperationDefinitionNode | undefined;\n const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n return [\n locatedError(\n \"Must provide operation name if query contains multiple operations.\",\n [],\n ),\n ];\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n case Kind.FRAGMENT_DEFINITION:\n fragments[definition.name.value] = definition;\n break;\n }\n }\n\n if (!operation) {\n if (operationName != null) {\n return [locatedError(`Unknown operation named \"${operationName}\".`, [])];\n }\n return [locatedError(\"Must provide an operation.\", [])];\n }\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const variableDefinitions = operation.variableDefinitions ?? [];\n\n const coercedVariableValues = getVariableValues(\n schemaFragment,\n variableDefinitions,\n variableValues ?? {},\n { maxErrors: 50 },\n );\n\n if (coercedVariableValues.errors) {\n return coercedVariableValues.errors;\n }\n\n return {\n schemaFragment,\n schemaFragmentLoader,\n fragments,\n rootValue,\n contextValue: buildContextValue\n ? buildContextValue(contextValue)\n : contextValue,\n buildContextValue,\n operation,\n variableValues: coercedVariableValues.coerced,\n fieldResolver: fieldResolver ?? defaultFieldResolver,\n typeResolver: typeResolver ?? defaultTypeResolver,\n subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,\n errors: [],\n fieldExecutionHooks,\n subsequentPayloads: new Set(),\n enablePerEventContext: enablePerEventContext ?? true,\n };\n}\n\nfunction buildPerEventExecutionContext(\n exeContext: ExecutionContext,\n payload: unknown,\n): ExecutionContext {\n return {\n ...exeContext,\n contextValue: exeContext.buildContextValue\n ? exeContext.buildContextValue(exeContext.contextValue)\n : exeContext.contextValue,\n rootValue: payload,\n subsequentPayloads: new Set(),\n errors: [],\n };\n}\n\nfunction executeOperationWithBeforeHook(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult> {\n const hooks = exeContext.fieldExecutionHooks;\n let hookResultPromise;\n if (hooks?.beforeOperationExecute) {\n hookResultPromise = invokeBeforeOperationExecuteHook(exeContext);\n }\n\n if (hookResultPromise instanceof GraphQLError) {\n return buildResponse(exeContext, null);\n }\n\n if (isPromise(hookResultPromise)) {\n return hookResultPromise.then((hookResult) => {\n if (hookResult instanceof GraphQLError) {\n return buildResponse(exeContext, null);\n }\n return executeOperation(exeContext);\n });\n }\n\n return executeOperation(exeContext);\n}\n\nfunction executeOperation(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult> {\n try {\n const { operation, rootValue } = exeContext;\n const rootTypeName = getOperationRootTypeName(operation);\n const { groupedFieldSet, patches } = collectFields(\n exeContext,\n rootTypeName,\n );\n const path = undefined;\n let result;\n\n // Note: cannot use OperationTypeNode from graphql-js as it doesn't exist in 15.x\n switch (operation.operation) {\n case \"query\":\n result = executeFields(\n exeContext,\n rootTypeName,\n rootValue,\n path,\n groupedFieldSet,\n undefined,\n );\n result = buildResponse(exeContext, result);\n break;\n case \"mutation\":\n result = executeFieldsSerially(\n exeContext,\n rootTypeName,\n rootValue,\n path,\n groupedFieldSet,\n );\n result = buildResponse(exeContext, result);\n break;\n case \"subscription\": {\n const resultOrStreamOrPromise = createSourceEventStream(exeContext);\n result = mapResultOrEventStreamOrPromise(\n resultOrStreamOrPromise,\n exeContext,\n rootTypeName,\n path,\n groupedFieldSet,\n );\n break;\n }\n default:\n invariant(\n false,\n `Operation \"${operation.operation}\" is not a part of GraphQL spec`,\n );\n }\n\n for (const patch of patches) {\n const { label, groupedFieldSet: patchGroupedFieldSet } = patch;\n executeDeferredFragment(\n exeContext,\n rootTypeName,\n rootValue,\n patchGroupedFieldSet,\n label,\n path,\n );\n }\n\n return result;\n } catch (error) {\n exeContext.errors.push(error as GraphQLError);\n return buildResponse(exeContext, null);\n }\n}\n\n/**\n * Given a completed execution context and data, build the { errors, data }\n * response defined by the \"Response\" section of the GraphQL specification.\n */\nfunction buildResponse(\n exeContext: ExecutionContext,\n data: PromiseOrValue<ObjMap<unknown> | null>,\n): PromiseOrValue<ExecutionResult> {\n if (isPromise(data)) {\n return data.then(\n (resolved) => buildResponse(exeContext, resolved),\n (error) => {\n exeContext.errors.push(error);\n return buildResponse(exeContext, null);\n },\n );\n }\n\n const hooks = exeContext.fieldExecutionHooks;\n try {\n const initialResult =\n exeContext.errors.length === 0\n ? { data }\n : { errors: exeContext.errors, data };\n if (exeContext.subsequentPayloads.size > 0) {\n // TODO: define how to call hooks for incremental results\n return {\n initialResult: {\n ...initialResult,\n hasNext: true,\n },\n subsequentResults: yieldSubsequentPayloads(exeContext),\n };\n } else {\n if (hooks?.afterBuildResponse) {\n const hookResult = invokeAfterBuildResponseHook(\n exeContext,\n initialResult,\n );\n if (exeContext.errors.length > (initialResult.errors?.length ?? 0)) {\n initialResult.errors = exeContext.errors;\n }\n if (hookResult instanceof GraphQLError) {\n return { errors: initialResult.errors };\n }\n }\n return initialResult;\n }\n } catch (error) {\n exeContext.errors.push(error as GraphQLError);\n return buildResponse(exeContext, null);\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that must be executed serially.\n */\nfunction executeFieldsSerially(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n): PromiseOrValue<ObjMap<unknown>> {\n return promiseReduce(\n groupedFieldSet,\n (results, [responseName, fieldGroup]) => {\n const fieldPath = addPath(path, responseName, parentTypeName);\n const result = executeField(\n exeContext,\n parentTypeName,\n sourceValue,\n fieldGroup,\n fieldPath,\n undefined,\n );\n if (result === undefined) {\n return results;\n }\n if (isPromise(result)) {\n return result.then((resolvedResult: unknown) => {\n if (resolvedResult === undefined) {\n return results;\n }\n\n results[responseName] = resolvedResult;\n return results;\n });\n }\n results[responseName] = result;\n return results;\n },\n Object.create(null),\n );\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that may be executed in parallel.\n */\nfunction executeFields(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n const results = Object.create(null);\n let containsPromise = false;\n\n try {\n for (const [responseName, fieldGroup] of groupedFieldSet) {\n const fieldPath = addPath(path, responseName, parentTypeName);\n const result = executeField(\n exeContext,\n parentTypeName,\n sourceValue,\n fieldGroup,\n fieldPath,\n incrementalDataRecord,\n );\n\n if (result !== undefined) {\n results[responseName] = result;\n if (isPromise(result)) {\n containsPromise = true;\n }\n }\n }\n } catch (error) {\n if (containsPromise) {\n // Ensure that any promises returned by other fields are handled, as they may also reject.\n return promiseForObject(results).finally(() => {\n throw error;\n });\n }\n throw error;\n }\n\n // If there are no promises, we can just return the object\n if (!containsPromise) {\n return results;\n }\n\n // Otherwise, results is a map from field name to the result of resolving that\n // field, which is possibly a promise. Return a promise that will return this\n // same map, but with any promises replaced with the values they resolved to.\n return promiseForObject(results);\n}\n\n/**\n * Implements the \"Executing field\" section of the spec\n * In particular, this function figures out the value that the field returns by\n * calling its resolve function, then calls completeValue to complete promises,\n * serialize scalars, or execute the sub-selection-set for objects.\n */\nfunction executeField(\n exeContext: ExecutionContext,\n parentTypeName: string,\n source: unknown,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n const schemaFragment = exeContext.schemaFragment;\n const fieldName = fieldGroup[0].name.value;\n const fieldDef = Definitions.getField(\n schemaFragment.definitions,\n parentTypeName,\n fieldName,\n );\n\n if (fieldDef !== undefined) {\n return resolveAndCompleteField(\n exeContext,\n parentTypeName,\n fieldDef,\n fieldGroup,\n path,\n source,\n incrementalDataRecord,\n );\n }\n\n const loading = requestSchemaFragment(exeContext, {\n kind: \"ReturnType\",\n parentTypeName,\n fieldName,\n });\n if (!loading) {\n handleMissingSchemaError(\n exeContext,\n undefined,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return undefined;\n }\n\n return loading.then(() => {\n const fieldDef = Definitions.getField(\n exeContext.schemaFragment.definitions,\n parentTypeName,\n fieldName,\n );\n if (fieldDef !== undefined) {\n return resolveAndCompleteField(\n exeContext,\n parentTypeName,\n fieldDef,\n fieldGroup,\n path,\n source,\n incrementalDataRecord,\n );\n }\n\n handleMissingSchemaError(\n exeContext,\n undefined,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return undefined;\n });\n}\n\nfunction requestSchemaFragment(\n exeContext: ExecutionContext,\n request: SchemaFragmentRequest,\n): PromiseOrValue<void> {\n if (!exeContext.schemaFragmentLoader) {\n return;\n }\n const currentSchemaId = exeContext.schemaFragment.schemaId;\n return exeContext\n .schemaFragmentLoader(\n exeContext.schemaFragment,\n exeContext.contextValue,\n request,\n )\n .then(({ mergedFragment, mergedContextValue }) => {\n if (currentSchemaId !== mergedFragment.schemaId) {\n throw new Error(\n `Cannot use new schema fragment: old and new fragments describe different schemas:` +\n ` ${currentSchemaId} vs. ${mergedFragment.schemaId}`,\n );\n }\n exeContext.contextValue = mergedContextValue ?? exeContext.contextValue;\n exeContext.schemaFragment = mergedFragment;\n });\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nfunction createSourceEventStream(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult | AsyncIterable<unknown>> {\n try {\n const eventStream = executeSubscriptionImpl(exeContext);\n if (isPromise(eventStream)) {\n return eventStream.then(undefined, (error) => ({ errors: [error] }));\n }\n\n return eventStream;\n } catch (error) {\n return { errors: [error as GraphQLError] };\n }\n}\n\nfunction afterFieldSubscribeHandle(\n resolved: unknown,\n isDefaultResolverUsed: boolean,\n exeContext: ExecutionContext,\n info: ResolveInfo,\n hookContext: unknown | undefined,\n afterFieldSubscribe: boolean,\n error?: Error,\n) {\n if (!isDefaultResolverUsed && afterFieldSubscribe) {\n hookContext = invokeAfterFieldSubscribeHook(\n info,\n exeContext,\n hookContext,\n resolved,\n error,\n );\n }\n}\n\nfunction executeSubscriptionImpl(\n exeContext: ExecutionContext,\n): PromiseOrValue<AsyncIterable<unknown>> {\n const { operation, rootValue, schemaFragment } = exeContext;\n const rootTypeName = getOperationRootTypeName(operation);\n const { groupedFieldSet } = collectFields(exeContext, rootTypeName);\n\n const firstRootField = groupedFieldSet.entries().next().value;\n if (firstRootField === undefined) {\n throw locatedError(\"Must have at least one root field.\", []);\n }\n\n const [responseName, fieldGroup] = firstRootField;\n const fieldName = fieldGroup[0].name.value;\n const fieldDef = Definitions.getField(\n schemaFragment.definitions,\n rootTypeName,\n fieldName,\n );\n\n if (!fieldDef) {\n throw locatedError(\n `The subscription field \"${fieldName}\" is not defined.`,\n fieldGroup,\n );\n }\n\n const returnTypeRef = Definitions.getFieldTypeReference(fieldDef);\n const resolveFn =\n Resolvers.getSubscriptionFieldResolver(\n schemaFragment,\n rootTypeName,\n fieldName,\n ) ?? exeContext.subscribeFieldResolver;\n\n const path = addPath(undefined, responseName, rootTypeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldGroup,\n rootTypeName,\n typeNameFromReference(returnTypeRef),\n path,\n );\n\n const isDefaultResolverUsed = resolveFn === exeContext.subscribeFieldResolver;\n const hooks = exeContext.fieldExecutionHooks;\n let hookContext: unknown = undefined;\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n let result: unknown;\n\n if (!isDefaultResolverUsed && hooks?.beforeFieldSubscribe) {\n hookContext = invokeBeforeFieldSubscribeHook(info, exeContext);\n }\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n if (hookContext) {\n if (isPromise(hookContext)) {\n result = hookContext.then((context) => {\n hookContext = context;\n\n return resolveFn(rootValue, args, contextValue, info);\n });\n }\n }\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n if (result === undefined) {\n result = resolveFn(rootValue, args, contextValue, info);\n }\n\n if (isPromise(result)) {\n return result\n .then(assertEventStream, (error) => {\n afterFieldSubscribeHandle(\n undefined,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n error,\n );\n throw locatedError(error, fieldGroup, pathToArray(path));\n })\n .then((resolved) => {\n afterFieldSubscribeHandle(\n resolved,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n );\n\n return resolved;\n });\n }\n\n const stream = assertEventStream(result);\n afterFieldSubscribeHandle(\n stream,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n );\n return stream;\n } catch (error) {\n if (!isDefaultResolverUsed && hooks?.afterFieldSubscribe) {\n invokeAfterFieldSubscribeHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n throw locatedError(error, fieldGroup, pathToArray(path));\n }\n}\n\nfunction assertEventStream(result: unknown): AsyncIterable<unknown> {\n if (result instanceof Error) {\n throw result;\n }\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(result)) {\n throw locatedError(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(result)}.`,\n [],\n );\n }\n\n return result;\n}\n\n// Either map or return potential event stream\nfunction mapResultOrEventStreamOrPromise(\n resultOrStreamOrPromise: PromiseOrValue<\n ExecutionResult | AsyncIterable<unknown>\n >,\n exeContext: ExecutionContext,\n parentTypeName: string,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n): PromiseOrValue<\n TotalExecutionResult | AsyncGenerator<TotalExecutionResult, void, void>\n> {\n if (isPromise(resultOrStreamOrPromise)) {\n return resultOrStreamOrPromise.then((resultOrStream) =>\n mapResultOrEventStreamOrPromise(\n resultOrStream,\n exeContext,\n parentTypeName,\n path,\n groupedFieldSet,\n ),\n );\n } else {\n if (!isAsyncIterable(resultOrStreamOrPromise)) {\n // This is typechecked in collect values\n return resultOrStreamOrPromise as TotalExecutionResult;\n } else {\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `executeFields` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) => {\n const perEventContext = buildPerEventExecutionContext(\n exeContext,\n payload,\n );\n const hooks = exeContext?.fieldExecutionHooks;\n let beforeExecuteSubscriptionEvenEmitHook;\n\n if (hooks?.beforeSubscriptionEventEmit) {\n beforeExecuteSubscriptionEvenEmitHook =\n invokeBeforeSubscriptionEventEmitHook(perEventContext, payload);\n\n if (beforeExecuteSubscriptionEvenEmitHook instanceof GraphQLError) {\n return buildResponse(perEventContext, null) as TotalExecutionResult;\n }\n }\n try {\n const data = isPromise(beforeExecuteSubscriptionEvenEmitHook)\n ? beforeExecuteSubscriptionEvenEmitHook.then((context) => {\n if (context instanceof GraphQLError) {\n return null;\n }\n\n return executeFields(\n exeContext.enablePerEventContext\n ? perEventContext\n : exeContext,\n parentTypeName,\n payload,\n path,\n groupedFieldSet,\n undefined,\n );\n })\n : executeFields(\n exeContext.enablePerEventContext ? perEventContext : exeContext,\n parentTypeName,\n payload,\n path,\n groupedFieldSet,\n undefined,\n );\n // This is typechecked in collect values\n return buildResponse(perEventContext, data) as TotalExecutionResult;\n } catch (error) {\n perEventContext.errors.push(error as GraphQLError);\n return buildResponse(perEventContext, null) as TotalExecutionResult;\n }\n };\n\n return mapAsyncIterator(resultOrStreamOrPromise, mapSourceToResponse);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function buildResolveInfo(\n exeContext: ExecutionContext,\n fieldName: string,\n fieldGroup: FieldGroup,\n parentTypeName: string,\n returnTypeName: string,\n path: Path,\n): ResolveInfo {\n // The resolve function's optional fourth argument is a collection of\n // information about the current execution state.\n return {\n fieldName: fieldName,\n fieldNodes: fieldGroup,\n returnTypeName,\n parentTypeName,\n path,\n fragments: exeContext.fragments,\n rootValue: exeContext.rootValue,\n operation: exeContext.operation,\n variableValues: exeContext.variableValues,\n };\n}\n\nfunction handleFieldError(\n rawError: unknown,\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference | undefined,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): void {\n const error = locatedError(rawError, fieldGroup, pathToArray(path));\n\n // If the field type is non-nullable, then it is resolved without any\n // protection from errors, however it still properly locates the error.\n if (returnTypeRef && isNonNullType(returnTypeRef)) {\n throw error;\n }\n\n const errors = incrementalDataRecord?.errors ?? exeContext.errors;\n\n // Otherwise, error protection is applied, logging the error and resolving\n // a null value for this field if one is encountered.\n errors.push(error);\n}\n\nfunction handleMissingSchemaError(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference | undefined,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n) {\n const parentTypeName = path.typename;\n // subscriptions have separate execution flow in executeSubscriptionImpl\n const isRootField =\n parentTypeName === \"Mutation\" || parentTypeName === \"Query\";\n if (!isRootField) {\n return;\n }\n\n const fieldName = path.key;\n const message = !returnTypeRef\n ? `Type definition for ${parentTypeName}.${fieldName} is missing`\n : `Resolver for ${parentTypeName}.${fieldName} is missing`;\n const error = new Error(message);\n\n handleFieldError(\n error,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n}\n\nfunction resolveAndCompleteField(\n exeContext: ExecutionContext,\n parentTypeName: string,\n fieldDefinition: FieldDefinition,\n fieldGroup: FieldGroup,\n path: Path,\n source: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n const fieldName = fieldGroup[0].name.value;\n const returnTypeRef = Definitions.getFieldTypeReference(fieldDefinition);\n\n const resolveFn: FunctionFieldResolver<unknown, unknown> =\n Resolvers.getFieldResolver(\n exeContext.schemaFragment,\n parentTypeName,\n fieldName,\n ) ?? exeContext.fieldResolver;\n\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldGroup,\n parentTypeName,\n typeNameFromReference(returnTypeRef),\n path,\n );\n\n const isDefaultResolverUsed =\n resolveFn === exeContext.fieldResolver || fieldName === \"__typename\";\n\n if (resolveFn === exeContext.fieldResolver && typeof source === \"undefined\") {\n /**\n * Resolving a root field with default resolver makes operation look succsessful, even though nothing was actually done.\n * This leads to problems that are hard to debug, especially for mutations.\n *\n * NOTE1: executing Mutation.__typename or Query.__typename with default resolver is fine\n * NOTE2: source check is required to account for systems like Grats that work exclusively on default resolvers\n */\n handleMissingSchemaError(\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n }\n\n const hooks = exeContext.fieldExecutionHooks;\n let hookContext: unknown = undefined;\n\n // the resolve function, regardless of if its result is normal or abrupt (error).\n try {\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n // TODO: find a way to memoize, in case this field is within a List type.\n const args = getArgumentValues(exeContext, fieldDefinition, fieldGroup[0]);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n if (!isDefaultResolverUsed && hooks?.beforeFieldResolve) {\n hookContext = invokeBeforeFieldResolveHook(info, exeContext);\n }\n\n let result: unknown;\n\n if (hookContext instanceof GraphQLError) {\n result = null;\n } else if (isPromise(hookContext)) {\n result = hookContext.then((context) => {\n hookContext = context;\n\n if (hookContext instanceof GraphQLError) {\n return null;\n }\n\n return resolveFn(source, args, contextValue, info);\n });\n } else {\n result = resolveFn(source, args, contextValue, info);\n }\n\n let completed;\n\n if (isPromise(result)) {\n completed = result\n .then((resolved) => {\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n resolved,\n );\n return hookContext instanceof GraphQLError ? null : resolved;\n }\n\n return resolved;\n })\n .then(\n (resolved) => {\n return completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n hookContext instanceof GraphQLError ? null : resolved,\n incrementalDataRecord,\n );\n },\n (rawError) => {\n // That's where afterResolve hook can only be called\n // in the case of async resolver promise rejection.\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n undefined,\n rawError,\n );\n }\n // Error will be handled on field completion\n throw rawError;\n },\n );\n } else {\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n result,\n );\n result = hookContext instanceof GraphQLError ? null : result;\n }\n\n completed = completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n if (isPromise(completed)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n return completed.then(\n (resolved) => {\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n resolved,\n );\n return hookContext instanceof GraphQLError ? null : resolved;\n }\n\n return resolved;\n },\n (rawError) => {\n const error = locatedError(rawError, fieldGroup, pathToArray(path));\n\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return null;\n },\n );\n }\n\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n completed,\n );\n\n return hookContext instanceof GraphQLError ? null : completed;\n }\n return completed;\n } catch (rawError) {\n const pathArray = pathToArray(path);\n const error = locatedError(rawError, fieldGroup, pathArray);\n // Do not invoke afterFieldResolve hook when error path and current field path are not equal:\n // it means that field itself resolved fine (so afterFieldResolve has been invoked already),\n // but non-nullable child field resolving throws an error,\n // so that error is propagated to the parent field according to spec\n if (\n !isDefaultResolverUsed &&\n hooks?.afterFieldResolve &&\n error.path &&\n arraysAreEqual(pathArray, error.path)\n ) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return null;\n }\n}\n\n/**\n * Implements the instructions for completeValue as defined in the\n * \"Field entries\" section of the spec.\n *\n * If the field type is Non-Null, then this recursively completes the value\n * for the inner type. It throws a field error if that completion returns null,\n * as per the \"Nullability\" section of the spec.\n *\n * If the field type is a List, then this recursively completes the value\n * for the inner type on each item in the list.\n *\n * If the field type is a Scalar or Enum, ensures the completed value is a legal\n * value of the type by calling the `serialize` method of GraphQL type\n * definition.\n *\n * If the field is an abstract type, determine the runtime type of the value\n * and then complete based on that type\n *\n * Otherwise, the field type expects a sub-selection set, and will complete the\n * value by executing all sub-selections.\n */\nfunction completeValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n // If result is an Error, throw a located error.\n if (result instanceof Error) {\n throw result;\n }\n\n // If field type is NonNull, complete for inner type, and throw field error\n // if result is null.\n if (isNonNullType(returnTypeRef)) {\n const completed = completeValue(\n exeContext,\n unwrap(returnTypeRef),\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n if (completed === null) {\n throw new Error(\n `Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.`,\n );\n }\n return completed;\n }\n\n // If result value is null or undefined then return null.\n if (result == null) {\n return null;\n }\n\n // If field type is List, complete each item in the list with the inner type\n if (isListType(returnTypeRef)) {\n return completeListValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n const { schemaFragment } = exeContext;\n const returnTypeName = typeNameFromReference(returnTypeRef);\n\n // If field type is a leaf type, Scalar or Enum, serialize to a valid value,\n // returning null if serialization is not possible.\n const leafType = Resolvers.getLeafTypeResolver(schemaFragment, returnTypeRef);\n if (leafType) {\n return completeLeafValue(leafType, result);\n }\n\n // If field type is an abstract type, Interface or Union, determine the\n // runtime Object type and complete for that type.\n if (Definitions.isAbstractType(schemaFragment.definitions, returnTypeRef)) {\n return completeAbstractValue(\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n // If field type is Object, execute and complete all sub-selections.\n // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n if (Definitions.isObjectType(schemaFragment.definitions, returnTypeRef)) {\n return completeObjectValue(\n exeContext,\n returnTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n // istanbul ignore next (Not reachable. All possible output types have been considered)\n invariant(\n false,\n \"Cannot complete value of unexpected output type: \" +\n inspectTypeReference(returnTypeRef),\n );\n}\n\nasync function completePromisedValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: Promise<unknown>,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): Promise<unknown> {\n try {\n const resolved = await result;\n let completed = completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n resolved,\n incrementalDataRecord,\n );\n if (isPromise(completed)) {\n completed = await completed;\n }\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n }\n}\n\n/**\n * Complete a list value by completing each item in the list with the\n * inner type\n */\nfunction completeListValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference, // assuming list type\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ReadonlyArray<unknown>> {\n const itemTypeRef = unwrap(returnTypeRef);\n if (isAsyncIterable(result)) {\n const asyncIterator = result[Symbol.asyncIterator]();\n\n return completeAsyncIteratorValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n path,\n asyncIterator,\n incrementalDataRecord,\n );\n }\n\n if (!isIterableObject(result)) {\n throw locatedError(\n `Expected Iterable, but did not find one for field \"${info.parentTypeName}.${info.fieldName}\".`,\n [],\n );\n }\n\n const stream = getStreamValues(exeContext, fieldGroup, path);\n\n // This is specified as a simple map, however we're optimizing the path\n // where the list contains no Promises by avoiding creating another Promise.\n let containsPromise = false;\n let previousIncrementalDataRecord = incrementalDataRecord;\n const completedResults: Array<unknown> = [];\n let index = 0;\n for (const item of result) {\n // No need to modify the info object containing the path,\n // since from here on it is not ever accessed by resolver functions.\n const itemPath = addPath(path, index, undefined);\n\n if (\n stream &&\n typeof stream.initialCount === \"number\" &&\n index >= stream.initialCount\n ) {\n previousIncrementalDataRecord = executeStreamField(\n path,\n itemPath,\n item,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n stream.label,\n previousIncrementalDataRecord,\n );\n index++;\n continue;\n }\n\n if (\n completeListItemValue(\n item,\n completedResults,\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n incrementalDataRecord,\n )\n ) {\n containsPromise = true;\n }\n\n index++;\n }\n\n return containsPromise ? Promise.all(completedResults) : completedResults;\n}\n\n/**\n * Complete a list item value by adding it to the completed results.\n *\n * Returns true if the value is a Promise.\n */\nfunction completeListItemValue(\n item: unknown,\n completedResults: Array<unknown>,\n exeContext: ExecutionContext,\n itemTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemPath: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): boolean {\n if (isPromise(item)) {\n completedResults.push(\n completePromisedValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n ),\n );\n\n return true;\n }\n\n try {\n const completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n\n if (isPromise(completedItem)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n completedResults.push(\n completedItem.then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n }),\n );\n\n return true;\n }\n\n completedResults.push(completedItem);\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n completedResults.push(null);\n }\n\n return false;\n}\n\n/**\n * Returns an object containing the `@stream` arguments if a field should be\n * streamed based on the experimental flag, stream directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getStreamValues(\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n path: Path,\n):\n | undefined\n | {\n initialCount: number | undefined;\n label: string | undefined;\n } {\n // do not stream inner lists of multi-dimensional lists\n if (typeof path.key === \"number\") {\n return;\n }\n\n // validation only allows equivalent streams on multiple fields, so it is\n // safe to only check the first fieldNode for the stream directive\n const stream = getDirectiveValues(\n exeContext,\n GraphQLStreamDirective,\n fieldGroup[0],\n );\n\n if (!stream) {\n return;\n }\n\n if (stream.if === false) {\n return;\n }\n\n invariant(\n typeof stream.initialCount === \"number\",\n \"initialCount must be a number\",\n );\n\n invariant(\n stream.initialCount >= 0,\n \"initialCount must be a positive integer\",\n );\n\n invariant(\n exeContext.operation.operation !== \"subscription\",\n \"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.\",\n );\n\n return {\n initialCount: stream.initialCount,\n label: typeof stream.label === \"string\" ? stream.label : undefined,\n };\n}\n\n/**\n * Complete a async iterator value by completing the result and calling\n * recursively until all the results are completed.\n */\nasync function completeAsyncIteratorValue(\n exeContext: ExecutionContext,\n itemTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n asyncIterator: AsyncIterator<unknown>,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): Promise<ReadonlyArray<unknown>> {\n const stream = getStreamValues(exeContext, fieldGroup, path);\n let containsPromise = false;\n const completedResults: Array<unknown> = [];\n let index = 0;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (\n stream &&\n typeof stream.initialCount === \"number\" &&\n index >= stream.initialCount\n ) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n executeStreamAsyncIterator(\n index,\n asyncIterator,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n path,\n stream.label,\n incrementalDataRecord,\n );\n break;\n }\n\n const itemPath = addPath(path, index, undefined);\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await asyncIterator.next();\n if (iteration.done) {\n break;\n }\n } catch (rawError) {\n throw locatedError(rawError, fieldGroup, pathToArray(path));\n }\n\n if (\n completeListItemValue(\n iteration.value,\n completedResults,\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n incrementalDataRecord,\n )\n ) {\n containsPromise = true;\n }\n index += 1;\n }\n return containsPromise ? Promise.all(completedResults) : completedResults;\n}\n\n/**\n * Complete a Scalar or Enum by serializing to a valid value, returning\n * null if serialization is not possible.\n */\nfunction completeLeafValue(\n returnType: GraphQLLeafType,\n result: unknown,\n): unknown {\n const serializedResult = returnType.serialize(result);\n if (serializedResult === undefined) {\n throw new Error(\n `Expected a value of type \"${inspect(returnType)}\" but ` +\n `received: ${inspect(result)}`,\n );\n }\n return serializedResult;\n}\n\n/**\n * Complete a value of an abstract type by determining the runtime object type\n * of that value, then complete the value for that type.\n */\nfunction completeAbstractValue(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n const { schemaFragment } = exeContext;\n const resolveTypeFn =\n Resolvers.getAbstractTypeResolver(schemaFragment, returnTypeName) ??\n exeContext.typeResolver;\n const contextValue = exeContext.contextValue;\n const runtimeTypeName = resolveTypeFn(result, contextValue, info);\n\n const validatedRuntimeTypeName = isPromise(runtimeTypeName)\n ? runtimeTypeName.then((resolvedRuntimeTypeName) =>\n ensureValidRuntimeType(\n resolvedRuntimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n result,\n ),\n )\n : ensureValidRuntimeType(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n result,\n );\n\n if (isPromise(validatedRuntimeTypeName)) {\n return validatedRuntimeTypeName.then((resolvedRuntimeTypeName) =>\n completeObjectValue(\n exeContext,\n resolvedRuntimeTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n ),\n );\n }\n\n return completeObjectValue(\n exeContext,\n validatedRuntimeTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n}\n\nfunction ensureValidRuntimeType(\n runtimeTypeName: unknown,\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n result: unknown,\n): PromiseOrValue<string> {\n if (runtimeTypeName == null) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" must resolve to an Object type at runtime for field \"${info.parentTypeName}.${info.fieldName}\".` +\n ` Either the \"${returnTypeName}\" should provide a \"__resolveType\" resolver function` +\n ` or \"${info.parentTypeName}.${info.fieldName}\" should be an object with \"__typename\" property.`,\n fieldGroup,\n );\n }\n\n if (typeof runtimeTypeName !== \"string\") {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" must resolve to an Object type at runtime for field \"${info.returnTypeName}.${info.fieldName}\" with ` +\n `value ${inspect(result)}, received \"${inspect(runtimeTypeName)}\".`,\n [],\n );\n }\n\n // Presence of schema fragment loader triggers strict checks for interface types\n // (assuming we can get full information about interface implementations on demand)\n const strictInterfaceValidation = !!exeContext.schemaFragmentLoader;\n\n const isDefinedType = Definitions.isDefined(\n exeContext.schemaFragment.definitions,\n runtimeTypeName,\n );\n const loading = !isDefinedType\n ? requestSchemaFragment(exeContext, {\n kind: \"RuntimeType\",\n abstractTypeName: returnTypeName,\n runtimeTypeName,\n })\n : undefined;\n return loading\n ? loading.then(() =>\n ensureValidRuntimeTypeImpl(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n strictInterfaceValidation,\n ),\n )\n : ensureValidRuntimeTypeImpl(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n strictInterfaceValidation,\n );\n}\n\nfunction ensureValidRuntimeTypeImpl(\n runtimeTypeName: string,\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n strictInterfaceValidation: boolean,\n): string {\n const definitions = exeContext.schemaFragment.definitions;\n\n const union = Definitions.getUnionType(definitions, returnTypeName);\n if (union || strictInterfaceValidation) {\n // Standard graphql-js checks\n if (!Definitions.isDefined(definitions, runtimeTypeName)) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a type \"${runtimeTypeName}\" that does not exist inside the schema.`,\n fieldGroup,\n );\n }\n if (!Definitions.isObjectType(definitions, runtimeTypeName)) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n fieldGroup,\n );\n }\n if (!Definitions.isSubType(definitions, returnTypeName, runtimeTypeName)) {\n throw locatedError(\n `Runtime Object type \"${runtimeTypeName}\" is not a possible type for \"${returnTypeName}\".`,\n fieldGroup,\n );\n }\n return runtimeTypeName;\n }\n\n const iface = Definitions.getInterfaceType(definitions, returnTypeName);\n if (iface) {\n // Loose interface validation mode, significant deviation from graphql-js:\n // Assuming runtimeTypeName is a valid implementation of returnTypeName.\n if (\n Definitions.isDefined(definitions, runtimeTypeName) &&\n !Definitions.isObjectType(definitions, runtimeTypeName)\n ) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n fieldGroup,\n );\n }\n Definitions.addInterfaceImplementation(\n definitions,\n returnTypeName,\n runtimeTypeName,\n );\n return runtimeTypeName;\n }\n\n invariant(false, `${returnTypeName} is not an abstract type`);\n}\n\n/**\n * Complete an Object value by executing all sub-selections.\n */\nfunction completeObjectValue(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n // Collect sub-fields to execute to complete this value.\n return collectAndExecuteSubfields(\n exeContext,\n returnTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n}\n\nfunction collectAndExecuteSubfields(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n // Collect sub-fields to execute to complete this value.\n const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } =\n collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);\n\n const subFields = executeFields(\n exeContext,\n returnTypeName,\n result,\n path,\n subGroupedFieldSet,\n incrementalDataRecord,\n );\n\n for (const subPatch of subPatches) {\n const { label, groupedFieldSet: subPatchGroupedFieldSet } = subPatch;\n executeDeferredFragment(\n exeContext,\n returnTypeName,\n result,\n subPatchGroupedFieldSet,\n label,\n path,\n incrementalDataRecord,\n );\n }\n\n return subFields;\n}\n\nfunction invokeBeforeFieldSubscribeHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeFieldSubscribe;\n if (!hook) {\n return;\n }\n\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by beforeFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from beforeFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeFieldResolveHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeFieldResolve;\n if (!hook) {\n return;\n }\n\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by beforeFieldResolve hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from beforeFieldResolve hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldResolveHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldResolve;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldResolve hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldResolve hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldSubscribeHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldSubscribe;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldCompleteHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldComplete;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldComplete hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldComplete hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeOperationExecuteHook(exeContext: ExecutionContext) {\n const hook = exeContext.fieldExecutionHooks?.beforeOperationExecute;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by beforeOperationExecute hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n }\n\n if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from beforeOperationExecute hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeSubscriptionEventEmitHook(\n exeContext: ExecutionContext,\n eventPayload: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeSubscriptionEventEmit;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n eventPayload,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by beforeSubscriptionEventEmit hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from beforeSubscriptionEventEmit hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterBuildResponseHook(\n exeContext: ExecutionContext,\n result: TotalExecutionResult,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterBuildResponse;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n result,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by afterBuildResponse hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from afterBuildResponse hook (operation: ${operationName})`,\n );\n\n exeContext.errors.push(error);\n }\n },\n );\n}\n\nfunction executeSafe<T>(\n execute: () => T | Promise<T>,\n onComplete: (result: T | undefined, error: unknown) => T | Promise<T>,\n): T | Promise<T> {\n let error: unknown;\n let result: T | Promise<T> | undefined;\n try {\n result = execute();\n } catch (e) {\n error = e;\n }\n\n if (!isPromise(result)) {\n return onComplete(result, error);\n }\n\n return result\n .then((hookResult) => {\n return onComplete(hookResult, error);\n })\n .catch((e) => {\n return onComplete(undefined, e);\n }) as Promise<T>;\n}\n\nfunction toGraphQLError(\n originalError: unknown,\n path: Path | undefined,\n prependMessage: string,\n): GraphQLError {\n const originalMessage =\n originalError instanceof Error\n ? originalError.message\n : inspect(originalError);\n const error = new Error(`${prependMessage}: ${originalMessage}`);\n return locatedError(error, undefined, path ? pathToArray(path) : undefined);\n}\n\n/**\n * If a resolveType function is not given, then a default resolve behavior is\n * used which attempts two strategies:\n *\n * First, See if the provided value has a `__typename` field defined, if so, use\n * that value as name of the resolved type.\n *\n * Otherwise, test each possible type for the abstract type by calling\n * isTypeOf for the object being coerced, returning the first type that matches.\n */\nexport const defaultTypeResolver: TypeResolver<unknown, unknown> = function (\n value,\n) {\n if (isObjectLike(value) && typeof value.__typename === \"string\") {\n return value.__typename;\n }\n};\n\n/**\n * If a resolve function is not given, then a default resolve behavior is used\n * which takes the property of the source object of the same name as the field\n * and returns it as the result, or if it's a function, returns the result\n * of calling that function while passing along args and context value.\n */\nexport const defaultFieldResolver: FunctionFieldResolver<unknown, unknown> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function (source: any, args, contextValue, info) {\n // ensure source is a value for which property access is acceptable.\n if (isObjectLike(source) || typeof source === \"function\") {\n const property = source[info.fieldName];\n if (typeof property === \"function\") {\n return source[info.fieldName](args, contextValue, info);\n }\n return property;\n }\n };\n\nexport function getOperationRootTypeName(\n operation: OperationDefinitionNode | OperationTypeDefinitionNode,\n): string {\n switch (operation.operation) {\n case \"query\":\n return \"Query\";\n case \"mutation\":\n return \"Mutation\";\n case \"subscription\":\n return \"Subscription\";\n default:\n invariant(\n false,\n `Operation \"${operation.operation}\" is not a part of GraphQL spec`,\n );\n }\n}\n\nfunction executeDeferredFragment(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n fields: GroupedFieldSet,\n label?: string,\n path?: Path,\n parentContext?: IncrementalDataRecord,\n): void {\n const incrementalDataRecord = new DeferredFragmentRecord({\n label,\n path,\n parentContext,\n exeContext,\n });\n let promiseOrData;\n try {\n promiseOrData = executeFields(\n exeContext,\n parentTypeName,\n sourceValue,\n path,\n fields,\n incrementalDataRecord,\n );\n\n if (isPromise(promiseOrData)) {\n promiseOrData = promiseOrData.then(null, (e) => {\n incrementalDataRecord.errors.push(e);\n return null;\n });\n }\n } catch (e) {\n incrementalDataRecord.errors.push(e as GraphQLError);\n promiseOrData = null;\n }\n incrementalDataRecord.addData(promiseOrData);\n}\n\nfunction executeStreamField(\n path: Path,\n itemPath: Path,\n item: PromiseOrValue<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n label?: string,\n parentContext?: IncrementalDataRecord,\n): IncrementalDataRecord {\n const incrementalDataRecord = new StreamItemsRecord({\n label,\n path: itemPath,\n parentContext,\n exeContext,\n });\n if (isPromise(item)) {\n const completedItems = completePromisedValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n ).then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n\n incrementalDataRecord.addItems(completedItems);\n return incrementalDataRecord;\n }\n\n let completedItem: PromiseOrValue<unknown>;\n try {\n try {\n completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n completedItem = null;\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n }\n } catch (error) {\n incrementalDataRecord.errors.push(error as GraphQLError);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n incrementalDataRecord.addItems(null);\n return incrementalDataRecord;\n }\n\n if (isPromise(completedItem)) {\n const completedItems = completedItem\n .then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n })\n .then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n\n incrementalDataRecord.addItems(completedItems);\n return incrementalDataRecord;\n }\n\n incrementalDataRecord.addItems([completedItem]);\n return incrementalDataRecord;\n}\n\nasync function executeStreamAsyncIteratorItem(\n asyncIterator: AsyncIterator<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n incrementalDataRecord: StreamItemsRecord,\n path: Path,\n itemPath: Path,\n): Promise<IteratorResult<unknown>> {\n let item;\n try {\n const { value, done } = await asyncIterator.next();\n if (done) {\n incrementalDataRecord.setIsCompletedAsyncIterator();\n return { done, value: undefined };\n }\n item = value;\n } catch (rawError) {\n throw locatedError(rawError, fieldGroup, pathToArray(path));\n }\n let completedItem;\n try {\n completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n\n if (isPromise(completedItem)) {\n completedItem = completedItem.then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n });\n }\n return { done: false, value: completedItem };\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return { done: false, value: null };\n }\n}\n\nasync function executeStreamAsyncIterator(\n initialIndex: number,\n asyncIterator: AsyncIterator<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n path: Path,\n label?: string,\n parentContext?: IncrementalDataRecord,\n): Promise<void> {\n let index = initialIndex;\n let previousIncrementalDataRecord = parentContext ?? undefined;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const itemPath = addPath(path, index, undefined);\n const incrementalDataRecord = new StreamItemsRecord({\n label,\n path: itemPath,\n parentContext: previousIncrementalDataRecord,\n asyncIterator,\n exeContext,\n });\n\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await executeStreamAsyncIteratorItem(\n asyncIterator,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n incrementalDataRecord,\n path,\n itemPath,\n );\n } catch (error) {\n incrementalDataRecord.errors.push(error as GraphQLError);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n incrementalDataRecord.addItems(null);\n // entire stream has errored and bubbled upwards\n if (asyncIterator?.return) {\n asyncIterator.return().catch(() => {\n // ignore errors\n });\n }\n return;\n }\n\n const { done, value: completedItem } = iteration;\n\n let completedItems: PromiseOrValue<Array<unknown> | null>;\n if (isPromise(completedItem)) {\n completedItems = completedItem.then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n } else {\n completedItems = [completedItem];\n }\n\n incrementalDataRecord.addItems(completedItems);\n\n if (done) {\n break;\n }\n previousIncrementalDataRecord = incrementalDataRecord;\n index++;\n }\n}\n\nfunction filterSubsequentPayloads(\n exeContext: ExecutionContext,\n nullPath: Path,\n currentIncrementalDataRecord: IncrementalDataRecord | undefined,\n): void {\n const nullPathArray = pathToArray(nullPath);\n exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {\n if (incrementalDataRecord === currentIncrementalDataRecord) {\n // don't remove payload from where error originates\n return;\n }\n for (let i = 0; i < nullPathArray.length; i++) {\n if (incrementalDataRecord.path[i] !== nullPathArray[i]) {\n // incrementalDataRecord points to a path unaffected by this payload\n return;\n }\n }\n // incrementalDataRecord path points to nulled error field\n if (\n isStreamItemsRecord(incrementalDataRecord) &&\n incrementalDataRecord.asyncIterator?.return\n ) {\n incrementalDataRecord.asyncIterator.return().catch(() => {\n // ignore error\n });\n }\n exeContext.subsequentPayloads.delete(incrementalDataRecord);\n });\n}\n\nfunction getCompletedIncrementalResults(\n exeContext: ExecutionContext,\n): Array<IncrementalResult> {\n const incrementalResults: Array<IncrementalResult> = [];\n for (const incrementalDataRecord of exeContext.subsequentPayloads) {\n const incrementalResult: IncrementalResult = {};\n if (!incrementalDataRecord.isCompleted) {\n continue;\n }\n exeContext.subsequentPayloads.delete(incrementalDataRecord);\n if (isStreamItemsRecord(incrementalDataRecord)) {\n const items = incrementalDataRecord.items;\n if (incrementalDataRecord.isCompletedAsyncIterator) {\n // async iterable resolver just finished but there may be pending payloads\n continue;\n }\n (incrementalResult as IncrementalStreamResult).items = items;\n } else {\n const data = incrementalDataRecord.data;\n (incrementalResult as IncrementalDeferResult).data = data ?? null;\n }\n\n incrementalResult.path = incrementalDataRecord.path;\n if (incrementalDataRecord.label != null) {\n incrementalResult.label = incrementalDataRecord.label;\n }\n if (incrementalDataRecord.errors.length > 0) {\n incrementalResult.errors = incrementalDataRecord.errors;\n }\n incrementalResults.push(incrementalResult);\n }\n return incrementalResults;\n}\n\nfunction yieldSubsequentPayloads(\n exeContext: ExecutionContext,\n): AsyncGenerator<SubsequentIncrementalExecutionResult, void, void> {\n let isDone = false;\n\n async function next(): Promise<\n IteratorResult<SubsequentIncrementalExecutionResult, void>\n > {\n if (isDone) {\n return { value: undefined, done: true };\n }\n\n await Promise.race(\n Array.from(exeContext.subsequentPayloads).map((p) => p.promise),\n );\n\n if (isDone) {\n // a different call to next has exhausted all payloads\n return { value: undefined, done: true };\n }\n\n const incremental = getCompletedIncrementalResults(exeContext);\n const hasNext = exeContext.subsequentPayloads.size > 0;\n\n if (!incremental.length && hasNext) {\n return next();\n }\n\n if (!hasNext) {\n isDone = true;\n }\n\n return {\n value: incremental.length ? { incremental, hasNext } : { hasNext },\n done: false,\n };\n }\n\n function returnStreamIterators() {\n const promises: Array<Promise<IteratorResult<unknown>>> = [];\n exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {\n if (\n isStreamItemsRecord(incrementalDataRecord) &&\n incrementalDataRecord.asyncIterator?.return\n ) {\n promises.push(incrementalDataRecord.asyncIterator.return());\n }\n });\n return Promise.all(promises);\n }\n\n return {\n [Symbol.asyncIterator]() {\n return this;\n },\n next,\n async return(): Promise<\n IteratorResult<SubsequentIncrementalExecutionResult, void>\n > {\n await returnStreamIterators();\n isDone = true;\n return { value: undefined, done: true };\n },\n async throw(\n error?: unknown,\n ): Promise<IteratorResult<SubsequentIncrementalExecutionResult, void>> {\n await returnStreamIterators();\n isDone = true;\n return Promise.reject(error);\n },\n };\n}\n\nexport type IncrementalDataRecord = DeferredFragmentRecord | StreamItemsRecord;\n\nfunction isStreamItemsRecord(\n incrementalDataRecord: IncrementalDataRecord,\n): incrementalDataRecord is StreamItemsRecord {\n return incrementalDataRecord.type === \"stream\";\n}\n\nclass DeferredFragmentRecord {\n type: \"defer\";\n errors: Array<GraphQLError>;\n label: string | undefined;\n path: Array<string | number>;\n promise: Promise<void>;\n data: ObjMap<unknown> | null;\n parentContext: IncrementalDataRecord | undefined;\n isCompleted: boolean;\n _exeContext: ExecutionContext;\n _resolve?: (arg: PromiseOrValue<ObjMap<unknown> | null>) => void;\n\n constructor(opts: {\n label: string | undefined;\n path: Path | undefined;\n parentContext: IncrementalDataRecord | undefined;\n exeContext: ExecutionContext;\n }) {\n this.type = \"defer\";\n this.label = opts.label;\n this.path = pathToArray(opts.path);\n this.parentContext = opts.parentContext;\n this.errors = [];\n this._exeContext = opts.exeContext;\n this._exeContext.subsequentPayloads.add(this);\n this.isCompleted = false;\n this.data = null;\n this.promise = new Promise<ObjMap<unknown> | null>((resolve) => {\n this._resolve = (promiseOrValue) => {\n resolve(promiseOrValue);\n };\n }).then((data) => {\n this.data = data;\n this.isCompleted = true;\n });\n }\n\n addData(data: PromiseOrValue<ObjMap<unknown> | null>) {\n const parentData = this.parentContext?.promise;\n if (parentData) {\n this._resolve?.(parentData.then(() => data));\n return;\n }\n this._resolve?.(data);\n }\n}\n\nclass StreamItemsRecord {\n type: \"stream\";\n errors: Array<GraphQLError>;\n label: string | undefined;\n path: Array<string | number>;\n items: Array<unknown> | null;\n promise: Promise<void>;\n parentContext: IncrementalDataRecord | undefined;\n asyncIterator: AsyncIterator<unknown> | undefined;\n isCompletedAsyncIterator?: boolean;\n isCompleted: boolean;\n _exeContext: ExecutionContext;\n _resolve?: (arg: PromiseOrValue<Array<unknown> | null>) => void;\n\n constructor(opts: {\n label: string | undefined;\n path: Path | undefined;\n asyncIterator?: AsyncIterator<unknown>;\n parentContext: IncrementalDataRecord | undefined;\n exeContext: ExecutionContext;\n }) {\n this.type = \"stream\";\n this.items = null;\n this.label = opts.label;\n this.path = pathToArray(opts.path);\n this.parentContext = opts.parentContext;\n this.asyncIterator = opts.asyncIterator;\n this.errors = [];\n this._exeContext = opts.exeContext;\n this._exeContext.subsequentPayloads.add(this);\n this.isCompleted = false;\n this.items = null;\n this.promise = new Promise<Array<unknown> | null>((resolve) => {\n this._resolve = (promiseOrValue) => {\n resolve(promiseOrValue);\n };\n }).then((items) => {\n this.items = items;\n this.isCompleted = true;\n });\n }\n\n addItems(items: PromiseOrValue<Array<unknown> | null>) {\n const parentData = this.parentContext?.promise;\n if (parentData) {\n this._resolve?.(parentData.then(() => items));\n return;\n }\n this._resolve?.(items);\n }\n\n setIsCompletedAsyncIterator() {\n this.isCompletedAsyncIterator = true;\n }\n}\n\nexport function isIncrementalExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n>(\n result: ExecutionResult<TData, TExtensions>,\n): result is IncrementalExecutionResult<TData, TExtensions> {\n return \"initialResult\" in result;\n}\n\nexport function isTotalExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n>(\n result: ExecutionResult<TData, TExtensions>,\n): result is TotalExecutionResult<TData, TExtensions> {\n return !(\"initialResult\" in result);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AACP,2BAKO;AACP,uBAA0B;AAC1B,qBAAwB;AACxB,uBA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I,IAAI;AAC5C,SAAK,cAAc;AACnB,SAAK,QAAQ;AACb,SAAK,UAAU,IAAI,QAA+B,CAAC,YAAY;AAC7D,WAAK,WAAW,CAAC,mBAAmB;AAClC,gBAAQ,cAAc;AAAA,MACxB;AAAA,IACF,CAAC,EAAE,KAAK,CAAC,UAAU;AACjB,WAAK,QAAQ;AACb,WAAK,cAAc;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,OAA8C;AAn2FzD;AAo2FI,UAAM,cAAa,UAAK,kBAAL,mBAAoB;AACvC,QAAI,YAAY;AACd,iBAAK,aAAL,8BAAgB,WAAW,KAAK,MAAM,KAAK;AAC3C;AAAA,IACF;AACA,eAAK,aAAL,8BAAgB;AAAA,EAClB;AAAA,EAEA,8BAA8B;AAC5B,SAAK,2BAA2B;AAAA,EAClC;AACF;AAEO,SAAS,6BAId,QAC0D;AAC1D,SAAO,mBAAmB;AAC5B;AAEO,SAAS,uBAId,QACoD;AACpD,SAAO,EAAE,mBAAmB;AAC9B;",
4
+ "sourcesContent": ["import {\n GraphQLError,\n GraphQLLeafType,\n Kind,\n locatedError,\n DocumentNode,\n FragmentDefinitionNode,\n OperationDefinitionNode,\n OperationTypeDefinitionNode,\n} from \"graphql\";\nimport {\n collectFields,\n collectSubfields as _collectSubfields,\n FieldGroup,\n GroupedFieldSet,\n} from \"./collectFields\";\nimport { devAssert } from \"./jsutils/devAssert\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { invariant } from \"./jsutils/invariant\";\nimport { isIterableObject } from \"./jsutils/isIterableObject\";\nimport { isObjectLike } from \"./jsutils/isObjectLike\";\nimport { isPromise } from \"./jsutils/isPromise\";\nimport type { Maybe } from \"./jsutils/Maybe\";\nimport type { ObjMap } from \"./jsutils/ObjMap\";\nimport type { Path } from \"./jsutils/Path\";\nimport { addPath, pathToArray } from \"./jsutils/Path\";\nimport { promiseForObject } from \"./jsutils/promiseForObject\";\nimport type { PromiseOrValue } from \"./jsutils/PromiseOrValue\";\nimport { promiseReduce } from \"./jsutils/promiseReduce\";\nimport type {\n ExecutionWithoutSchemaArgs,\n FunctionFieldResolver,\n ResolveInfo,\n TypeResolver,\n ExecutionResult,\n TotalExecutionResult,\n SubsequentIncrementalExecutionResult,\n IncrementalDeferResult,\n IncrementalResult,\n IncrementalStreamResult,\n IncrementalExecutionResult,\n SchemaFragment,\n SchemaFragmentLoader,\n SchemaFragmentRequest,\n} from \"./types\";\nimport {\n getArgumentValues,\n getVariableValues,\n getDirectiveValues,\n} from \"./values\";\nimport type { ExecutionHooks } from \"./hooks/types\";\nimport { arraysAreEqual } from \"./utilities/array\";\nimport { isAsyncIterable } from \"./jsutils/isAsyncIterable\";\nimport { mapAsyncIterator } from \"./utilities/mapAsyncIterator\";\nimport { GraphQLStreamDirective } from \"./schema/directives\";\nimport { memoize3 } from \"./jsutils/memoize3\";\nimport {\n inspectTypeReference,\n isListType,\n isNonNullType,\n typeNameFromReference,\n unwrap,\n} from \"./schema/reference\";\nimport type { TypeReference } from \"./schema/reference\";\nimport type { FieldDefinition } from \"./schema/definition\";\nimport * as Definitions from \"./schema/definition\";\nimport * as Resolvers from \"./schema/resolvers\";\n\n/**\n * A memoized collection of relevant subfields with regard to the return\n * type. Memoizing ensures the subfields are not repeatedly calculated, which\n * saves overhead when resolving lists of values.\n */\nconst collectSubfields = memoize3(\n (\n exeContext: ExecutionContext,\n // HAX??\n returnTypeName: { name: string },\n fieldGroup: FieldGroup,\n ) => _collectSubfields(exeContext, returnTypeName.name, fieldGroup),\n);\n\n/**\n * Terminology\n *\n * \"Definitions\" are the generic name for top-level statements in the document.\n * Examples of this include:\n * 1) Operations (such as a query)\n * 2) Fragments\n *\n * \"Operations\" are a generic name for requests in the document.\n * Examples of this include:\n * 1) query,\n * 2) mutation\n *\n * \"Selections\" are the definitions that can appear legally and at\n * single level of the query. These include:\n * 1) field references e.g \"a\"\n * 2) fragment \"spreads\" e.g. \"...c\"\n * 3) inline fragment \"spreads\" e.g. \"...on Type { a }\"\n */\n\n/**\n * Data that must be available at all points during query execution.\n *\n * Namely, schema of the type system that is currently executing,\n * and the fragments defined in the query document\n */\nexport interface ExecutionContext {\n schemaFragment: SchemaFragment;\n schemaFragmentLoader?: SchemaFragmentLoader;\n fragments: ObjMap<FragmentDefinitionNode>;\n rootValue: unknown;\n contextValue: unknown;\n buildContextValue?: (contextValue?: unknown) => unknown;\n operation: OperationDefinitionNode;\n variableValues: { [variable: string]: unknown };\n fieldResolver: FunctionFieldResolver<unknown, unknown>;\n typeResolver: TypeResolver<unknown, unknown>;\n subscribeFieldResolver: FunctionFieldResolver<unknown, unknown>;\n errors: Array<GraphQLError>;\n fieldExecutionHooks?: ExecutionHooks;\n subsequentPayloads: Set<IncrementalDataRecord>;\n enablePerEventContext: boolean;\n}\n\n/**\n * Implements the \"Executing requests\" section of the GraphQL specification.\n *\n * Returns either a synchronous ExecutionResult (if all encountered resolvers\n * are synchronous), or a Promise of an ExecutionResult that will eventually be\n * resolved and never rejected.\n *\n * If the arguments to this function do not result in a legal execution context,\n * a GraphQLError will be thrown immediately explaining the invalid input.\n */\nexport function executeWithoutSchema(\n args: ExecutionWithoutSchemaArgs,\n): PromiseOrValue<ExecutionResult> {\n // If a valid execution context cannot be created due to incorrect arguments,\n // a \"Response\" with only errors is returned.\n const exeContext = buildExecutionContext(args);\n\n // Return early errors if execution context failed.\n if (!(\"schemaFragment\" in exeContext)) {\n return { errors: exeContext };\n } else {\n return executeOperationWithBeforeHook(exeContext);\n }\n}\n\n/**\n * Essential assertions before executing to provide developer feedback for\n * improper use of the GraphQL library.\n *\n * @internal\n */\nexport function assertValidExecutionArguments(\n document: DocumentNode,\n rawVariableValues: Maybe<{ [variable: string]: unknown }>,\n): void {\n devAssert(document, \"Must provide document.\");\n\n // Variables, if provided, must be an object.\n devAssert(\n rawVariableValues == null || isObjectLike(rawVariableValues),\n \"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.\",\n );\n}\n\n/**\n * Constructs a ExecutionContext object from the arguments passed to\n * execute, which we will pass throughout the other execution methods.\n *\n * Throws a GraphQLError if a valid execution context cannot be created.\n *\n * @internal\n */\nfunction buildExecutionContext(\n args: ExecutionWithoutSchemaArgs,\n): Array<GraphQLError> | ExecutionContext {\n const {\n schemaFragment,\n schemaFragmentLoader,\n document,\n rootValue,\n contextValue,\n buildContextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n subscribeFieldResolver,\n fieldExecutionHooks,\n enablePerEventContext,\n } = args;\n\n assertValidExecutionArguments(document, variableValues);\n\n let operation: OperationDefinitionNode | undefined;\n const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);\n\n for (const definition of document.definitions) {\n switch (definition.kind) {\n case Kind.OPERATION_DEFINITION:\n if (operationName == null) {\n if (operation !== undefined) {\n return [\n locatedError(\n \"Must provide operation name if query contains multiple operations.\",\n [],\n ),\n ];\n }\n operation = definition;\n } else if (definition.name?.value === operationName) {\n operation = definition;\n }\n break;\n case Kind.FRAGMENT_DEFINITION:\n fragments[definition.name.value] = definition;\n break;\n }\n }\n\n if (!operation) {\n if (operationName != null) {\n return [locatedError(`Unknown operation named \"${operationName}\".`, [])];\n }\n return [locatedError(\"Must provide an operation.\", [])];\n }\n\n // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')\n const variableDefinitions = operation.variableDefinitions ?? [];\n\n const coercedVariableValues = getVariableValues(\n schemaFragment,\n variableDefinitions,\n variableValues ?? {},\n { maxErrors: 50 },\n );\n\n if (coercedVariableValues.errors) {\n return coercedVariableValues.errors;\n }\n\n return {\n schemaFragment,\n schemaFragmentLoader,\n fragments,\n rootValue,\n contextValue: buildContextValue\n ? buildContextValue(contextValue)\n : contextValue,\n buildContextValue,\n operation,\n variableValues: coercedVariableValues.coerced,\n fieldResolver: fieldResolver ?? defaultFieldResolver,\n typeResolver: typeResolver ?? defaultTypeResolver,\n subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,\n errors: [],\n fieldExecutionHooks,\n subsequentPayloads: new Set(),\n enablePerEventContext: enablePerEventContext ?? true,\n };\n}\n\nfunction buildPerEventExecutionContext(\n exeContext: ExecutionContext,\n payload: unknown,\n): ExecutionContext {\n return {\n ...exeContext,\n contextValue: exeContext.buildContextValue\n ? exeContext.buildContextValue(exeContext.contextValue)\n : exeContext.contextValue,\n rootValue: payload,\n subsequentPayloads: new Set(),\n errors: [],\n };\n}\n\nfunction executeOperationWithBeforeHook(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult> {\n const hooks = exeContext.fieldExecutionHooks;\n let hookResultPromise;\n if (hooks?.beforeOperationExecute) {\n hookResultPromise = invokeBeforeOperationExecuteHook(exeContext);\n }\n\n if (hookResultPromise instanceof GraphQLError) {\n return buildResponse(exeContext, null);\n }\n\n if (isPromise(hookResultPromise)) {\n return hookResultPromise.then((hookResult) => {\n if (hookResult instanceof GraphQLError) {\n return buildResponse(exeContext, null);\n }\n return executeOperation(exeContext);\n });\n }\n\n return executeOperation(exeContext);\n}\n\nfunction executeOperation(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult> {\n try {\n const { operation, rootValue } = exeContext;\n const rootTypeName = getOperationRootTypeName(operation);\n const { groupedFieldSet, patches } = collectFields(\n exeContext,\n rootTypeName,\n );\n const path = undefined;\n let result;\n\n // Note: cannot use OperationTypeNode from graphql-js as it doesn't exist in 15.x\n switch (operation.operation) {\n case \"query\":\n result = executeFields(\n exeContext,\n rootTypeName,\n rootValue,\n path,\n groupedFieldSet,\n undefined,\n );\n result = buildResponse(exeContext, result);\n break;\n case \"mutation\":\n result = executeFieldsSerially(\n exeContext,\n rootTypeName,\n rootValue,\n path,\n groupedFieldSet,\n );\n result = buildResponse(exeContext, result);\n break;\n case \"subscription\": {\n const resultOrStreamOrPromise = createSourceEventStream(exeContext);\n result = mapResultOrEventStreamOrPromise(\n resultOrStreamOrPromise,\n exeContext,\n rootTypeName,\n path,\n groupedFieldSet,\n );\n break;\n }\n default:\n invariant(\n false,\n `Operation \"${operation.operation}\" is not a part of GraphQL spec`,\n );\n }\n\n for (const patch of patches) {\n const { label, groupedFieldSet: patchGroupedFieldSet } = patch;\n executeDeferredFragment(\n exeContext,\n rootTypeName,\n rootValue,\n patchGroupedFieldSet,\n label,\n path,\n );\n }\n\n return result;\n } catch (error) {\n exeContext.errors.push(error as GraphQLError);\n return buildResponse(exeContext, null);\n }\n}\n\n/**\n * Given a completed execution context and data, build the { errors, data }\n * response defined by the \"Response\" section of the GraphQL specification.\n */\nfunction buildResponse(\n exeContext: ExecutionContext,\n data: PromiseOrValue<ObjMap<unknown> | null>,\n): PromiseOrValue<ExecutionResult> {\n if (isPromise(data)) {\n return data.then(\n (resolved) => buildResponse(exeContext, resolved),\n (error) => {\n exeContext.errors.push(error);\n return buildResponse(exeContext, null);\n },\n );\n }\n\n const hooks = exeContext.fieldExecutionHooks;\n try {\n const initialResult =\n exeContext.errors.length === 0\n ? { data }\n : { errors: exeContext.errors, data };\n if (exeContext.subsequentPayloads.size > 0) {\n // TODO: define how to call hooks for incremental results\n return {\n initialResult: {\n ...initialResult,\n hasNext: true,\n },\n subsequentResults: yieldSubsequentPayloads(exeContext),\n };\n } else {\n if (hooks?.afterBuildResponse) {\n const hookResult = invokeAfterBuildResponseHook(\n exeContext,\n initialResult,\n );\n if (exeContext.errors.length > (initialResult.errors?.length ?? 0)) {\n initialResult.errors = exeContext.errors;\n }\n if (hookResult instanceof GraphQLError) {\n return { errors: initialResult.errors };\n }\n }\n return initialResult;\n }\n } catch (error) {\n exeContext.errors.push(error as GraphQLError);\n return buildResponse(exeContext, null);\n }\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that must be executed serially.\n */\nfunction executeFieldsSerially(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n): PromiseOrValue<ObjMap<unknown>> {\n return promiseReduce(\n groupedFieldSet,\n (results, [responseName, fieldGroup]) => {\n const fieldPath = addPath(path, responseName, parentTypeName);\n const result = executeField(\n exeContext,\n parentTypeName,\n sourceValue,\n fieldGroup,\n fieldPath,\n undefined,\n );\n if (result === undefined) {\n return results;\n }\n if (isPromise(result)) {\n return result.then((resolvedResult: unknown) => {\n if (resolvedResult === undefined) {\n return results;\n }\n\n results[responseName] = resolvedResult;\n return results;\n });\n }\n results[responseName] = result;\n return results;\n },\n Object.create(null),\n );\n}\n\n/**\n * Implements the \"Executing selection sets\" section of the spec\n * for fields that may be executed in parallel.\n */\nfunction executeFields(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n const results = Object.create(null);\n let containsPromise = false;\n\n try {\n for (const [responseName, fieldGroup] of groupedFieldSet) {\n const fieldPath = addPath(path, responseName, parentTypeName);\n const result = executeField(\n exeContext,\n parentTypeName,\n sourceValue,\n fieldGroup,\n fieldPath,\n incrementalDataRecord,\n );\n\n if (result !== undefined) {\n results[responseName] = result;\n if (isPromise(result)) {\n containsPromise = true;\n }\n }\n }\n } catch (error) {\n if (containsPromise) {\n // Ensure that any promises returned by other fields are handled, as they may also reject.\n return promiseForObject(results).finally(() => {\n throw error;\n });\n }\n throw error;\n }\n\n // If there are no promises, we can just return the object\n if (!containsPromise) {\n return results;\n }\n\n // Otherwise, results is a map from field name to the result of resolving that\n // field, which is possibly a promise. Return a promise that will return this\n // same map, but with any promises replaced with the values they resolved to.\n return promiseForObject(results);\n}\n\n/**\n * Implements the \"Executing field\" section of the spec\n * In particular, this function figures out the value that the field returns by\n * calling its resolve function, then calls completeValue to complete promises,\n * serialize scalars, or execute the sub-selection-set for objects.\n */\nfunction executeField(\n exeContext: ExecutionContext,\n parentTypeName: string,\n source: unknown,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n const schemaFragment = exeContext.schemaFragment;\n const fieldName = fieldGroup[0].name.value;\n const fieldDef = Definitions.getField(\n schemaFragment.definitions,\n parentTypeName,\n fieldName,\n );\n\n if (fieldDef !== undefined) {\n return resolveAndCompleteField(\n exeContext,\n parentTypeName,\n fieldDef,\n fieldGroup,\n path,\n source,\n incrementalDataRecord,\n );\n }\n\n const loading = requestSchemaFragment(exeContext, {\n kind: \"ReturnType\",\n parentTypeName,\n fieldName,\n });\n if (!loading) {\n handleMissingSchemaError(\n exeContext,\n undefined,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return undefined;\n }\n\n return loading.then(() => {\n const fieldDef = Definitions.getField(\n exeContext.schemaFragment.definitions,\n parentTypeName,\n fieldName,\n );\n if (fieldDef !== undefined) {\n return resolveAndCompleteField(\n exeContext,\n parentTypeName,\n fieldDef,\n fieldGroup,\n path,\n source,\n incrementalDataRecord,\n );\n }\n\n handleMissingSchemaError(\n exeContext,\n undefined,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return undefined;\n });\n}\n\nfunction requestSchemaFragment(\n exeContext: ExecutionContext,\n request: SchemaFragmentRequest,\n): PromiseOrValue<void> {\n if (!exeContext.schemaFragmentLoader) {\n return;\n }\n const currentSchemaId = exeContext.schemaFragment.schemaId;\n return exeContext\n .schemaFragmentLoader(\n exeContext.schemaFragment,\n exeContext.contextValue,\n request,\n )\n .then(({ mergedFragment, mergedContextValue }) => {\n if (currentSchemaId !== mergedFragment.schemaId) {\n throw new Error(\n `Cannot use new schema fragment: old and new fragments describe different schemas:` +\n ` ${currentSchemaId} vs. ${mergedFragment.schemaId}`,\n );\n }\n exeContext.contextValue = mergedContextValue ?? exeContext.contextValue;\n exeContext.schemaFragment = mergedFragment;\n });\n}\n\n/**\n * Implements the \"CreateSourceEventStream\" algorithm described in the\n * GraphQL specification, resolving the subscription source event stream.\n *\n * Returns a Promise which resolves to either an AsyncIterable (if successful)\n * or an ExecutionResult (error). The promise will be rejected if the schema or\n * other arguments to this function are invalid, or if the resolved event stream\n * is not an async iterable.\n *\n * If the client-provided arguments to this function do not result in a\n * compliant subscription, a GraphQL Response (ExecutionResult) with\n * descriptive errors and no data will be returned.\n *\n * If the the source stream could not be created due to faulty subscription\n * resolver logic or underlying systems, the promise will resolve to a single\n * ExecutionResult containing `errors` and no `data`.\n *\n * If the operation succeeded, the promise resolves to the AsyncIterable for the\n * event stream returned by the resolver.\n *\n * A Source Event Stream represents a sequence of events, each of which triggers\n * a GraphQL execution for that event.\n *\n * This may be useful when hosting the stateful subscription service in a\n * different process or machine than the stateless GraphQL execution engine,\n * or otherwise separating these two steps. For more on this, see the\n * \"Supporting Subscriptions at Scale\" information in the GraphQL specification.\n */\nfunction createSourceEventStream(\n exeContext: ExecutionContext,\n): PromiseOrValue<ExecutionResult | AsyncIterable<unknown>> {\n try {\n const eventStream = executeSubscriptionImpl(exeContext);\n if (isPromise(eventStream)) {\n return eventStream.then(undefined, (error) => ({ errors: [error] }));\n }\n\n return eventStream;\n } catch (error) {\n return { errors: [error as GraphQLError] };\n }\n}\n\nfunction afterFieldSubscribeHandle(\n resolved: unknown,\n isDefaultResolverUsed: boolean,\n exeContext: ExecutionContext,\n info: ResolveInfo,\n hookContext: unknown | undefined,\n afterFieldSubscribe: boolean,\n error?: Error,\n) {\n if (!isDefaultResolverUsed && afterFieldSubscribe) {\n hookContext = invokeAfterFieldSubscribeHook(\n info,\n exeContext,\n hookContext,\n resolved,\n error,\n );\n }\n}\n\nfunction executeSubscriptionImpl(\n exeContext: ExecutionContext,\n): PromiseOrValue<AsyncIterable<unknown>> {\n const { operation, schemaFragment } = exeContext;\n const rootTypeName = getOperationRootTypeName(operation);\n const { groupedFieldSet } = collectFields(exeContext, rootTypeName);\n\n const firstRootField = groupedFieldSet.entries().next().value;\n if (firstRootField === undefined) {\n throw locatedError(\"Must have at least one root field.\", []);\n }\n\n const [responseName, fieldGroup] = firstRootField;\n const fieldName = fieldGroup[0].name.value;\n const fieldDef = Definitions.getField(\n schemaFragment.definitions,\n rootTypeName,\n fieldName,\n );\n\n if (fieldDef) {\n return runSubscriptionResolver(\n exeContext,\n fieldDef,\n fieldName,\n fieldGroup,\n responseName,\n rootTypeName,\n );\n }\n\n const loading = requestSchemaFragment(exeContext, {\n kind: \"ReturnType\",\n parentTypeName: rootTypeName,\n fieldName,\n });\n\n if (!loading) {\n throw locatedError(\n `Type definition for ${rootTypeName}.${fieldName} is missing`,\n fieldGroup,\n );\n }\n\n return loading.then(() => {\n const fieldDef = Definitions.getField(\n schemaFragment.definitions,\n rootTypeName,\n fieldName,\n );\n\n if (fieldDef === undefined) {\n throw locatedError(\n `Type definition for ${rootTypeName}.${fieldName} is missing`,\n fieldGroup,\n );\n }\n\n return runSubscriptionResolver(\n exeContext,\n fieldDef,\n fieldName,\n fieldGroup,\n responseName,\n rootTypeName,\n );\n });\n}\n\nfunction runSubscriptionResolver(\n exeContext: ExecutionContext,\n fieldDef: FieldDefinition,\n fieldName: string,\n fieldGroup: FieldGroup,\n responseName: string,\n rootTypeName: string,\n): PromiseOrValue<AsyncIterable<unknown>> {\n const { rootValue, schemaFragment } = exeContext;\n const returnTypeRef = Definitions.getFieldTypeReference(fieldDef);\n const resolveFn =\n Resolvers.getSubscriptionFieldResolver(\n schemaFragment,\n rootTypeName,\n fieldName,\n ) ?? exeContext.subscribeFieldResolver;\n\n const path = addPath(undefined, responseName, rootTypeName);\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldGroup,\n rootTypeName,\n typeNameFromReference(returnTypeRef),\n path,\n );\n\n const isDefaultResolverUsed = resolveFn === exeContext.subscribeFieldResolver;\n const hooks = exeContext.fieldExecutionHooks;\n let hookContext: unknown = undefined;\n\n try {\n // Implements the \"ResolveFieldEventStream\" algorithm from GraphQL specification.\n // It differs from \"ResolveFieldValue\" due to providing a different `resolveFn`.\n\n let result: unknown;\n\n if (!isDefaultResolverUsed && hooks?.beforeFieldSubscribe) {\n hookContext = invokeBeforeFieldSubscribeHook(info, exeContext);\n }\n\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n if (hookContext) {\n if (isPromise(hookContext)) {\n result = hookContext.then((context) => {\n hookContext = context;\n\n return resolveFn(rootValue, args, contextValue, info);\n });\n }\n }\n\n // Call the `subscribe()` resolver or the default resolver to produce an\n // AsyncIterable yielding raw payloads.\n if (result === undefined) {\n result = resolveFn(rootValue, args, contextValue, info);\n }\n\n if (isPromise(result)) {\n return result\n .then(assertEventStream, (error) => {\n afterFieldSubscribeHandle(\n undefined,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n error,\n );\n throw locatedError(error, fieldGroup, pathToArray(path));\n })\n .then((resolved) => {\n afterFieldSubscribeHandle(\n resolved,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n );\n\n return resolved;\n });\n }\n\n const stream = assertEventStream(result);\n afterFieldSubscribeHandle(\n stream,\n isDefaultResolverUsed,\n exeContext,\n info,\n hookContext,\n !!hooks?.afterFieldSubscribe,\n );\n return stream;\n } catch (error) {\n if (!isDefaultResolverUsed && hooks?.afterFieldSubscribe) {\n invokeAfterFieldSubscribeHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n throw locatedError(error, fieldGroup, pathToArray(path));\n }\n}\n\nfunction assertEventStream(result: unknown): AsyncIterable<unknown> {\n if (result instanceof Error) {\n throw result;\n }\n\n // Assert field returned an event stream, otherwise yield an error.\n if (!isAsyncIterable(result)) {\n throw locatedError(\n \"Subscription field must return Async Iterable. \" +\n `Received: ${inspect(result)}.`,\n [],\n );\n }\n\n return result;\n}\n\n// Either map or return potential event stream\nfunction mapResultOrEventStreamOrPromise(\n resultOrStreamOrPromise: PromiseOrValue<\n ExecutionResult | AsyncIterable<unknown>\n >,\n exeContext: ExecutionContext,\n parentTypeName: string,\n path: Path | undefined,\n groupedFieldSet: GroupedFieldSet,\n): PromiseOrValue<\n TotalExecutionResult | AsyncGenerator<TotalExecutionResult, void, void>\n> {\n if (isPromise(resultOrStreamOrPromise)) {\n return resultOrStreamOrPromise.then((resultOrStream) =>\n mapResultOrEventStreamOrPromise(\n resultOrStream,\n exeContext,\n parentTypeName,\n path,\n groupedFieldSet,\n ),\n );\n } else {\n if (!isAsyncIterable(resultOrStreamOrPromise)) {\n // This is typechecked in collect values\n return resultOrStreamOrPromise as TotalExecutionResult;\n } else {\n // For each payload yielded from a subscription, map it over the normal\n // GraphQL `execute` function, with `payload` as the rootValue.\n // This implements the \"MapSourceToResponseEvent\" algorithm described in\n // the GraphQL specification. The `executeFields` function provides the\n // \"ExecuteSubscriptionEvent\" algorithm, as it is nearly identical to the\n // \"ExecuteQuery\" algorithm, for which `execute` is also used.\n const mapSourceToResponse = (payload: unknown) => {\n const perEventContext = buildPerEventExecutionContext(\n exeContext,\n payload,\n );\n const hooks = exeContext?.fieldExecutionHooks;\n let beforeExecuteSubscriptionEvenEmitHook;\n\n if (hooks?.beforeSubscriptionEventEmit) {\n beforeExecuteSubscriptionEvenEmitHook =\n invokeBeforeSubscriptionEventEmitHook(perEventContext, payload);\n\n if (beforeExecuteSubscriptionEvenEmitHook instanceof GraphQLError) {\n return buildResponse(perEventContext, null) as TotalExecutionResult;\n }\n }\n try {\n const data = isPromise(beforeExecuteSubscriptionEvenEmitHook)\n ? beforeExecuteSubscriptionEvenEmitHook.then((context) => {\n if (context instanceof GraphQLError) {\n return null;\n }\n\n return executeFields(\n exeContext.enablePerEventContext\n ? perEventContext\n : exeContext,\n parentTypeName,\n payload,\n path,\n groupedFieldSet,\n undefined,\n );\n })\n : executeFields(\n exeContext.enablePerEventContext ? perEventContext : exeContext,\n parentTypeName,\n payload,\n path,\n groupedFieldSet,\n undefined,\n );\n // This is typechecked in collect values\n return buildResponse(perEventContext, data) as TotalExecutionResult;\n } catch (error) {\n perEventContext.errors.push(error as GraphQLError);\n return buildResponse(perEventContext, null) as TotalExecutionResult;\n }\n };\n\n return mapAsyncIterator(resultOrStreamOrPromise, mapSourceToResponse);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function buildResolveInfo(\n exeContext: ExecutionContext,\n fieldName: string,\n fieldGroup: FieldGroup,\n parentTypeName: string,\n returnTypeName: string,\n path: Path,\n): ResolveInfo {\n // The resolve function's optional fourth argument is a collection of\n // information about the current execution state.\n return {\n fieldName: fieldName,\n fieldNodes: fieldGroup,\n returnTypeName,\n parentTypeName,\n path,\n fragments: exeContext.fragments,\n rootValue: exeContext.rootValue,\n operation: exeContext.operation,\n variableValues: exeContext.variableValues,\n };\n}\n\nfunction handleFieldError(\n rawError: unknown,\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference | undefined,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): void {\n const error = locatedError(rawError, fieldGroup, pathToArray(path));\n\n // If the field type is non-nullable, then it is resolved without any\n // protection from errors, however it still properly locates the error.\n if (returnTypeRef && isNonNullType(returnTypeRef)) {\n throw error;\n }\n\n const errors = incrementalDataRecord?.errors ?? exeContext.errors;\n\n // Otherwise, error protection is applied, logging the error and resolving\n // a null value for this field if one is encountered.\n errors.push(error);\n}\n\nfunction handleMissingSchemaError(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference | undefined,\n fieldGroup: FieldGroup,\n path: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n) {\n const parentTypeName = path.typename;\n // subscriptions have separate execution flow in executeSubscriptionImpl\n const isRootField =\n parentTypeName === \"Mutation\" || parentTypeName === \"Query\";\n if (!isRootField) {\n return;\n }\n\n const fieldName = path.key;\n const message = !returnTypeRef\n ? `Type definition for ${parentTypeName}.${fieldName} is missing`\n : `Resolver for ${parentTypeName}.${fieldName} is missing`;\n const error = new Error(message);\n\n handleFieldError(\n error,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n}\n\nfunction resolveAndCompleteField(\n exeContext: ExecutionContext,\n parentTypeName: string,\n fieldDefinition: FieldDefinition,\n fieldGroup: FieldGroup,\n path: Path,\n source: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n const fieldName = fieldGroup[0].name.value;\n const returnTypeRef = Definitions.getFieldTypeReference(fieldDefinition);\n\n const resolveFn: FunctionFieldResolver<unknown, unknown> =\n Resolvers.getFieldResolver(\n exeContext.schemaFragment,\n parentTypeName,\n fieldName,\n ) ?? exeContext.fieldResolver;\n\n const info = buildResolveInfo(\n exeContext,\n fieldName,\n fieldGroup,\n parentTypeName,\n typeNameFromReference(returnTypeRef),\n path,\n );\n\n const isDefaultResolverUsed =\n resolveFn === exeContext.fieldResolver || fieldName === \"__typename\";\n\n if (resolveFn === exeContext.fieldResolver && typeof source === \"undefined\") {\n /**\n * Resolving a root field with default resolver makes operation look succsessful, even though nothing was actually done.\n * This leads to problems that are hard to debug, especially for mutations.\n *\n * NOTE1: executing Mutation.__typename or Query.__typename with default resolver is fine\n * NOTE2: source check is required to account for systems like Grats that work exclusively on default resolvers\n */\n handleMissingSchemaError(\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n }\n\n const hooks = exeContext.fieldExecutionHooks;\n let hookContext: unknown = undefined;\n\n // the resolve function, regardless of if its result is normal or abrupt (error).\n try {\n // Build a JS object of arguments from the field.arguments AST, using the\n // variables scope to fulfill any variable references.\n // TODO: find a way to memoize, in case this field is within a List type.\n const args = getArgumentValues(exeContext, fieldDefinition, fieldGroup[0]);\n\n // The resolve function's optional third argument is a context value that\n // is provided to every resolve function within an execution. It is commonly\n // used to represent an authenticated user, or request-specific caches.\n const contextValue = exeContext.contextValue;\n\n if (!isDefaultResolverUsed && hooks?.beforeFieldResolve) {\n hookContext = invokeBeforeFieldResolveHook(info, exeContext);\n }\n\n let result: unknown;\n\n if (hookContext instanceof GraphQLError) {\n result = null;\n } else if (isPromise(hookContext)) {\n result = hookContext.then((context) => {\n hookContext = context;\n\n if (hookContext instanceof GraphQLError) {\n return null;\n }\n\n return resolveFn(source, args, contextValue, info);\n });\n } else {\n result = resolveFn(source, args, contextValue, info);\n }\n\n let completed;\n\n if (isPromise(result)) {\n completed = result\n .then((resolved) => {\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n resolved,\n );\n return hookContext instanceof GraphQLError ? null : resolved;\n }\n\n return resolved;\n })\n .then(\n (resolved) => {\n return completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n hookContext instanceof GraphQLError ? null : resolved,\n incrementalDataRecord,\n );\n },\n (rawError) => {\n // That's where afterResolve hook can only be called\n // in the case of async resolver promise rejection.\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n undefined,\n rawError,\n );\n }\n // Error will be handled on field completion\n throw rawError;\n },\n );\n } else {\n if (!isDefaultResolverUsed && hooks?.afterFieldResolve) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n result,\n );\n result = hookContext instanceof GraphQLError ? null : result;\n }\n\n completed = completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n if (isPromise(completed)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n return completed.then(\n (resolved) => {\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n resolved,\n );\n return hookContext instanceof GraphQLError ? null : resolved;\n }\n\n return resolved;\n },\n (rawError) => {\n const error = locatedError(rawError, fieldGroup, pathToArray(path));\n\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return null;\n },\n );\n }\n\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n hookContext = invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n completed,\n );\n\n return hookContext instanceof GraphQLError ? null : completed;\n }\n return completed;\n } catch (rawError) {\n const pathArray = pathToArray(path);\n const error = locatedError(rawError, fieldGroup, pathArray);\n // Do not invoke afterFieldResolve hook when error path and current field path are not equal:\n // it means that field itself resolved fine (so afterFieldResolve has been invoked already),\n // but non-nullable child field resolving throws an error,\n // so that error is propagated to the parent field according to spec\n if (\n !isDefaultResolverUsed &&\n hooks?.afterFieldResolve &&\n error.path &&\n arraysAreEqual(pathArray, error.path)\n ) {\n hookContext = invokeAfterFieldResolveHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n if (!isDefaultResolverUsed && hooks?.afterFieldComplete) {\n invokeAfterFieldCompleteHook(\n info,\n exeContext,\n hookContext,\n undefined,\n error,\n );\n }\n\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n return null;\n }\n}\n\n/**\n * Implements the instructions for completeValue as defined in the\n * \"Field entries\" section of the spec.\n *\n * If the field type is Non-Null, then this recursively completes the value\n * for the inner type. It throws a field error if that completion returns null,\n * as per the \"Nullability\" section of the spec.\n *\n * If the field type is a List, then this recursively completes the value\n * for the inner type on each item in the list.\n *\n * If the field type is a Scalar or Enum, ensures the completed value is a legal\n * value of the type by calling the `serialize` method of GraphQL type\n * definition.\n *\n * If the field is an abstract type, determine the runtime type of the value\n * and then complete based on that type\n *\n * Otherwise, the field type expects a sub-selection set, and will complete the\n * value by executing all sub-selections.\n */\nfunction completeValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<unknown> {\n // If result is an Error, throw a located error.\n if (result instanceof Error) {\n throw result;\n }\n\n // If field type is NonNull, complete for inner type, and throw field error\n // if result is null.\n if (isNonNullType(returnTypeRef)) {\n const completed = completeValue(\n exeContext,\n unwrap(returnTypeRef),\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n if (completed === null) {\n throw new Error(\n `Cannot return null for non-nullable field ${info.parentTypeName}.${info.fieldName}.`,\n );\n }\n return completed;\n }\n\n // If result value is null or undefined then return null.\n if (result == null) {\n return null;\n }\n\n // If field type is List, complete each item in the list with the inner type\n if (isListType(returnTypeRef)) {\n return completeListValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n const { schemaFragment } = exeContext;\n const returnTypeName = typeNameFromReference(returnTypeRef);\n\n // If field type is a leaf type, Scalar or Enum, serialize to a valid value,\n // returning null if serialization is not possible.\n const leafType = Resolvers.getLeafTypeResolver(schemaFragment, returnTypeRef);\n if (leafType) {\n return completeLeafValue(leafType, result);\n }\n\n // If field type is an abstract type, Interface or Union, determine the\n // runtime Object type and complete for that type.\n if (Definitions.isAbstractType(schemaFragment.definitions, returnTypeRef)) {\n return completeAbstractValue(\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n // If field type is Object, execute and complete all sub-selections.\n // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')\n if (Definitions.isObjectType(schemaFragment.definitions, returnTypeRef)) {\n return completeObjectValue(\n exeContext,\n returnTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n }\n\n // istanbul ignore next (Not reachable. All possible output types have been considered)\n invariant(\n false,\n \"Cannot complete value of unexpected output type: \" +\n inspectTypeReference(returnTypeRef),\n );\n}\n\nasync function completePromisedValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: Promise<unknown>,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): Promise<unknown> {\n try {\n const resolved = await result;\n let completed = completeValue(\n exeContext,\n returnTypeRef,\n fieldGroup,\n info,\n path,\n resolved,\n incrementalDataRecord,\n );\n if (isPromise(completed)) {\n completed = await completed;\n }\n return completed;\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n returnTypeRef,\n fieldGroup,\n path,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n }\n}\n\n/**\n * Complete a list value by completing each item in the list with the\n * inner type\n */\nfunction completeListValue(\n exeContext: ExecutionContext,\n returnTypeRef: TypeReference, // assuming list type\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ReadonlyArray<unknown>> {\n const itemTypeRef = unwrap(returnTypeRef);\n if (isAsyncIterable(result)) {\n const asyncIterator = result[Symbol.asyncIterator]();\n\n return completeAsyncIteratorValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n path,\n asyncIterator,\n incrementalDataRecord,\n );\n }\n\n if (!isIterableObject(result)) {\n throw locatedError(\n `Expected Iterable, but did not find one for field \"${info.parentTypeName}.${info.fieldName}\".`,\n [],\n );\n }\n\n const stream = getStreamValues(exeContext, fieldGroup, path);\n\n // This is specified as a simple map, however we're optimizing the path\n // where the list contains no Promises by avoiding creating another Promise.\n let containsPromise = false;\n let previousIncrementalDataRecord = incrementalDataRecord;\n const completedResults: Array<unknown> = [];\n let index = 0;\n for (const item of result) {\n // No need to modify the info object containing the path,\n // since from here on it is not ever accessed by resolver functions.\n const itemPath = addPath(path, index, undefined);\n\n if (\n stream &&\n typeof stream.initialCount === \"number\" &&\n index >= stream.initialCount\n ) {\n previousIncrementalDataRecord = executeStreamField(\n path,\n itemPath,\n item,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n stream.label,\n previousIncrementalDataRecord,\n );\n index++;\n continue;\n }\n\n if (\n completeListItemValue(\n item,\n completedResults,\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n incrementalDataRecord,\n )\n ) {\n containsPromise = true;\n }\n\n index++;\n }\n\n return containsPromise ? Promise.all(completedResults) : completedResults;\n}\n\n/**\n * Complete a list item value by adding it to the completed results.\n *\n * Returns true if the value is a Promise.\n */\nfunction completeListItemValue(\n item: unknown,\n completedResults: Array<unknown>,\n exeContext: ExecutionContext,\n itemTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemPath: Path,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): boolean {\n if (isPromise(item)) {\n completedResults.push(\n completePromisedValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n ),\n );\n\n return true;\n }\n\n try {\n const completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n\n if (isPromise(completedItem)) {\n // Note: we don't rely on a `catch` method, but we do expect \"thenable\"\n // to take a second callback for the error case.\n completedResults.push(\n completedItem.then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n }),\n );\n\n return true;\n }\n\n completedResults.push(completedItem);\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n completedResults.push(null);\n }\n\n return false;\n}\n\n/**\n * Returns an object containing the `@stream` arguments if a field should be\n * streamed based on the experimental flag, stream directive present and\n * not disabled by the \"if\" argument.\n */\nfunction getStreamValues(\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n path: Path,\n):\n | undefined\n | {\n initialCount: number | undefined;\n label: string | undefined;\n } {\n // do not stream inner lists of multi-dimensional lists\n if (typeof path.key === \"number\") {\n return;\n }\n\n // validation only allows equivalent streams on multiple fields, so it is\n // safe to only check the first fieldNode for the stream directive\n const stream = getDirectiveValues(\n exeContext,\n GraphQLStreamDirective,\n fieldGroup[0],\n );\n\n if (!stream) {\n return;\n }\n\n if (stream.if === false) {\n return;\n }\n\n invariant(\n typeof stream.initialCount === \"number\",\n \"initialCount must be a number\",\n );\n\n invariant(\n stream.initialCount >= 0,\n \"initialCount must be a positive integer\",\n );\n\n invariant(\n exeContext.operation.operation !== \"subscription\",\n \"`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.\",\n );\n\n return {\n initialCount: stream.initialCount,\n label: typeof stream.label === \"string\" ? stream.label : undefined,\n };\n}\n\n/**\n * Complete a async iterator value by completing the result and calling\n * recursively until all the results are completed.\n */\nasync function completeAsyncIteratorValue(\n exeContext: ExecutionContext,\n itemTypeRef: TypeReference,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n asyncIterator: AsyncIterator<unknown>,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): Promise<ReadonlyArray<unknown>> {\n const stream = getStreamValues(exeContext, fieldGroup, path);\n let containsPromise = false;\n const completedResults: Array<unknown> = [];\n let index = 0;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (\n stream &&\n typeof stream.initialCount === \"number\" &&\n index >= stream.initialCount\n ) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n executeStreamAsyncIterator(\n index,\n asyncIterator,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n path,\n stream.label,\n incrementalDataRecord,\n );\n break;\n }\n\n const itemPath = addPath(path, index, undefined);\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await asyncIterator.next();\n if (iteration.done) {\n break;\n }\n } catch (rawError) {\n throw locatedError(rawError, fieldGroup, pathToArray(path));\n }\n\n if (\n completeListItemValue(\n iteration.value,\n completedResults,\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n incrementalDataRecord,\n )\n ) {\n containsPromise = true;\n }\n index += 1;\n }\n return containsPromise ? Promise.all(completedResults) : completedResults;\n}\n\n/**\n * Complete a Scalar or Enum by serializing to a valid value, returning\n * null if serialization is not possible.\n */\nfunction completeLeafValue(\n returnType: GraphQLLeafType,\n result: unknown,\n): unknown {\n const serializedResult = returnType.serialize(result);\n if (serializedResult === undefined) {\n throw new Error(\n `Expected a value of type \"${inspect(returnType)}\" but ` +\n `received: ${inspect(result)}`,\n );\n }\n return serializedResult;\n}\n\n/**\n * Complete a value of an abstract type by determining the runtime object type\n * of that value, then complete the value for that type.\n */\nfunction completeAbstractValue(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n const { schemaFragment } = exeContext;\n const resolveTypeFn =\n Resolvers.getAbstractTypeResolver(schemaFragment, returnTypeName) ??\n exeContext.typeResolver;\n const contextValue = exeContext.contextValue;\n const runtimeTypeName = resolveTypeFn(result, contextValue, info);\n\n const validatedRuntimeTypeName = isPromise(runtimeTypeName)\n ? runtimeTypeName.then((resolvedRuntimeTypeName) =>\n ensureValidRuntimeType(\n resolvedRuntimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n result,\n ),\n )\n : ensureValidRuntimeType(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n info,\n result,\n );\n\n if (isPromise(validatedRuntimeTypeName)) {\n return validatedRuntimeTypeName.then((resolvedRuntimeTypeName) =>\n completeObjectValue(\n exeContext,\n resolvedRuntimeTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n ),\n );\n }\n\n return completeObjectValue(\n exeContext,\n validatedRuntimeTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n}\n\nfunction ensureValidRuntimeType(\n runtimeTypeName: unknown,\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n result: unknown,\n): PromiseOrValue<string> {\n if (runtimeTypeName == null) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" must resolve to an Object type at runtime for field \"${info.parentTypeName}.${info.fieldName}\".` +\n ` Either the \"${returnTypeName}\" should provide a \"__resolveType\" resolver function` +\n ` or \"${info.parentTypeName}.${info.fieldName}\" should be an object with \"__typename\" property.`,\n fieldGroup,\n );\n }\n\n if (typeof runtimeTypeName !== \"string\") {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" must resolve to an Object type at runtime for field \"${info.returnTypeName}.${info.fieldName}\" with ` +\n `value ${inspect(result)}, received \"${inspect(runtimeTypeName)}\".`,\n [],\n );\n }\n\n // Presence of schema fragment loader triggers strict checks for interface types\n // (assuming we can get full information about interface implementations on demand)\n const strictInterfaceValidation = !!exeContext.schemaFragmentLoader;\n\n const isDefinedType = Definitions.isDefined(\n exeContext.schemaFragment.definitions,\n runtimeTypeName,\n );\n const loading = !isDefinedType\n ? requestSchemaFragment(exeContext, {\n kind: \"RuntimeType\",\n abstractTypeName: returnTypeName,\n runtimeTypeName,\n })\n : undefined;\n return loading\n ? loading.then(() =>\n ensureValidRuntimeTypeImpl(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n strictInterfaceValidation,\n ),\n )\n : ensureValidRuntimeTypeImpl(\n runtimeTypeName,\n exeContext,\n returnTypeName,\n fieldGroup,\n strictInterfaceValidation,\n );\n}\n\nfunction ensureValidRuntimeTypeImpl(\n runtimeTypeName: string,\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n strictInterfaceValidation: boolean,\n): string {\n const definitions = exeContext.schemaFragment.definitions;\n\n const union = Definitions.getUnionType(definitions, returnTypeName);\n if (union || strictInterfaceValidation) {\n // Standard graphql-js checks\n if (!Definitions.isDefined(definitions, runtimeTypeName)) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a type \"${runtimeTypeName}\" that does not exist inside the schema.`,\n fieldGroup,\n );\n }\n if (!Definitions.isObjectType(definitions, runtimeTypeName)) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n fieldGroup,\n );\n }\n if (!Definitions.isSubType(definitions, returnTypeName, runtimeTypeName)) {\n throw locatedError(\n `Runtime Object type \"${runtimeTypeName}\" is not a possible type for \"${returnTypeName}\".`,\n fieldGroup,\n );\n }\n return runtimeTypeName;\n }\n\n const iface = Definitions.getInterfaceType(definitions, returnTypeName);\n if (iface) {\n // Loose interface validation mode, significant deviation from graphql-js:\n // Assuming runtimeTypeName is a valid implementation of returnTypeName.\n if (\n Definitions.isDefined(definitions, runtimeTypeName) &&\n !Definitions.isObjectType(definitions, runtimeTypeName)\n ) {\n throw locatedError(\n `Abstract type \"${returnTypeName}\" was resolved to a non-object type \"${runtimeTypeName}\".`,\n fieldGroup,\n );\n }\n Definitions.addInterfaceImplementation(\n definitions,\n returnTypeName,\n runtimeTypeName,\n );\n return runtimeTypeName;\n }\n\n invariant(false, `${returnTypeName} is not an abstract type`);\n}\n\n/**\n * Complete an Object value by executing all sub-selections.\n */\nfunction completeObjectValue(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n // Collect sub-fields to execute to complete this value.\n return collectAndExecuteSubfields(\n exeContext,\n returnTypeName,\n fieldGroup,\n path,\n result,\n incrementalDataRecord,\n );\n}\n\nfunction collectAndExecuteSubfields(\n exeContext: ExecutionContext,\n returnTypeName: string,\n fieldGroup: FieldGroup,\n path: Path,\n result: unknown,\n incrementalDataRecord: IncrementalDataRecord | undefined,\n): PromiseOrValue<ObjMap<unknown>> {\n // Collect sub-fields to execute to complete this value.\n const { groupedFieldSet: subGroupedFieldSet, patches: subPatches } =\n collectSubfields(exeContext, { name: returnTypeName }, fieldGroup);\n\n const subFields = executeFields(\n exeContext,\n returnTypeName,\n result,\n path,\n subGroupedFieldSet,\n incrementalDataRecord,\n );\n\n for (const subPatch of subPatches) {\n const { label, groupedFieldSet: subPatchGroupedFieldSet } = subPatch;\n executeDeferredFragment(\n exeContext,\n returnTypeName,\n result,\n subPatchGroupedFieldSet,\n label,\n path,\n incrementalDataRecord,\n );\n }\n\n return subFields;\n}\n\nfunction invokeBeforeFieldSubscribeHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeFieldSubscribe;\n if (!hook) {\n return;\n }\n\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by beforeFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from beforeFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeFieldResolveHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeFieldResolve;\n if (!hook) {\n return;\n }\n\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by beforeFieldResolve hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from beforeFieldResolve hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldResolveHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldResolve;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldResolve hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldResolve hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldSubscribeHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldSubscribe;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldSubscribe hook\",\n );\n exeContext.errors.push(error);\n\n throw error;\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterFieldCompleteHook(\n resolveInfo: ResolveInfo,\n exeContext: ExecutionContext,\n hookContext: unknown,\n result?: unknown,\n error?: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterFieldComplete;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n resolveInfo,\n context: exeContext.contextValue,\n hookContext,\n result,\n error,\n }),\n (result, rawError) => {\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n resolveInfo.path,\n \"Unexpected error thrown by afterFieldComplete hook\",\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n resolveInfo.path,\n \"Unexpected error returned from afterFieldComplete hook\",\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeOperationExecuteHook(exeContext: ExecutionContext) {\n const hook = exeContext.fieldExecutionHooks?.beforeOperationExecute;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by beforeOperationExecute hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n }\n\n if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from beforeOperationExecute hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeBeforeSubscriptionEventEmitHook(\n exeContext: ExecutionContext,\n eventPayload: unknown,\n) {\n const hook = exeContext.fieldExecutionHooks?.beforeSubscriptionEventEmit;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n eventPayload,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by beforeSubscriptionEventEmit hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from beforeSubscriptionEventEmit hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n }\n\n return result;\n },\n );\n}\n\nfunction invokeAfterBuildResponseHook(\n exeContext: ExecutionContext,\n result: TotalExecutionResult,\n) {\n const hook = exeContext.fieldExecutionHooks?.afterBuildResponse;\n if (!hook) {\n return;\n }\n return executeSafe(\n () =>\n hook({\n context: exeContext.contextValue,\n operation: exeContext.operation,\n result,\n }),\n (result, rawError) => {\n const operationName = exeContext.operation.name?.value ?? \"unknown\";\n if (rawError) {\n const error = toGraphQLError(\n rawError,\n undefined,\n `Unexpected error thrown by afterBuildResponse hook (operation: ${operationName})`,\n );\n exeContext.errors.push(error);\n\n return error;\n } else if (result instanceof Error) {\n const error = toGraphQLError(\n result,\n undefined,\n `Unexpected error returned from afterBuildResponse hook (operation: ${operationName})`,\n );\n\n exeContext.errors.push(error);\n }\n },\n );\n}\n\nfunction executeSafe<T>(\n execute: () => T | Promise<T>,\n onComplete: (result: T | undefined, error: unknown) => T | Promise<T>,\n): T | Promise<T> {\n let error: unknown;\n let result: T | Promise<T> | undefined;\n try {\n result = execute();\n } catch (e) {\n error = e;\n }\n\n if (!isPromise(result)) {\n return onComplete(result, error);\n }\n\n return result\n .then((hookResult) => {\n return onComplete(hookResult, error);\n })\n .catch((e) => {\n return onComplete(undefined, e);\n }) as Promise<T>;\n}\n\nfunction toGraphQLError(\n originalError: unknown,\n path: Path | undefined,\n prependMessage: string,\n): GraphQLError {\n const originalMessage =\n originalError instanceof Error\n ? originalError.message\n : inspect(originalError);\n const error = new Error(`${prependMessage}: ${originalMessage}`);\n return locatedError(error, undefined, path ? pathToArray(path) : undefined);\n}\n\n/**\n * If a resolveType function is not given, then a default resolve behavior is\n * used which attempts two strategies:\n *\n * First, See if the provided value has a `__typename` field defined, if so, use\n * that value as name of the resolved type.\n *\n * Otherwise, test each possible type for the abstract type by calling\n * isTypeOf for the object being coerced, returning the first type that matches.\n */\nexport const defaultTypeResolver: TypeResolver<unknown, unknown> = function (\n value,\n) {\n if (isObjectLike(value) && typeof value.__typename === \"string\") {\n return value.__typename;\n }\n};\n\n/**\n * If a resolve function is not given, then a default resolve behavior is used\n * which takes the property of the source object of the same name as the field\n * and returns it as the result, or if it's a function, returns the result\n * of calling that function while passing along args and context value.\n */\nexport const defaultFieldResolver: FunctionFieldResolver<unknown, unknown> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function (source: any, args, contextValue, info) {\n // ensure source is a value for which property access is acceptable.\n if (isObjectLike(source) || typeof source === \"function\") {\n const property = source[info.fieldName];\n if (typeof property === \"function\") {\n return source[info.fieldName](args, contextValue, info);\n }\n return property;\n }\n };\n\nexport function getOperationRootTypeName(\n operation: OperationDefinitionNode | OperationTypeDefinitionNode,\n): string {\n switch (operation.operation) {\n case \"query\":\n return \"Query\";\n case \"mutation\":\n return \"Mutation\";\n case \"subscription\":\n return \"Subscription\";\n default:\n invariant(\n false,\n `Operation \"${operation.operation}\" is not a part of GraphQL spec`,\n );\n }\n}\n\nfunction executeDeferredFragment(\n exeContext: ExecutionContext,\n parentTypeName: string,\n sourceValue: unknown,\n fields: GroupedFieldSet,\n label?: string,\n path?: Path,\n parentContext?: IncrementalDataRecord,\n): void {\n const incrementalDataRecord = new DeferredFragmentRecord({\n label,\n path,\n parentContext,\n exeContext,\n });\n let promiseOrData;\n try {\n promiseOrData = executeFields(\n exeContext,\n parentTypeName,\n sourceValue,\n path,\n fields,\n incrementalDataRecord,\n );\n\n if (isPromise(promiseOrData)) {\n promiseOrData = promiseOrData.then(null, (e) => {\n incrementalDataRecord.errors.push(e);\n return null;\n });\n }\n } catch (e) {\n incrementalDataRecord.errors.push(e as GraphQLError);\n promiseOrData = null;\n }\n incrementalDataRecord.addData(promiseOrData);\n}\n\nfunction executeStreamField(\n path: Path,\n itemPath: Path,\n item: PromiseOrValue<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n label?: string,\n parentContext?: IncrementalDataRecord,\n): IncrementalDataRecord {\n const incrementalDataRecord = new StreamItemsRecord({\n label,\n path: itemPath,\n parentContext,\n exeContext,\n });\n if (isPromise(item)) {\n const completedItems = completePromisedValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n ).then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n\n incrementalDataRecord.addItems(completedItems);\n return incrementalDataRecord;\n }\n\n let completedItem: PromiseOrValue<unknown>;\n try {\n try {\n completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n completedItem = null;\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n }\n } catch (error) {\n incrementalDataRecord.errors.push(error as GraphQLError);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n incrementalDataRecord.addItems(null);\n return incrementalDataRecord;\n }\n\n if (isPromise(completedItem)) {\n const completedItems = completedItem\n .then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n })\n .then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n\n incrementalDataRecord.addItems(completedItems);\n return incrementalDataRecord;\n }\n\n incrementalDataRecord.addItems([completedItem]);\n return incrementalDataRecord;\n}\n\nasync function executeStreamAsyncIteratorItem(\n asyncIterator: AsyncIterator<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n incrementalDataRecord: StreamItemsRecord,\n path: Path,\n itemPath: Path,\n): Promise<IteratorResult<unknown>> {\n let item;\n try {\n const { value, done } = await asyncIterator.next();\n if (done) {\n incrementalDataRecord.setIsCompletedAsyncIterator();\n return { done, value: undefined };\n }\n item = value;\n } catch (rawError) {\n throw locatedError(rawError, fieldGroup, pathToArray(path));\n }\n let completedItem;\n try {\n completedItem = completeValue(\n exeContext,\n itemTypeRef,\n fieldGroup,\n info,\n itemPath,\n item,\n incrementalDataRecord,\n );\n\n if (isPromise(completedItem)) {\n completedItem = completedItem.then(undefined, (rawError) => {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return null;\n });\n }\n return { done: false, value: completedItem };\n } catch (rawError) {\n handleFieldError(\n rawError,\n exeContext,\n itemTypeRef,\n fieldGroup,\n itemPath,\n incrementalDataRecord,\n );\n filterSubsequentPayloads(exeContext, itemPath, incrementalDataRecord);\n return { done: false, value: null };\n }\n}\n\nasync function executeStreamAsyncIterator(\n initialIndex: number,\n asyncIterator: AsyncIterator<unknown>,\n exeContext: ExecutionContext,\n fieldGroup: FieldGroup,\n info: ResolveInfo,\n itemTypeRef: TypeReference,\n path: Path,\n label?: string,\n parentContext?: IncrementalDataRecord,\n): Promise<void> {\n let index = initialIndex;\n let previousIncrementalDataRecord = parentContext ?? undefined;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const itemPath = addPath(path, index, undefined);\n const incrementalDataRecord = new StreamItemsRecord({\n label,\n path: itemPath,\n parentContext: previousIncrementalDataRecord,\n asyncIterator,\n exeContext,\n });\n\n let iteration;\n try {\n // eslint-disable-next-line no-await-in-loop\n iteration = await executeStreamAsyncIteratorItem(\n asyncIterator,\n exeContext,\n fieldGroup,\n info,\n itemTypeRef,\n incrementalDataRecord,\n path,\n itemPath,\n );\n } catch (error) {\n incrementalDataRecord.errors.push(error as GraphQLError);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n incrementalDataRecord.addItems(null);\n // entire stream has errored and bubbled upwards\n if (asyncIterator?.return) {\n asyncIterator.return().catch(() => {\n // ignore errors\n });\n }\n return;\n }\n\n const { done, value: completedItem } = iteration;\n\n let completedItems: PromiseOrValue<Array<unknown> | null>;\n if (isPromise(completedItem)) {\n completedItems = completedItem.then(\n (value) => [value],\n (error) => {\n incrementalDataRecord.errors.push(error);\n filterSubsequentPayloads(exeContext, path, incrementalDataRecord);\n return null;\n },\n );\n } else {\n completedItems = [completedItem];\n }\n\n incrementalDataRecord.addItems(completedItems);\n\n if (done) {\n break;\n }\n previousIncrementalDataRecord = incrementalDataRecord;\n index++;\n }\n}\n\nfunction filterSubsequentPayloads(\n exeContext: ExecutionContext,\n nullPath: Path,\n currentIncrementalDataRecord: IncrementalDataRecord | undefined,\n): void {\n const nullPathArray = pathToArray(nullPath);\n exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {\n if (incrementalDataRecord === currentIncrementalDataRecord) {\n // don't remove payload from where error originates\n return;\n }\n for (let i = 0; i < nullPathArray.length; i++) {\n if (incrementalDataRecord.path[i] !== nullPathArray[i]) {\n // incrementalDataRecord points to a path unaffected by this payload\n return;\n }\n }\n // incrementalDataRecord path points to nulled error field\n if (\n isStreamItemsRecord(incrementalDataRecord) &&\n incrementalDataRecord.asyncIterator?.return\n ) {\n incrementalDataRecord.asyncIterator.return().catch(() => {\n // ignore error\n });\n }\n exeContext.subsequentPayloads.delete(incrementalDataRecord);\n });\n}\n\nfunction getCompletedIncrementalResults(\n exeContext: ExecutionContext,\n): Array<IncrementalResult> {\n const incrementalResults: Array<IncrementalResult> = [];\n for (const incrementalDataRecord of exeContext.subsequentPayloads) {\n const incrementalResult: IncrementalResult = {};\n if (!incrementalDataRecord.isCompleted) {\n continue;\n }\n exeContext.subsequentPayloads.delete(incrementalDataRecord);\n if (isStreamItemsRecord(incrementalDataRecord)) {\n const items = incrementalDataRecord.items;\n if (incrementalDataRecord.isCompletedAsyncIterator) {\n // async iterable resolver just finished but there may be pending payloads\n continue;\n }\n (incrementalResult as IncrementalStreamResult).items = items;\n } else {\n const data = incrementalDataRecord.data;\n (incrementalResult as IncrementalDeferResult).data = data ?? null;\n }\n\n incrementalResult.path = incrementalDataRecord.path;\n if (incrementalDataRecord.label != null) {\n incrementalResult.label = incrementalDataRecord.label;\n }\n if (incrementalDataRecord.errors.length > 0) {\n incrementalResult.errors = incrementalDataRecord.errors;\n }\n incrementalResults.push(incrementalResult);\n }\n return incrementalResults;\n}\n\nfunction yieldSubsequentPayloads(\n exeContext: ExecutionContext,\n): AsyncGenerator<SubsequentIncrementalExecutionResult, void, void> {\n let isDone = false;\n\n async function next(): Promise<\n IteratorResult<SubsequentIncrementalExecutionResult, void>\n > {\n if (isDone) {\n return { value: undefined, done: true };\n }\n\n await Promise.race(\n Array.from(exeContext.subsequentPayloads).map((p) => p.promise),\n );\n\n if (isDone) {\n // a different call to next has exhausted all payloads\n return { value: undefined, done: true };\n }\n\n const incremental = getCompletedIncrementalResults(exeContext);\n const hasNext = exeContext.subsequentPayloads.size > 0;\n\n if (!incremental.length && hasNext) {\n return next();\n }\n\n if (!hasNext) {\n isDone = true;\n }\n\n return {\n value: incremental.length ? { incremental, hasNext } : { hasNext },\n done: false,\n };\n }\n\n function returnStreamIterators() {\n const promises: Array<Promise<IteratorResult<unknown>>> = [];\n exeContext.subsequentPayloads.forEach((incrementalDataRecord) => {\n if (\n isStreamItemsRecord(incrementalDataRecord) &&\n incrementalDataRecord.asyncIterator?.return\n ) {\n promises.push(incrementalDataRecord.asyncIterator.return());\n }\n });\n return Promise.all(promises);\n }\n\n return {\n [Symbol.asyncIterator]() {\n return this;\n },\n next,\n async return(): Promise<\n IteratorResult<SubsequentIncrementalExecutionResult, void>\n > {\n await returnStreamIterators();\n isDone = true;\n return { value: undefined, done: true };\n },\n async throw(\n error?: unknown,\n ): Promise<IteratorResult<SubsequentIncrementalExecutionResult, void>> {\n await returnStreamIterators();\n isDone = true;\n return Promise.reject(error);\n },\n };\n}\n\nexport type IncrementalDataRecord = DeferredFragmentRecord | StreamItemsRecord;\n\nfunction isStreamItemsRecord(\n incrementalDataRecord: IncrementalDataRecord,\n): incrementalDataRecord is StreamItemsRecord {\n return incrementalDataRecord.type === \"stream\";\n}\n\nclass DeferredFragmentRecord {\n type: \"defer\";\n errors: Array<GraphQLError>;\n label: string | undefined;\n path: Array<string | number>;\n promise: Promise<void>;\n data: ObjMap<unknown> | null;\n parentContext: IncrementalDataRecord | undefined;\n isCompleted: boolean;\n _exeContext: ExecutionContext;\n _resolve?: (arg: PromiseOrValue<ObjMap<unknown> | null>) => void;\n\n constructor(opts: {\n label: string | undefined;\n path: Path | undefined;\n parentContext: IncrementalDataRecord | undefined;\n exeContext: ExecutionContext;\n }) {\n this.type = \"defer\";\n this.label = opts.label;\n this.path = pathToArray(opts.path);\n this.parentContext = opts.parentContext;\n this.errors = [];\n this._exeContext = opts.exeContext;\n this._exeContext.subsequentPayloads.add(this);\n this.isCompleted = false;\n this.data = null;\n this.promise = new Promise<ObjMap<unknown> | null>((resolve) => {\n this._resolve = (promiseOrValue) => {\n resolve(promiseOrValue);\n };\n }).then((data) => {\n this.data = data;\n this.isCompleted = true;\n });\n }\n\n addData(data: PromiseOrValue<ObjMap<unknown> | null>) {\n const parentData = this.parentContext?.promise;\n if (parentData) {\n this._resolve?.(parentData.then(() => data));\n return;\n }\n this._resolve?.(data);\n }\n}\n\nclass StreamItemsRecord {\n type: \"stream\";\n errors: Array<GraphQLError>;\n label: string | undefined;\n path: Array<string | number>;\n items: Array<unknown> | null;\n promise: Promise<void>;\n parentContext: IncrementalDataRecord | undefined;\n asyncIterator: AsyncIterator<unknown> | undefined;\n isCompletedAsyncIterator?: boolean;\n isCompleted: boolean;\n _exeContext: ExecutionContext;\n _resolve?: (arg: PromiseOrValue<Array<unknown> | null>) => void;\n\n constructor(opts: {\n label: string | undefined;\n path: Path | undefined;\n asyncIterator?: AsyncIterator<unknown>;\n parentContext: IncrementalDataRecord | undefined;\n exeContext: ExecutionContext;\n }) {\n this.type = \"stream\";\n this.items = null;\n this.label = opts.label;\n this.path = pathToArray(opts.path);\n this.parentContext = opts.parentContext;\n this.asyncIterator = opts.asyncIterator;\n this.errors = [];\n this._exeContext = opts.exeContext;\n this._exeContext.subsequentPayloads.add(this);\n this.isCompleted = false;\n this.items = null;\n this.promise = new Promise<Array<unknown> | null>((resolve) => {\n this._resolve = (promiseOrValue) => {\n resolve(promiseOrValue);\n };\n }).then((items) => {\n this.items = items;\n this.isCompleted = true;\n });\n }\n\n addItems(items: PromiseOrValue<Array<unknown> | null>) {\n const parentData = this.parentContext?.promise;\n if (parentData) {\n this._resolve?.(parentData.then(() => items));\n return;\n }\n this._resolve?.(items);\n }\n\n setIsCompletedAsyncIterator() {\n this.isCompletedAsyncIterator = true;\n }\n}\n\nexport function isIncrementalExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n>(\n result: ExecutionResult<TData, TExtensions>,\n): result is IncrementalExecutionResult<TData, TExtensions> {\n return \"initialResult\" in result;\n}\n\nexport function isTotalExecutionResult<\n TData = ObjMap<unknown>,\n TExtensions = ObjMap<unknown>,\n>(\n result: ExecutionResult<TData, TExtensions>,\n): result is TotalExecutionResult<TData, TExtensions> {\n return !(\"initialResult\" in result);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBASO;AACP,2BAKO;AACP,uBAA0B;AAC1B,qBAAwB;AACxB,uBAA0B;AAC1B,8BAAiC;AACjC,0BAA6B;AAC7B,uBAA0B;AAI1B,kBAAqC;AACrC,8BAAiC;AAEjC,2BAA8B;AAiB9B,oBAIO;AAEP,mBAA+B;AAC/B,6BAAgC;AAChC,8BAAiC;AACjC,wBAAuC;AACvC,sBAAyB;AACzB,uBAMO;AAGP,k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