graphql
Version:
A Query Language and Runtime which can target any service.
1 lines • 5.26 kB
Source Map (JSON)
{"version":3,"file":"ExecutorThrowingOnIncremental.js","sourceRoot":"","sources":["../../src/execution/ExecutorThrowingOnIncremental.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AAKpD,OAAO,EAAE,iBAAiB,EAAE,4BAA2B;AAcvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAsB;AAEzD,MAAM,4BAA4B,GAChC,oHAAoH,CAAC;AAGvH,MAAM,OAAO,6BAA8B,SAAQ,QAAQ;IAChD,0BAA0B,CACjC,QAA2B,EAC3B,SAAkB,EAClB,uBAAwC,EACxC,QAAiB,EACjB,cAAyC;QAEzC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;kBAE5B,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,SAAS;gBAC7C,iBAAiB,CAAC,YAAY;gBAFlC,SAAS,QAGP,wHAAwH;YAE1H,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACvD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,MAAM,MAAM,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,0BAA0B,CACpC,QAAQ,EACR,SAAS,EACT,uBAAuB,EACvB,QAAQ,EACR,SAAS,CACV,CAAC;IACJ,CAAC;IAEQ,yBAAyB,CAChC,UAA6B,EAC7B,WAAoB,EACpB,IAAsB,EACtB,uBAAwC,EACxC,cAAyC;QAEzC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;kBAE5B,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,SAAS;gBAC7C,iBAAiB,CAAC,YAAY;gBAFlC,SAAS,QAGP,wHAAwH;YAE1H,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACvD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,MAAM,MAAM,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CACvB,UAAU,EACV,WAAW,EACX,IAAI,EACJ,uBAAuB,EACvB,SAAS,CACV,CAAC;IACJ,CAAC;IAGQ,iBAAiB,CACxB,UAA0C,EAC1C,gBAAkC,EAClC,IAAwB,EACxB,IAAU,EACV,MAAe,EACf,eAA0B;QAE1B,MAAM,WAAW,GAAG,cAAc,CAChC,IAAI,CAAC,sBAAsB,EAC3B,gBAAgB,CACjB,CAAC;QACF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;kBAE5B,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,SAAS;gBAC7C,iBAAiB,CAAC,YAAY;gBAFlC,SAAS,QAGP,0HAA0H;YAG5H,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YACvD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,MAAM,MAAM,CAAC;QACf,CAAC;QAED,OAAO,KAAK,CAAC,iBAAiB,CAC5B,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,eAAe,CAChB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { invariant } from '../jsutils/invariant.ts';\nimport type { ObjMap } from '../jsutils/ObjMap.ts';\nimport type { Path } from '../jsutils/Path.ts';\nimport type { PromiseOrValue } from '../jsutils/PromiseOrValue.ts';\n\nimport { OperationTypeNode } from '../language/ast.ts';\n\nimport type {\n GraphQLList,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n} from '../type/index.ts';\n\nimport type {\n DeferUsage,\n FieldDetailsList,\n GroupedFieldSet,\n} from './collectFields.ts';\nimport { Executor, getStreamUsage } from './Executor.ts';\n\nconst UNEXPECTED_MULTIPLE_PAYLOADS =\n 'Executing this GraphQL operation would unexpectedly produce multiple payloads (due to @defer or @stream directive)';\n\n/** @internal */\nexport class ExecutorThrowingOnIncremental extends Executor {\n override executeCollectedRootFields(\n rootType: GraphQLObjectType,\n rootValue: unknown,\n originalGroupedFieldSet: GroupedFieldSet,\n serially: boolean,\n newDeferUsages: ReadonlyArray<DeferUsage>,\n ): PromiseOrValue<ObjMap<unknown>> {\n if (newDeferUsages.length > 0) {\n invariant(\n this.validatedExecutionArgs.operation.operation !==\n OperationTypeNode.SUBSCRIPTION,\n '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n );\n const reason = new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n this.abort(reason);\n throw reason;\n }\n return this.executeRootGroupedFieldSet(\n rootType,\n rootValue,\n originalGroupedFieldSet,\n serially,\n undefined,\n );\n }\n\n override executeCollectedSubfields(\n parentType: GraphQLObjectType,\n sourceValue: unknown,\n path: Path | undefined,\n originalGroupedFieldSet: GroupedFieldSet,\n newDeferUsages: ReadonlyArray<DeferUsage>,\n ): PromiseOrValue<ObjMap<unknown>> {\n if (newDeferUsages.length > 0) {\n invariant(\n this.validatedExecutionArgs.operation.operation !==\n OperationTypeNode.SUBSCRIPTION,\n '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.',\n );\n const reason = new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n this.abort(reason);\n throw reason;\n }\n\n return this.executeFields(\n parentType,\n sourceValue,\n path,\n originalGroupedFieldSet,\n undefined,\n );\n }\n\n // eslint-disable-next-line max-params\n override completeListValue(\n returnType: GraphQLList<GraphQLOutputType>,\n fieldDetailsList: FieldDetailsList,\n info: GraphQLResolveInfo,\n path: Path,\n result: unknown,\n positionContext: undefined,\n ): PromiseOrValue<ReadonlyArray<unknown>> {\n const streamUsage = getStreamUsage(\n this.validatedExecutionArgs,\n fieldDetailsList,\n );\n if (streamUsage !== undefined) {\n invariant(\n this.validatedExecutionArgs.operation.operation !==\n OperationTypeNode.SUBSCRIPTION,\n '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.',\n );\n\n const reason = new Error(UNEXPECTED_MULTIPLE_PAYLOADS);\n this.abort(reason);\n throw reason;\n }\n\n return super.completeListValue(\n returnType,\n fieldDetailsList,\n info,\n path,\n result,\n positionContext,\n );\n }\n}\n"]}