@depup/apollo__server 5.5.0-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/changes.json +46 -0
- package/dist/cjs/ApolloServer.d.ts +126 -0
- package/dist/cjs/ApolloServer.d.ts.map +1 -0
- package/dist/cjs/ApolloServer.js +726 -0
- package/dist/cjs/ApolloServer.js.map +1 -0
- package/dist/cjs/cachePolicy.d.ts +3 -0
- package/dist/cjs/cachePolicy.d.ts.map +1 -0
- package/dist/cjs/cachePolicy.js +33 -0
- package/dist/cjs/cachePolicy.js.map +1 -0
- package/dist/cjs/determineApolloConfig.d.ts +4 -0
- package/dist/cjs/determineApolloConfig.d.ts.map +1 -0
- package/dist/cjs/determineApolloConfig.js +58 -0
- package/dist/cjs/determineApolloConfig.js.map +1 -0
- package/dist/cjs/errorNormalize.d.ts +12 -0
- package/dist/cjs/errorNormalize.d.ts.map +1 -0
- package/dist/cjs/errorNormalize.js +71 -0
- package/dist/cjs/errorNormalize.js.map +1 -0
- package/dist/cjs/errors/index.d.ts +16 -0
- package/dist/cjs/errors/index.d.ts.map +1 -0
- package/dist/cjs/errors/index.js +28 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/externalTypes/constructor.d.ts +78 -0
- package/dist/cjs/externalTypes/constructor.d.ts.map +1 -0
- package/dist/cjs/externalTypes/constructor.js +3 -0
- package/dist/cjs/externalTypes/constructor.js.map +1 -0
- package/dist/cjs/externalTypes/context.d.ts +4 -0
- package/dist/cjs/externalTypes/context.d.ts.map +1 -0
- package/dist/cjs/externalTypes/context.js +3 -0
- package/dist/cjs/externalTypes/context.js.map +1 -0
- package/dist/cjs/externalTypes/graphql.d.ts +41 -0
- package/dist/cjs/externalTypes/graphql.d.ts.map +1 -0
- package/dist/cjs/externalTypes/graphql.js +3 -0
- package/dist/cjs/externalTypes/graphql.js.map +1 -0
- package/dist/cjs/externalTypes/http.d.ts +22 -0
- package/dist/cjs/externalTypes/http.d.ts.map +1 -0
- package/dist/cjs/externalTypes/http.js +3 -0
- package/dist/cjs/externalTypes/http.js.map +1 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts +28 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts.map +1 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.js +3 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.js.map +1 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts +43 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts.map +1 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.js +3 -0
- package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.js.map +1 -0
- package/dist/cjs/externalTypes/index.d.ts +9 -0
- package/dist/cjs/externalTypes/index.d.ts.map +1 -0
- package/dist/cjs/externalTypes/index.js +3 -0
- package/dist/cjs/externalTypes/index.js.map +1 -0
- package/dist/cjs/externalTypes/plugins.d.ts +75 -0
- package/dist/cjs/externalTypes/plugins.d.ts.map +1 -0
- package/dist/cjs/externalTypes/plugins.js +3 -0
- package/dist/cjs/externalTypes/plugins.js.map +1 -0
- package/dist/cjs/externalTypes/requestPipeline.d.ts +50 -0
- package/dist/cjs/externalTypes/requestPipeline.d.ts.map +1 -0
- package/dist/cjs/externalTypes/requestPipeline.js +3 -0
- package/dist/cjs/externalTypes/requestPipeline.js.map +1 -0
- package/dist/cjs/generated/packageVersion.d.ts +2 -0
- package/dist/cjs/generated/packageVersion.d.ts.map +1 -0
- package/dist/cjs/generated/packageVersion.js +5 -0
- package/dist/cjs/generated/packageVersion.js.map +1 -0
- package/dist/cjs/httpBatching.d.ts +4 -0
- package/dist/cjs/httpBatching.d.ts.map +1 -0
- package/dist/cjs/httpBatching.js +58 -0
- package/dist/cjs/httpBatching.js.map +1 -0
- package/dist/cjs/incrementalDeliveryPolyfill.d.ts +82 -0
- package/dist/cjs/incrementalDeliveryPolyfill.d.ts.map +1 -0
- package/dist/cjs/incrementalDeliveryPolyfill.js +74 -0
- package/dist/cjs/incrementalDeliveryPolyfill.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/internalErrorClasses.d.ts +28 -0
- package/dist/cjs/internalErrorClasses.d.ts.map +1 -0
- package/dist/cjs/internalErrorClasses.js +91 -0
- package/dist/cjs/internalErrorClasses.js.map +1 -0
- package/dist/cjs/internalPlugin.d.ts +9 -0
- package/dist/cjs/internalPlugin.d.ts.map +1 -0
- package/dist/cjs/internalPlugin.js +11 -0
- package/dist/cjs/internalPlugin.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugin/cacheControl/index.d.ts +9 -0
- package/dist/cjs/plugin/cacheControl/index.d.ts.map +1 -0
- package/dist/cjs/plugin/cacheControl/index.js +223 -0
- package/dist/cjs/plugin/cacheControl/index.js.map +1 -0
- package/dist/cjs/plugin/disableSuggestions/index.d.ts +3 -0
- package/dist/cjs/plugin/disableSuggestions/index.d.ts.map +1 -0
- package/dist/cjs/plugin/disableSuggestions/index.js +22 -0
- package/dist/cjs/plugin/disableSuggestions/index.js.map +1 -0
- package/dist/cjs/plugin/disabled/index.d.ts +7 -0
- package/dist/cjs/plugin/disabled/index.d.ts.map +1 -0
- package/dist/cjs/plugin/disabled/index.js +30 -0
- package/dist/cjs/plugin/disabled/index.js.map +1 -0
- package/dist/cjs/plugin/drainHttpServer/index.d.ts +8 -0
- package/dist/cjs/plugin/drainHttpServer/index.d.ts.map +1 -0
- package/dist/cjs/plugin/drainHttpServer/index.js +19 -0
- package/dist/cjs/plugin/drainHttpServer/index.js.map +1 -0
- package/dist/cjs/plugin/drainHttpServer/stoppable.d.ts +10 -0
- package/dist/cjs/plugin/drainHttpServer/stoppable.d.ts.map +1 -0
- package/dist/cjs/plugin/drainHttpServer/stoppable.js +54 -0
- package/dist/cjs/plugin/drainHttpServer/stoppable.js.map +1 -0
- package/dist/cjs/plugin/inlineTrace/index.d.ts +8 -0
- package/dist/cjs/plugin/inlineTrace/index.d.ts.map +1 -0
- package/dist/cjs/plugin/inlineTrace/index.js +70 -0
- package/dist/cjs/plugin/inlineTrace/index.js.map +1 -0
- package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.d.ts +4 -0
- package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.d.ts.map +1 -0
- package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.js +143 -0
- package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.js.map +1 -0
- package/dist/cjs/plugin/landingPage/default/index.d.ts +9 -0
- package/dist/cjs/plugin/landingPage/default/index.d.ts.map +1 -0
- package/dist/cjs/plugin/landingPage/default/index.js +146 -0
- package/dist/cjs/plugin/landingPage/default/index.js.map +1 -0
- package/dist/cjs/plugin/landingPage/default/types.d.ts +56 -0
- package/dist/cjs/plugin/landingPage/default/types.d.ts.map +1 -0
- package/dist/cjs/plugin/landingPage/default/types.js +3 -0
- package/dist/cjs/plugin/landingPage/default/types.js.map +1 -0
- package/dist/cjs/plugin/schemaIsSubgraph.d.ts +3 -0
- package/dist/cjs/plugin/schemaIsSubgraph.d.ts.map +1 -0
- package/dist/cjs/plugin/schemaIsSubgraph.js +23 -0
- package/dist/cjs/plugin/schemaIsSubgraph.js.map +1 -0
- package/dist/cjs/plugin/schemaReporting/index.d.ts +10 -0
- package/dist/cjs/plugin/schemaReporting/index.d.ts.map +1 -0
- package/dist/cjs/plugin/schemaReporting/index.js +104 -0
- package/dist/cjs/plugin/schemaReporting/index.js.map +1 -0
- package/dist/cjs/plugin/schemaReporting/schemaReporter.d.ts +33 -0
- package/dist/cjs/plugin/schemaReporting/schemaReporter.d.ts.map +1 -0
- package/dist/cjs/plugin/schemaReporting/schemaReporter.js +147 -0
- package/dist/cjs/plugin/schemaReporting/schemaReporter.js.map +1 -0
- package/dist/cjs/plugin/subscriptionCallback/index.d.ts +12 -0
- package/dist/cjs/plugin/subscriptionCallback/index.d.ts.map +1 -0
- package/dist/cjs/plugin/subscriptionCallback/index.js +434 -0
- package/dist/cjs/plugin/subscriptionCallback/index.js.map +1 -0
- package/dist/cjs/plugin/traceTreeBuilder.d.ts +25 -0
- package/dist/cjs/plugin/traceTreeBuilder.d.ts.map +1 -0
- package/dist/cjs/plugin/traceTreeBuilder.js +201 -0
- package/dist/cjs/plugin/traceTreeBuilder.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts +3 -0
- package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.js +44 -0
- package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/durationHistogram.d.ts +16 -0
- package/dist/cjs/plugin/usageReporting/durationHistogram.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/durationHistogram.js +68 -0
- package/dist/cjs/plugin/usageReporting/durationHistogram.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/index.d.ts +3 -0
- package/dist/cjs/plugin/usageReporting/index.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/index.js +6 -0
- package/dist/cjs/plugin/usageReporting/index.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/iterateOverTrace.d.ts +7 -0
- package/dist/cjs/plugin/usageReporting/iterateOverTrace.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/iterateOverTrace.js +81 -0
- package/dist/cjs/plugin/usageReporting/iterateOverTrace.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.d.ts +12 -0
- package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.js +33 -0
- package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/options.d.ts +60 -0
- package/dist/cjs/plugin/usageReporting/options.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/options.js +3 -0
- package/dist/cjs/plugin/usageReporting/options.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/plugin.d.ts +7 -0
- package/dist/cjs/plugin/usageReporting/plugin.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/plugin.js +494 -0
- package/dist/cjs/plugin/usageReporting/plugin.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/stats.d.ts +96 -0
- package/dist/cjs/plugin/usageReporting/stats.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/stats.js +289 -0
- package/dist/cjs/plugin/usageReporting/stats.js.map +1 -0
- package/dist/cjs/plugin/usageReporting/traceDetails.d.ts +4 -0
- package/dist/cjs/plugin/usageReporting/traceDetails.d.ts.map +1 -0
- package/dist/cjs/plugin/usageReporting/traceDetails.js +63 -0
- package/dist/cjs/plugin/usageReporting/traceDetails.js.map +1 -0
- package/dist/cjs/preventCsrf.d.ts +4 -0
- package/dist/cjs/preventCsrf.d.ts.map +1 -0
- package/dist/cjs/preventCsrf.js +41 -0
- package/dist/cjs/preventCsrf.js.map +1 -0
- package/dist/cjs/requestPipeline.d.ts +9 -0
- package/dist/cjs/requestPipeline.d.ts.map +1 -0
- package/dist/cjs/requestPipeline.js +371 -0
- package/dist/cjs/requestPipeline.js.map +1 -0
- package/dist/cjs/runHttpQuery.d.ts +15 -0
- package/dist/cjs/runHttpQuery.d.ts.map +1 -0
- package/dist/cjs/runHttpQuery.js +230 -0
- package/dist/cjs/runHttpQuery.js.map +1 -0
- package/dist/cjs/standalone/index.d.ts +25 -0
- package/dist/cjs/standalone/index.d.ts.map +1 -0
- package/dist/cjs/standalone/index.js +97 -0
- package/dist/cjs/standalone/index.js.map +1 -0
- package/dist/cjs/utils/HeaderMap.d.ts +8 -0
- package/dist/cjs/utils/HeaderMap.d.ts.map +1 -0
- package/dist/cjs/utils/HeaderMap.js +20 -0
- package/dist/cjs/utils/HeaderMap.js.map +1 -0
- package/dist/cjs/utils/UnreachableCaseError.d.ts +4 -0
- package/dist/cjs/utils/UnreachableCaseError.d.ts.map +1 -0
- package/dist/cjs/utils/UnreachableCaseError.js +10 -0
- package/dist/cjs/utils/UnreachableCaseError.js.map +1 -0
- package/dist/cjs/utils/computeCoreSchemaHash.d.ts +2 -0
- package/dist/cjs/utils/computeCoreSchemaHash.d.ts.map +1 -0
- package/dist/cjs/utils/computeCoreSchemaHash.js +8 -0
- package/dist/cjs/utils/computeCoreSchemaHash.js.map +1 -0
- package/dist/cjs/utils/invokeHooks.d.ts +7 -0
- package/dist/cjs/utils/invokeHooks.d.ts.map +1 -0
- package/dist/cjs/utils/invokeHooks.js +36 -0
- package/dist/cjs/utils/invokeHooks.js.map +1 -0
- package/dist/cjs/utils/isDefined.d.ts +2 -0
- package/dist/cjs/utils/isDefined.d.ts.map +1 -0
- package/dist/cjs/utils/isDefined.js +7 -0
- package/dist/cjs/utils/isDefined.js.map +1 -0
- package/dist/cjs/utils/makeGatewayGraphQLRequestContext.d.ts +5 -0
- package/dist/cjs/utils/makeGatewayGraphQLRequestContext.d.ts.map +1 -0
- package/dist/cjs/utils/makeGatewayGraphQLRequestContext.js +96 -0
- package/dist/cjs/utils/makeGatewayGraphQLRequestContext.js.map +1 -0
- package/dist/cjs/utils/resolvable.d.ts +7 -0
- package/dist/cjs/utils/resolvable.d.ts.map +1 -0
- package/dist/cjs/utils/resolvable.js +14 -0
- package/dist/cjs/utils/resolvable.js.map +1 -0
- package/dist/cjs/utils/schemaInstrumentation.d.ts +16 -0
- package/dist/cjs/utils/schemaInstrumentation.d.ts.map +1 -0
- package/dist/cjs/utils/schemaInstrumentation.js +75 -0
- package/dist/cjs/utils/schemaInstrumentation.js.map +1 -0
- package/dist/cjs/utils/schemaManager.d.ts +31 -0
- package/dist/cjs/utils/schemaManager.d.ts.map +1 -0
- package/dist/cjs/utils/schemaManager.js +103 -0
- package/dist/cjs/utils/schemaManager.js.map +1 -0
- package/dist/cjs/utils/urlForHttpServer.d.ts +3 -0
- package/dist/cjs/utils/urlForHttpServer.d.ts.map +1 -0
- package/dist/cjs/utils/urlForHttpServer.js +15 -0
- package/dist/cjs/utils/urlForHttpServer.js.map +1 -0
- package/dist/cjs/validationRules/NoIntrospection.d.ts +3 -0
- package/dist/cjs/validationRules/NoIntrospection.d.ts.map +1 -0
- package/dist/cjs/validationRules/NoIntrospection.js +19 -0
- package/dist/cjs/validationRules/NoIntrospection.js.map +1 -0
- package/dist/cjs/validationRules/RecursiveSelectionsLimit.d.ts +4 -0
- package/dist/cjs/validationRules/RecursiveSelectionsLimit.d.ts.map +1 -0
- package/dist/cjs/validationRules/RecursiveSelectionsLimit.js +150 -0
- package/dist/cjs/validationRules/RecursiveSelectionsLimit.js.map +1 -0
- package/dist/cjs/validationRules/index.d.ts +3 -0
- package/dist/cjs/validationRules/index.d.ts.map +1 -0
- package/dist/cjs/validationRules/index.js +9 -0
- package/dist/cjs/validationRules/index.js.map +1 -0
- package/dist/esm/ApolloServer.d.ts +126 -0
- package/dist/esm/ApolloServer.d.ts.map +1 -0
- package/dist/esm/ApolloServer.js +683 -0
- package/dist/esm/ApolloServer.js.map +1 -0
- package/dist/esm/cachePolicy.d.ts +3 -0
- package/dist/esm/cachePolicy.d.ts.map +1 -0
- package/dist/esm/cachePolicy.js +30 -0
- package/dist/esm/cachePolicy.js.map +1 -0
- package/dist/esm/determineApolloConfig.d.ts +4 -0
- package/dist/esm/determineApolloConfig.d.ts.map +1 -0
- package/dist/esm/determineApolloConfig.js +55 -0
- package/dist/esm/determineApolloConfig.js.map +1 -0
- package/dist/esm/errorNormalize.d.ts +12 -0
- package/dist/esm/errorNormalize.d.ts.map +1 -0
- package/dist/esm/errorNormalize.js +66 -0
- package/dist/esm/errorNormalize.js.map +1 -0
- package/dist/esm/errors/index.d.ts +16 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/errors/index.js +24 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/externalTypes/constructor.d.ts +78 -0
- package/dist/esm/externalTypes/constructor.d.ts.map +1 -0
- package/dist/esm/externalTypes/constructor.js +2 -0
- package/dist/esm/externalTypes/constructor.js.map +1 -0
- package/dist/esm/externalTypes/context.d.ts +4 -0
- package/dist/esm/externalTypes/context.d.ts.map +1 -0
- package/dist/esm/externalTypes/context.js +2 -0
- package/dist/esm/externalTypes/context.js.map +1 -0
- package/dist/esm/externalTypes/graphql.d.ts +41 -0
- package/dist/esm/externalTypes/graphql.d.ts.map +1 -0
- package/dist/esm/externalTypes/graphql.js +2 -0
- package/dist/esm/externalTypes/graphql.js.map +1 -0
- package/dist/esm/externalTypes/http.d.ts +22 -0
- package/dist/esm/externalTypes/http.d.ts.map +1 -0
- package/dist/esm/externalTypes/http.js +2 -0
- package/dist/esm/externalTypes/http.js.map +1 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts +28 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts.map +1 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.js +2 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.js.map +1 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts +43 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts.map +1 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.js +2 -0
- package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.js.map +1 -0
- package/dist/esm/externalTypes/index.d.ts +9 -0
- package/dist/esm/externalTypes/index.d.ts.map +1 -0
- package/dist/esm/externalTypes/index.js +2 -0
- package/dist/esm/externalTypes/index.js.map +1 -0
- package/dist/esm/externalTypes/plugins.d.ts +75 -0
- package/dist/esm/externalTypes/plugins.d.ts.map +1 -0
- package/dist/esm/externalTypes/plugins.js +2 -0
- package/dist/esm/externalTypes/plugins.js.map +1 -0
- package/dist/esm/externalTypes/requestPipeline.d.ts +50 -0
- package/dist/esm/externalTypes/requestPipeline.d.ts.map +1 -0
- package/dist/esm/externalTypes/requestPipeline.js +2 -0
- package/dist/esm/externalTypes/requestPipeline.js.map +1 -0
- package/dist/esm/generated/packageVersion.d.ts +2 -0
- package/dist/esm/generated/packageVersion.d.ts.map +1 -0
- package/dist/esm/generated/packageVersion.js +2 -0
- package/dist/esm/generated/packageVersion.js.map +1 -0
- package/dist/esm/httpBatching.d.ts +4 -0
- package/dist/esm/httpBatching.d.ts.map +1 -0
- package/dist/esm/httpBatching.js +55 -0
- package/dist/esm/httpBatching.js.map +1 -0
- package/dist/esm/incrementalDeliveryPolyfill.d.ts +82 -0
- package/dist/esm/incrementalDeliveryPolyfill.d.ts.map +1 -0
- package/dist/esm/incrementalDeliveryPolyfill.js +38 -0
- package/dist/esm/incrementalDeliveryPolyfill.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internalErrorClasses.d.ts +28 -0
- package/dist/esm/internalErrorClasses.d.ts.map +1 -0
- package/dist/esm/internalErrorClasses.js +81 -0
- package/dist/esm/internalErrorClasses.js.map +1 -0
- package/dist/esm/internalPlugin.d.ts +9 -0
- package/dist/esm/internalPlugin.d.ts.map +1 -0
- package/dist/esm/internalPlugin.js +7 -0
- package/dist/esm/internalPlugin.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/plugin/cacheControl/index.d.ts +9 -0
- package/dist/esm/plugin/cacheControl/index.d.ts.map +1 -0
- package/dist/esm/plugin/cacheControl/index.js +220 -0
- package/dist/esm/plugin/cacheControl/index.js.map +1 -0
- package/dist/esm/plugin/disableSuggestions/index.d.ts +3 -0
- package/dist/esm/plugin/disableSuggestions/index.d.ts.map +1 -0
- package/dist/esm/plugin/disableSuggestions/index.js +19 -0
- package/dist/esm/plugin/disableSuggestions/index.js.map +1 -0
- package/dist/esm/plugin/disabled/index.d.ts +7 -0
- package/dist/esm/plugin/disabled/index.d.ts.map +1 -0
- package/dist/esm/plugin/disabled/index.js +23 -0
- package/dist/esm/plugin/disabled/index.js.map +1 -0
- package/dist/esm/plugin/drainHttpServer/index.d.ts +8 -0
- package/dist/esm/plugin/drainHttpServer/index.d.ts.map +1 -0
- package/dist/esm/plugin/drainHttpServer/index.js +16 -0
- package/dist/esm/plugin/drainHttpServer/index.js.map +1 -0
- package/dist/esm/plugin/drainHttpServer/stoppable.d.ts +10 -0
- package/dist/esm/plugin/drainHttpServer/stoppable.d.ts.map +1 -0
- package/dist/esm/plugin/drainHttpServer/stoppable.js +47 -0
- package/dist/esm/plugin/drainHttpServer/stoppable.js.map +1 -0
- package/dist/esm/plugin/inlineTrace/index.d.ts +8 -0
- package/dist/esm/plugin/inlineTrace/index.d.ts.map +1 -0
- package/dist/esm/plugin/inlineTrace/index.js +67 -0
- package/dist/esm/plugin/inlineTrace/index.js.map +1 -0
- package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.d.ts +4 -0
- package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.d.ts.map +1 -0
- package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.js +138 -0
- package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.js.map +1 -0
- package/dist/esm/plugin/landingPage/default/index.d.ts +9 -0
- package/dist/esm/plugin/landingPage/default/index.d.ts.map +1 -0
- package/dist/esm/plugin/landingPage/default/index.js +141 -0
- package/dist/esm/plugin/landingPage/default/index.js.map +1 -0
- package/dist/esm/plugin/landingPage/default/types.d.ts +56 -0
- package/dist/esm/plugin/landingPage/default/types.d.ts.map +1 -0
- package/dist/esm/plugin/landingPage/default/types.js +2 -0
- package/dist/esm/plugin/landingPage/default/types.js.map +1 -0
- package/dist/esm/plugin/schemaIsSubgraph.d.ts +3 -0
- package/dist/esm/plugin/schemaIsSubgraph.d.ts.map +1 -0
- package/dist/esm/plugin/schemaIsSubgraph.js +20 -0
- package/dist/esm/plugin/schemaIsSubgraph.js.map +1 -0
- package/dist/esm/plugin/schemaReporting/index.d.ts +10 -0
- package/dist/esm/plugin/schemaReporting/index.d.ts.map +1 -0
- package/dist/esm/plugin/schemaReporting/index.js +98 -0
- package/dist/esm/plugin/schemaReporting/index.js.map +1 -0
- package/dist/esm/plugin/schemaReporting/schemaReporter.d.ts +33 -0
- package/dist/esm/plugin/schemaReporting/schemaReporter.d.ts.map +1 -0
- package/dist/esm/plugin/schemaReporting/schemaReporter.js +143 -0
- package/dist/esm/plugin/schemaReporting/schemaReporter.js.map +1 -0
- package/dist/esm/plugin/subscriptionCallback/index.d.ts +12 -0
- package/dist/esm/plugin/subscriptionCallback/index.d.ts.map +1 -0
- package/dist/esm/plugin/subscriptionCallback/index.js +428 -0
- package/dist/esm/plugin/subscriptionCallback/index.js.map +1 -0
- package/dist/esm/plugin/traceTreeBuilder.d.ts +25 -0
- package/dist/esm/plugin/traceTreeBuilder.d.ts.map +1 -0
- package/dist/esm/plugin/traceTreeBuilder.js +196 -0
- package/dist/esm/plugin/traceTreeBuilder.js.map +1 -0
- package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts +3 -0
- package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.js +41 -0
- package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.js.map +1 -0
- package/dist/esm/plugin/usageReporting/durationHistogram.d.ts +16 -0
- package/dist/esm/plugin/usageReporting/durationHistogram.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/durationHistogram.js +64 -0
- package/dist/esm/plugin/usageReporting/durationHistogram.js.map +1 -0
- package/dist/esm/plugin/usageReporting/index.d.ts +3 -0
- package/dist/esm/plugin/usageReporting/index.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/index.js +2 -0
- package/dist/esm/plugin/usageReporting/index.js.map +1 -0
- package/dist/esm/plugin/usageReporting/iterateOverTrace.d.ts +7 -0
- package/dist/esm/plugin/usageReporting/iterateOverTrace.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/iterateOverTrace.js +78 -0
- package/dist/esm/plugin/usageReporting/iterateOverTrace.js.map +1 -0
- package/dist/esm/plugin/usageReporting/operationDerivedDataCache.d.ts +12 -0
- package/dist/esm/plugin/usageReporting/operationDerivedDataCache.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/operationDerivedDataCache.js +29 -0
- package/dist/esm/plugin/usageReporting/operationDerivedDataCache.js.map +1 -0
- package/dist/esm/plugin/usageReporting/options.d.ts +60 -0
- package/dist/esm/plugin/usageReporting/options.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/options.js +2 -0
- package/dist/esm/plugin/usageReporting/options.js.map +1 -0
- package/dist/esm/plugin/usageReporting/plugin.d.ts +7 -0
- package/dist/esm/plugin/usageReporting/plugin.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/plugin.js +487 -0
- package/dist/esm/plugin/usageReporting/plugin.js.map +1 -0
- package/dist/esm/plugin/usageReporting/stats.d.ts +96 -0
- package/dist/esm/plugin/usageReporting/stats.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/stats.js +283 -0
- package/dist/esm/plugin/usageReporting/stats.js.map +1 -0
- package/dist/esm/plugin/usageReporting/traceDetails.d.ts +4 -0
- package/dist/esm/plugin/usageReporting/traceDetails.d.ts.map +1 -0
- package/dist/esm/plugin/usageReporting/traceDetails.js +60 -0
- package/dist/esm/plugin/usageReporting/traceDetails.js.map +1 -0
- package/dist/esm/preventCsrf.d.ts +4 -0
- package/dist/esm/preventCsrf.d.ts.map +1 -0
- package/dist/esm/preventCsrf.js +34 -0
- package/dist/esm/preventCsrf.js.map +1 -0
- package/dist/esm/requestPipeline.d.ts +9 -0
- package/dist/esm/requestPipeline.d.ts.map +1 -0
- package/dist/esm/requestPipeline.js +364 -0
- package/dist/esm/requestPipeline.js.map +1 -0
- package/dist/esm/runHttpQuery.d.ts +15 -0
- package/dist/esm/runHttpQuery.d.ts.map +1 -0
- package/dist/esm/runHttpQuery.js +221 -0
- package/dist/esm/runHttpQuery.js.map +1 -0
- package/dist/esm/standalone/index.d.ts +25 -0
- package/dist/esm/standalone/index.d.ts.map +1 -0
- package/dist/esm/standalone/index.js +91 -0
- package/dist/esm/standalone/index.js.map +1 -0
- package/dist/esm/utils/HeaderMap.d.ts +8 -0
- package/dist/esm/utils/HeaderMap.d.ts.map +1 -0
- package/dist/esm/utils/HeaderMap.js +16 -0
- package/dist/esm/utils/HeaderMap.js.map +1 -0
- package/dist/esm/utils/UnreachableCaseError.d.ts +4 -0
- package/dist/esm/utils/UnreachableCaseError.d.ts.map +1 -0
- package/dist/esm/utils/UnreachableCaseError.js +6 -0
- package/dist/esm/utils/UnreachableCaseError.js.map +1 -0
- package/dist/esm/utils/computeCoreSchemaHash.d.ts +2 -0
- package/dist/esm/utils/computeCoreSchemaHash.d.ts.map +1 -0
- package/dist/esm/utils/computeCoreSchemaHash.js +5 -0
- package/dist/esm/utils/computeCoreSchemaHash.js.map +1 -0
- package/dist/esm/utils/invokeHooks.d.ts +7 -0
- package/dist/esm/utils/invokeHooks.d.ts.map +1 -0
- package/dist/esm/utils/invokeHooks.js +31 -0
- package/dist/esm/utils/invokeHooks.js.map +1 -0
- package/dist/esm/utils/isDefined.d.ts +2 -0
- package/dist/esm/utils/isDefined.d.ts.map +1 -0
- package/dist/esm/utils/isDefined.js +4 -0
- package/dist/esm/utils/isDefined.js.map +1 -0
- package/dist/esm/utils/makeGatewayGraphQLRequestContext.d.ts +5 -0
- package/dist/esm/utils/makeGatewayGraphQLRequestContext.d.ts.map +1 -0
- package/dist/esm/utils/makeGatewayGraphQLRequestContext.js +93 -0
- package/dist/esm/utils/makeGatewayGraphQLRequestContext.js.map +1 -0
- package/dist/esm/utils/resolvable.d.ts +7 -0
- package/dist/esm/utils/resolvable.d.ts.map +1 -0
- package/dist/esm/utils/resolvable.js +12 -0
- package/dist/esm/utils/resolvable.js.map +1 -0
- package/dist/esm/utils/schemaInstrumentation.d.ts +16 -0
- package/dist/esm/utils/schemaInstrumentation.d.ts.map +1 -0
- package/dist/esm/utils/schemaInstrumentation.js +69 -0
- package/dist/esm/utils/schemaInstrumentation.js.map +1 -0
- package/dist/esm/utils/schemaManager.d.ts +31 -0
- package/dist/esm/utils/schemaManager.d.ts.map +1 -0
- package/dist/esm/utils/schemaManager.js +99 -0
- package/dist/esm/utils/schemaManager.js.map +1 -0
- package/dist/esm/utils/urlForHttpServer.d.ts +3 -0
- package/dist/esm/utils/urlForHttpServer.d.ts.map +1 -0
- package/dist/esm/utils/urlForHttpServer.js +12 -0
- package/dist/esm/utils/urlForHttpServer.js.map +1 -0
- package/dist/esm/validationRules/NoIntrospection.d.ts +3 -0
- package/dist/esm/validationRules/NoIntrospection.d.ts.map +1 -0
- package/dist/esm/validationRules/NoIntrospection.js +15 -0
- package/dist/esm/validationRules/NoIntrospection.js.map +1 -0
- package/dist/esm/validationRules/RecursiveSelectionsLimit.d.ts +4 -0
- package/dist/esm/validationRules/RecursiveSelectionsLimit.d.ts.map +1 -0
- package/dist/esm/validationRules/RecursiveSelectionsLimit.js +146 -0
- package/dist/esm/validationRules/RecursiveSelectionsLimit.js.map +1 -0
- package/dist/esm/validationRules/index.d.ts +3 -0
- package/dist/esm/validationRules/index.d.ts.map +1 -0
- package/dist/esm/validationRules/index.js +3 -0
- package/dist/esm/validationRules/index.js.map +1 -0
- package/errors/package.json +8 -0
- package/package.json +208 -0
- package/plugin/cacheControl/package.json +8 -0
- package/plugin/disableSuggestions/package.json +8 -0
- package/plugin/disabled/package.json +8 -0
- package/plugin/drainHttpServer/package.json +8 -0
- package/plugin/inlineTrace/package.json +8 -0
- package/plugin/landingPage/default/package.json +8 -0
- package/plugin/schemaReporting/package.json +8 -0
- package/plugin/subscriptionCallback/package.json +8 -0
- package/plugin/usageReporting/package.json +8 -0
- package/src/ApolloServer.ts +1456 -0
- package/src/cachePolicy.ts +33 -0
- package/src/determineApolloConfig.ts +95 -0
- package/src/errorNormalize.ts +114 -0
- package/src/errors/index.ts +33 -0
- package/src/externalTypes/constructor.ts +174 -0
- package/src/externalTypes/context.ts +18 -0
- package/src/externalTypes/graphql.ts +81 -0
- package/src/externalTypes/http.ts +44 -0
- package/src/externalTypes/incrementalDeliveryPolyfillAlpha2.ts +63 -0
- package/src/externalTypes/incrementalDeliveryPolyfillAlpha9.ts +82 -0
- package/src/externalTypes/index.ts +73 -0
- package/src/externalTypes/plugins.ts +222 -0
- package/src/externalTypes/requestPipeline.ts +123 -0
- package/src/generated/packageVersion.ts +1 -0
- package/src/httpBatching.ts +105 -0
- package/src/incrementalDeliveryPolyfill.ts +253 -0
- package/src/index.ts +4 -0
- package/src/internalErrorClasses.ts +123 -0
- package/src/internalPlugin.ts +42 -0
- package/src/plugin/cacheControl/index.ts +453 -0
- package/src/plugin/disableSuggestions/index.ts +23 -0
- package/src/plugin/disabled/index.ts +41 -0
- package/src/plugin/drainHttpServer/index.ts +42 -0
- package/src/plugin/drainHttpServer/stoppable.ts +109 -0
- package/src/plugin/inlineTrace/index.ts +156 -0
- package/src/plugin/landingPage/default/getEmbeddedHTML.ts +204 -0
- package/src/plugin/landingPage/default/index.ts +219 -0
- package/src/plugin/landingPage/default/types.ts +198 -0
- package/src/plugin/schemaIsSubgraph.ts +41 -0
- package/src/plugin/schemaReporting/generated/operations.d.ts +18359 -0
- package/src/plugin/schemaReporting/index.ts +198 -0
- package/src/plugin/schemaReporting/schemaReporter.ts +207 -0
- package/src/plugin/subscriptionCallback/index.ts +724 -0
- package/src/plugin/traceTreeBuilder.ts +356 -0
- package/src/plugin/usageReporting/defaultSendOperationsAsTrace.ts +74 -0
- package/src/plugin/usageReporting/durationHistogram.ts +87 -0
- package/src/plugin/usageReporting/index.ts +9 -0
- package/src/plugin/usageReporting/iterateOverTrace.ts +140 -0
- package/src/plugin/usageReporting/operationDerivedDataCache.ts +61 -0
- package/src/plugin/usageReporting/options.ts +414 -0
- package/src/plugin/usageReporting/plugin.ts +871 -0
- package/src/plugin/usageReporting/stats.ts +492 -0
- package/src/plugin/usageReporting/traceDetails.ts +96 -0
- package/src/preventCsrf.ts +99 -0
- package/src/requestPipeline.ts +821 -0
- package/src/runHttpQuery.ts +408 -0
- package/src/standalone/index.ts +155 -0
- package/src/utils/HeaderMap.ts +22 -0
- package/src/utils/UnreachableCaseError.ts +10 -0
- package/src/utils/computeCoreSchemaHash.ts +9 -0
- package/src/utils/invokeHooks.ts +53 -0
- package/src/utils/isDefined.ts +3 -0
- package/src/utils/makeGatewayGraphQLRequestContext.ts +197 -0
- package/src/utils/resolvable.ts +30 -0
- package/src/utils/schemaInstrumentation.ts +132 -0
- package/src/utils/schemaManager.ts +212 -0
- package/src/utils/urlForHttpServer.ts +21 -0
- package/src/validationRules/NoIntrospection.ts +27 -0
- package/src/validationRules/RecursiveSelectionsLimit.ts +198 -0
- package/src/validationRules/index.ts +5 -0
- package/standalone/package.json +8 -0
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import { createHash } from '@apollo/utils.createhash';
|
|
2
|
+
import {
|
|
3
|
+
specifiedRules,
|
|
4
|
+
getOperationAST,
|
|
5
|
+
GraphQLError,
|
|
6
|
+
validate,
|
|
7
|
+
parse,
|
|
8
|
+
Kind,
|
|
9
|
+
type ExecutionResult,
|
|
10
|
+
} from 'graphql';
|
|
11
|
+
import {
|
|
12
|
+
symbolExecutionDispatcherWillResolveField,
|
|
13
|
+
enablePluginsForSchemaResolvers,
|
|
14
|
+
symbolUserFieldResolver,
|
|
15
|
+
} from './utils/schemaInstrumentation.js';
|
|
16
|
+
import {
|
|
17
|
+
PersistedQueryNotSupportedError,
|
|
18
|
+
PersistedQueryNotFoundError,
|
|
19
|
+
UserInputError,
|
|
20
|
+
BadRequestError,
|
|
21
|
+
ValidationError,
|
|
22
|
+
SyntaxError,
|
|
23
|
+
OperationResolutionError,
|
|
24
|
+
} from './internalErrorClasses.js';
|
|
25
|
+
import {
|
|
26
|
+
ensureError,
|
|
27
|
+
normalizeAndFormatErrors,
|
|
28
|
+
ensureGraphQLError,
|
|
29
|
+
} from './errorNormalize.js';
|
|
30
|
+
import type {
|
|
31
|
+
GraphQLRequestContext,
|
|
32
|
+
GraphQLRequestContextDidResolveSource,
|
|
33
|
+
GraphQLRequestContextExecutionDidStart,
|
|
34
|
+
GraphQLRequestContextResponseForOperation,
|
|
35
|
+
GraphQLRequestContextDidResolveOperation,
|
|
36
|
+
GraphQLRequestContextParsingDidStart,
|
|
37
|
+
GraphQLRequestContextValidationDidStart,
|
|
38
|
+
GraphQLRequestContextWillSendResponse,
|
|
39
|
+
GraphQLRequestContextDidEncounterErrors,
|
|
40
|
+
GraphQLRequestExecutionListener,
|
|
41
|
+
BaseContext,
|
|
42
|
+
GraphQLResponse,
|
|
43
|
+
GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha2,
|
|
44
|
+
GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha9,
|
|
45
|
+
} from './externalTypes/index.js';
|
|
46
|
+
|
|
47
|
+
import {
|
|
48
|
+
invokeDidStartHook,
|
|
49
|
+
invokeHooksUntilDefinedAndNonNull,
|
|
50
|
+
invokeSyncDidStartHook,
|
|
51
|
+
} from './utils/invokeHooks.js';
|
|
52
|
+
|
|
53
|
+
import { makeGatewayGraphQLRequestContext } from './utils/makeGatewayGraphQLRequestContext.js';
|
|
54
|
+
|
|
55
|
+
import { mergeHTTPGraphQLHead, newHTTPGraphQLHead } from './runHttpQuery.js';
|
|
56
|
+
import {
|
|
57
|
+
MEDIA_TYPES,
|
|
58
|
+
type ApolloServer,
|
|
59
|
+
type ApolloServerInternals,
|
|
60
|
+
type SchemaDerivedData,
|
|
61
|
+
} from './ApolloServer.js';
|
|
62
|
+
import { isDefined } from './utils/isDefined.js';
|
|
63
|
+
import type {
|
|
64
|
+
GraphQLRequestContextDidEncounterSubsequentErrors,
|
|
65
|
+
GraphQLRequestContextWillSendSubsequentPayload,
|
|
66
|
+
} from './externalTypes/requestPipeline.js';
|
|
67
|
+
import {
|
|
68
|
+
executeIncrementally,
|
|
69
|
+
type GraphQLExperimentalSubsequentIncrementalExecutionResultAlpha9,
|
|
70
|
+
type GraphQLExperimentalInitialIncrementalExecutionResultAlpha2,
|
|
71
|
+
type GraphQLExperimentalInitialIncrementalExecutionResultAlpha9,
|
|
72
|
+
type GraphQLExperimentalSubsequentIncrementalExecutionResultAlpha2,
|
|
73
|
+
} from './incrementalDeliveryPolyfill.js';
|
|
74
|
+
import { HeaderMap } from './utils/HeaderMap.js';
|
|
75
|
+
import Negotiator from 'negotiator';
|
|
76
|
+
|
|
77
|
+
export const APQ_CACHE_PREFIX = 'apq:';
|
|
78
|
+
|
|
79
|
+
function computeQueryHash(query: string) {
|
|
80
|
+
return createHash('sha256').update(query).digest('hex');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
|
84
|
+
|
|
85
|
+
// Once GraphQL-JS v17 is released and we make a version of Apollo Server that
|
|
86
|
+
// requires it, we can drop this hack, because it lets us break the `execute`
|
|
87
|
+
// API into two steps and validate user input explicitly first.
|
|
88
|
+
function isBadUserInputGraphQLError(error: GraphQLError): boolean {
|
|
89
|
+
return (
|
|
90
|
+
error.nodes?.length === 1 &&
|
|
91
|
+
error.nodes[0].kind === Kind.VARIABLE_DEFINITION &&
|
|
92
|
+
// GraphQL-JS v17 alpha wording
|
|
93
|
+
(error.message.startsWith(
|
|
94
|
+
`Variable "$${error.nodes[0].variable.name.value}" has invalid value`,
|
|
95
|
+
) ||
|
|
96
|
+
// GraphQL-JS v16 wording
|
|
97
|
+
error.message.startsWith(
|
|
98
|
+
`Variable "$${error.nodes[0].variable.name.value}" got invalid value `,
|
|
99
|
+
) ||
|
|
100
|
+
error.message.startsWith(
|
|
101
|
+
`Variable "$${error.nodes[0].variable.name.value}" of required type `,
|
|
102
|
+
) ||
|
|
103
|
+
error.message.startsWith(
|
|
104
|
+
`Variable "$${error.nodes[0].variable.name.value}" of non-null type `,
|
|
105
|
+
))
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// This is "semi-formatted" because the initial result has not yet been
|
|
110
|
+
// formatted but the subsequent results "have been" --- in the sense that they
|
|
111
|
+
// are an async iterable that will format them as they come in.
|
|
112
|
+
type SemiFormattedExecuteIncrementallyResults =
|
|
113
|
+
| {
|
|
114
|
+
singleResult: ExecutionResult;
|
|
115
|
+
}
|
|
116
|
+
| {
|
|
117
|
+
initialResult: GraphQLExperimentalInitialIncrementalExecutionResultAlpha2;
|
|
118
|
+
subsequentResults: AsyncIterable<GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha2>;
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
initialResult: GraphQLExperimentalInitialIncrementalExecutionResultAlpha9;
|
|
122
|
+
subsequentResults: AsyncIterable<GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha9>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export async function processGraphQLRequest<TContext extends BaseContext>(
|
|
126
|
+
schemaDerivedData: SchemaDerivedData,
|
|
127
|
+
server: ApolloServer<TContext>,
|
|
128
|
+
internals: ApolloServerInternals<TContext>,
|
|
129
|
+
requestContext: Mutable<GraphQLRequestContext<TContext>>,
|
|
130
|
+
): Promise<GraphQLResponse> {
|
|
131
|
+
const requestListeners = (
|
|
132
|
+
await Promise.all(
|
|
133
|
+
internals.plugins.map((p) => p.requestDidStart?.(requestContext)),
|
|
134
|
+
)
|
|
135
|
+
).filter(isDefined);
|
|
136
|
+
|
|
137
|
+
const request = requestContext.request;
|
|
138
|
+
|
|
139
|
+
let { query, extensions } = request;
|
|
140
|
+
|
|
141
|
+
let queryHash: string;
|
|
142
|
+
|
|
143
|
+
requestContext.metrics.persistedQueryHit = false;
|
|
144
|
+
requestContext.metrics.persistedQueryRegister = false;
|
|
145
|
+
|
|
146
|
+
if (extensions?.persistedQuery) {
|
|
147
|
+
// It looks like we've received a persisted query. Check if we
|
|
148
|
+
// support them.
|
|
149
|
+
if (!internals.persistedQueries) {
|
|
150
|
+
return await sendErrorResponse([new PersistedQueryNotSupportedError()]);
|
|
151
|
+
} else if (extensions.persistedQuery.version !== 1) {
|
|
152
|
+
return await sendErrorResponse([
|
|
153
|
+
new GraphQLError('Unsupported persisted query version', {
|
|
154
|
+
extensions: { http: newHTTPGraphQLHead(400) },
|
|
155
|
+
}),
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
queryHash = extensions.persistedQuery.sha256Hash;
|
|
160
|
+
|
|
161
|
+
if (query === undefined) {
|
|
162
|
+
query = await internals.persistedQueries.cache.get(queryHash);
|
|
163
|
+
if (query) {
|
|
164
|
+
requestContext.metrics.persistedQueryHit = true;
|
|
165
|
+
} else {
|
|
166
|
+
return await sendErrorResponse([new PersistedQueryNotFoundError()]);
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
const computedQueryHash = computeQueryHash(query);
|
|
170
|
+
|
|
171
|
+
// The provided hash must exactly match the SHA-256 hash of
|
|
172
|
+
// the query string. This prevents hash hijacking, where a
|
|
173
|
+
// new and potentially malicious query is associated with
|
|
174
|
+
// an existing hash.
|
|
175
|
+
if (queryHash !== computedQueryHash) {
|
|
176
|
+
return await sendErrorResponse([
|
|
177
|
+
new GraphQLError('provided sha does not match query', {
|
|
178
|
+
extensions: { http: newHTTPGraphQLHead(400) },
|
|
179
|
+
}),
|
|
180
|
+
]);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// We won't write to the persisted query cache until later.
|
|
184
|
+
// Deferring the writing gives plugins the ability to "win" from use of
|
|
185
|
+
// the cache, but also have their say in whether or not the cache is
|
|
186
|
+
// written to (by interrupting the request with an error).
|
|
187
|
+
requestContext.metrics.persistedQueryRegister = true;
|
|
188
|
+
}
|
|
189
|
+
} else if (query) {
|
|
190
|
+
queryHash = computeQueryHash(query);
|
|
191
|
+
} else {
|
|
192
|
+
return await sendErrorResponse([
|
|
193
|
+
new BadRequestError(
|
|
194
|
+
'GraphQL operations must contain a non-empty `query` or a `persistedQuery` extension.',
|
|
195
|
+
),
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
requestContext.queryHash = queryHash;
|
|
200
|
+
requestContext.source = query;
|
|
201
|
+
|
|
202
|
+
// Let the plugins know that we now have a STRING of what we hope will
|
|
203
|
+
// parse and validate into a document we can execute on. Unless we have
|
|
204
|
+
// retrieved this from our APQ cache, there's no guarantee that it is
|
|
205
|
+
// syntactically correct, so this string should not be trusted as a valid
|
|
206
|
+
// document until after it's parsed and validated.
|
|
207
|
+
await Promise.all(
|
|
208
|
+
requestListeners.map((l) =>
|
|
209
|
+
l.didResolveSource?.(
|
|
210
|
+
requestContext as GraphQLRequestContextDidResolveSource<TContext>,
|
|
211
|
+
),
|
|
212
|
+
),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// If we're configured with a document store (by default, we are), we'll
|
|
216
|
+
// utilize the operation's hash to lookup the AST from the previously
|
|
217
|
+
// parsed-and-validated operation. Failure to retrieve anything from the
|
|
218
|
+
// cache just means we're committed to doing the parsing and validation.
|
|
219
|
+
if (schemaDerivedData.documentStore) {
|
|
220
|
+
try {
|
|
221
|
+
requestContext.document = await schemaDerivedData.documentStore.get(
|
|
222
|
+
schemaDerivedData.documentStoreKeyPrefix + queryHash,
|
|
223
|
+
);
|
|
224
|
+
} catch (err: unknown) {
|
|
225
|
+
server.logger.warn(
|
|
226
|
+
'An error occurred while attempting to read from the documentStore. ' +
|
|
227
|
+
ensureError(err).message,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// If we still don't have a document, we'll need to parse and validate it.
|
|
233
|
+
// With success, we'll attempt to save it into the store for future use.
|
|
234
|
+
if (!requestContext.document) {
|
|
235
|
+
const parsingDidEnd = await invokeDidStartHook(
|
|
236
|
+
requestListeners,
|
|
237
|
+
async (l) =>
|
|
238
|
+
l.parsingDidStart?.(
|
|
239
|
+
requestContext as GraphQLRequestContextParsingDidStart<TContext>,
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
requestContext.document = parse(query, internals.parseOptions);
|
|
245
|
+
} catch (syntaxMaybeError: unknown) {
|
|
246
|
+
const error = ensureError(syntaxMaybeError);
|
|
247
|
+
await parsingDidEnd(error);
|
|
248
|
+
return await sendErrorResponse([
|
|
249
|
+
new SyntaxError(ensureGraphQLError(error)),
|
|
250
|
+
]);
|
|
251
|
+
}
|
|
252
|
+
await parsingDidEnd();
|
|
253
|
+
|
|
254
|
+
if (internals.dangerouslyDisableValidation !== true) {
|
|
255
|
+
const validationDidEnd = await invokeDidStartHook(
|
|
256
|
+
requestListeners,
|
|
257
|
+
async (l) =>
|
|
258
|
+
l.validationDidStart?.(
|
|
259
|
+
requestContext as GraphQLRequestContextValidationDidStart<TContext>,
|
|
260
|
+
),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
let validationErrors = validate(
|
|
264
|
+
schemaDerivedData.schema,
|
|
265
|
+
requestContext.document,
|
|
266
|
+
[...specifiedRules, ...internals.validationRules],
|
|
267
|
+
internals.validationOptions,
|
|
268
|
+
);
|
|
269
|
+
if (validationErrors.length === 0 && internals.laterValidationRules) {
|
|
270
|
+
validationErrors = validate(
|
|
271
|
+
schemaDerivedData.schema,
|
|
272
|
+
requestContext.document,
|
|
273
|
+
internals.laterValidationRules,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (validationErrors.length === 0) {
|
|
278
|
+
await validationDidEnd();
|
|
279
|
+
} else {
|
|
280
|
+
await validationDidEnd(validationErrors);
|
|
281
|
+
return await sendErrorResponse(
|
|
282
|
+
validationErrors.map((error) => new ValidationError(error)),
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (schemaDerivedData.documentStore) {
|
|
288
|
+
// The underlying cache store behind the `documentStore` returns a
|
|
289
|
+
// `Promise` which is resolved (or rejected), eventually, based on the
|
|
290
|
+
// success or failure (respectively) of the cache save attempt. While
|
|
291
|
+
// it's certainly possible to `await` this `Promise`, we don't care about
|
|
292
|
+
// whether or not it's successful at this point. We'll instead proceed
|
|
293
|
+
// to serve the rest of the request and just hope that this works out.
|
|
294
|
+
// If it doesn't work, the next request will have another opportunity to
|
|
295
|
+
// try again. Errors will surface as warnings, as appropriate.
|
|
296
|
+
//
|
|
297
|
+
// While it shouldn't normally be necessary to wrap this `Promise` in a
|
|
298
|
+
// `Promise.resolve` invocation, it seems that the underlying cache store
|
|
299
|
+
// is returning a non-native `Promise` (e.g. Bluebird, etc.).
|
|
300
|
+
Promise.resolve(
|
|
301
|
+
schemaDerivedData.documentStore.set(
|
|
302
|
+
schemaDerivedData.documentStoreKeyPrefix + queryHash,
|
|
303
|
+
requestContext.document,
|
|
304
|
+
),
|
|
305
|
+
).catch((err) =>
|
|
306
|
+
server.logger.warn(
|
|
307
|
+
'Could not store validated document. ' + err?.message || err,
|
|
308
|
+
),
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// TODO: If we want to guarantee an operation has been set when invoking
|
|
314
|
+
// `willExecuteOperation` and executionDidStart`, we need to throw an
|
|
315
|
+
// error here and not leave this to `buildExecutionContext` in
|
|
316
|
+
// `graphql-js`.
|
|
317
|
+
const operation = getOperationAST(
|
|
318
|
+
requestContext.document,
|
|
319
|
+
request.operationName,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
requestContext.operation = operation || undefined;
|
|
323
|
+
// We'll set `operationName` to `null` for anonymous operations.
|
|
324
|
+
requestContext.operationName = operation?.name?.value || null;
|
|
325
|
+
|
|
326
|
+
// Special case: GET operations should only be queries (not mutations). We
|
|
327
|
+
// want to throw a particular HTTP error in that case. (This matters because
|
|
328
|
+
// it's generally how HTTP requests should work, and additionally it makes us
|
|
329
|
+
// less vulnerable to mutations running over CSRF, if you turn off our CSRF
|
|
330
|
+
// prevention feature.)
|
|
331
|
+
if (
|
|
332
|
+
request.http?.method === 'GET' &&
|
|
333
|
+
operation?.operation &&
|
|
334
|
+
operation.operation !== 'query'
|
|
335
|
+
) {
|
|
336
|
+
return await sendErrorResponse([
|
|
337
|
+
new BadRequestError(
|
|
338
|
+
`GET requests only support query operations, not ${operation.operation} operations`,
|
|
339
|
+
{
|
|
340
|
+
extensions: {
|
|
341
|
+
http: { status: 405, headers: new HeaderMap([['allow', 'POST']]) },
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
),
|
|
345
|
+
]);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
try {
|
|
349
|
+
await Promise.all(
|
|
350
|
+
requestListeners.map((l) =>
|
|
351
|
+
l.didResolveOperation?.(
|
|
352
|
+
requestContext as GraphQLRequestContextDidResolveOperation<TContext>,
|
|
353
|
+
),
|
|
354
|
+
),
|
|
355
|
+
);
|
|
356
|
+
} catch (err: unknown) {
|
|
357
|
+
// Note that we explicitly document throwing `GraphQLError`s from
|
|
358
|
+
// `didResolveOperation` as a good way to do validation that depends on the
|
|
359
|
+
// validated operation and the request context. (It will have status 500 by
|
|
360
|
+
// default.)
|
|
361
|
+
return await sendErrorResponse([ensureGraphQLError(err)]);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Now that we've gone through the pre-execution phases of the request
|
|
365
|
+
// pipeline, and given plugins appropriate ability to object (by throwing
|
|
366
|
+
// an error) and not actually write, we'll write to the cache if it was
|
|
367
|
+
// determined earlier in the request pipeline that we should do so.
|
|
368
|
+
if (
|
|
369
|
+
requestContext.metrics.persistedQueryRegister &&
|
|
370
|
+
internals.persistedQueries
|
|
371
|
+
) {
|
|
372
|
+
// While it shouldn't normally be necessary to wrap this `Promise` in a
|
|
373
|
+
// `Promise.resolve` invocation, it seems that the underlying cache store
|
|
374
|
+
// is returning a non-native `Promise` (e.g. Bluebird, etc.).
|
|
375
|
+
const ttl = internals.persistedQueries?.ttl;
|
|
376
|
+
Promise.resolve(
|
|
377
|
+
internals.persistedQueries.cache.set(
|
|
378
|
+
queryHash,
|
|
379
|
+
query,
|
|
380
|
+
// Explicitly checking for `undefined` which means "not set" vs 0 or
|
|
381
|
+
// null which means "no TTL".
|
|
382
|
+
ttl !== undefined
|
|
383
|
+
? { ttl: internals.persistedQueries?.ttl }
|
|
384
|
+
: undefined,
|
|
385
|
+
),
|
|
386
|
+
).catch(server.logger.warn.bind(server.logger));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const responseFromPlugin = await invokeHooksUntilDefinedAndNonNull(
|
|
390
|
+
requestListeners,
|
|
391
|
+
async (l) =>
|
|
392
|
+
await l.responseForOperation?.(
|
|
393
|
+
requestContext as GraphQLRequestContextResponseForOperation<TContext>,
|
|
394
|
+
),
|
|
395
|
+
);
|
|
396
|
+
if (responseFromPlugin !== null) {
|
|
397
|
+
requestContext.response.body = responseFromPlugin.body;
|
|
398
|
+
mergeHTTPGraphQLHead(requestContext.response.http, responseFromPlugin.http);
|
|
399
|
+
} else {
|
|
400
|
+
const executionListeners = (
|
|
401
|
+
await Promise.all(
|
|
402
|
+
requestListeners.map((l) =>
|
|
403
|
+
l.executionDidStart?.(
|
|
404
|
+
requestContext as GraphQLRequestContextExecutionDidStart<TContext>,
|
|
405
|
+
),
|
|
406
|
+
),
|
|
407
|
+
)
|
|
408
|
+
).filter(isDefined);
|
|
409
|
+
executionListeners.reverse();
|
|
410
|
+
|
|
411
|
+
if (executionListeners.some((l) => l.willResolveField)) {
|
|
412
|
+
// Create a callback that will trigger the execution dispatcher's
|
|
413
|
+
// `willResolveField` hook. We will attach this to the context on a
|
|
414
|
+
// symbol so it can be invoked by our `wrapField` method during execution.
|
|
415
|
+
const invokeWillResolveField: GraphQLRequestExecutionListener<TContext>['willResolveField'] =
|
|
416
|
+
(...args) =>
|
|
417
|
+
invokeSyncDidStartHook(executionListeners, (l) =>
|
|
418
|
+
l.willResolveField?.(...args),
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
Object.defineProperty(
|
|
422
|
+
requestContext.contextValue,
|
|
423
|
+
symbolExecutionDispatcherWillResolveField,
|
|
424
|
+
{ value: invokeWillResolveField },
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
// If the user has provided a custom field resolver, we will attach
|
|
428
|
+
// it to the context so we can still invoke it after we've wrapped the
|
|
429
|
+
// fields with `wrapField` within `enablePluginsForSchemaResolvers` of
|
|
430
|
+
// the `schemaInstrumentation` module.
|
|
431
|
+
if (internals.fieldResolver) {
|
|
432
|
+
Object.defineProperty(
|
|
433
|
+
requestContext.contextValue,
|
|
434
|
+
symbolUserFieldResolver,
|
|
435
|
+
{
|
|
436
|
+
value: internals.fieldResolver,
|
|
437
|
+
},
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// If the schema is already enabled, this is a no-op. Otherwise, the
|
|
442
|
+
// schema will be augmented so it is able to invoke willResolveField. Note
|
|
443
|
+
// that if we never see a plugin with willResolveField then we will never
|
|
444
|
+
// need to instrument the schema, which might be a small performance gain.
|
|
445
|
+
// (For example, this can happen if you pass `fieldLevelInstrumentation:
|
|
446
|
+
// () => false` to the usage reporting plugin and disable the cache
|
|
447
|
+
// control plugin. We can consider changing the cache control plugin to
|
|
448
|
+
// have a "static cache control only" mode that doesn't use
|
|
449
|
+
// willResolveField too if this proves to be helpful in practice.)
|
|
450
|
+
enablePluginsForSchemaResolvers(schemaDerivedData.schema);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
try {
|
|
454
|
+
const fullResult = await execute({
|
|
455
|
+
...requestContext,
|
|
456
|
+
useLegacyIncremental:
|
|
457
|
+
new Negotiator({
|
|
458
|
+
headers: { accept: request.http?.headers.get('accept') },
|
|
459
|
+
}).mediaType([
|
|
460
|
+
MEDIA_TYPES.MULTIPART_MIXED_EXPERIMENTAL_ALPHA_9,
|
|
461
|
+
MEDIA_TYPES.MULTIPART_MIXED_EXPERIMENTAL_ALPHA_2,
|
|
462
|
+
]) === MEDIA_TYPES.MULTIPART_MIXED_EXPERIMENTAL_ALPHA_2,
|
|
463
|
+
} as GraphQLRequestContextExecutionDidStart<TContext>);
|
|
464
|
+
const result =
|
|
465
|
+
'singleResult' in fullResult
|
|
466
|
+
? fullResult.singleResult
|
|
467
|
+
: fullResult.initialResult;
|
|
468
|
+
|
|
469
|
+
// If we don't have an operation, there's no reason to go further. We know
|
|
470
|
+
// `result` will consist of one error (returned by `graphql-js`'s
|
|
471
|
+
// `buildExecutionContext`).
|
|
472
|
+
if (!requestContext.operation) {
|
|
473
|
+
if (!result.errors?.length) {
|
|
474
|
+
throw new Error(
|
|
475
|
+
'Unexpected error: Apollo Server did not resolve an operation but execute did not return errors',
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
throw new OperationResolutionError(result.errors[0]);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// The first thing that execution does is coerce the request's variables
|
|
482
|
+
// to the types declared in the operation, which can lead to errors if
|
|
483
|
+
// they are of the wrong type. It also makes sure that all non-null
|
|
484
|
+
// variables are required and get non-null values. If any of these things
|
|
485
|
+
// lead to errors, we change them into UserInputError so that their code
|
|
486
|
+
// doesn't end up being INTERNAL_SERVER_ERROR, since these are client
|
|
487
|
+
// errors. (But if the error already has a code, perhaps because the
|
|
488
|
+
// original error was thrown from a custom scalar parseValue, we leave it
|
|
489
|
+
// alone. We check that here instead of as part of
|
|
490
|
+
// isBadUserInputGraphQLError since perhaps that function will one day be
|
|
491
|
+
// changed to something we can get directly from graphql-js, but the
|
|
492
|
+
// `code` check is AS-specific.)
|
|
493
|
+
//
|
|
494
|
+
// This is hacky! Hopefully graphql-js will give us a way to separate
|
|
495
|
+
// variable resolution from execution later; see
|
|
496
|
+
// https://github.com/graphql/graphql-js/issues/3169
|
|
497
|
+
const resultErrors = result.errors?.map((e) => {
|
|
498
|
+
if (isBadUserInputGraphQLError(e) && e.extensions?.code == null) {
|
|
499
|
+
return new UserInputError(e);
|
|
500
|
+
}
|
|
501
|
+
return e;
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
if (resultErrors) {
|
|
505
|
+
await didEncounterErrors(resultErrors);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const { formattedErrors, httpFromErrors } = resultErrors
|
|
509
|
+
? formatErrors(resultErrors)
|
|
510
|
+
: { formattedErrors: undefined, httpFromErrors: newHTTPGraphQLHead() };
|
|
511
|
+
|
|
512
|
+
// TODO(AS6): remove `status400ForVariableCoercionErrors`
|
|
513
|
+
if (
|
|
514
|
+
internals.status400ForVariableCoercionErrors &&
|
|
515
|
+
resultErrors?.length &&
|
|
516
|
+
result.data === undefined &&
|
|
517
|
+
!httpFromErrors.status
|
|
518
|
+
) {
|
|
519
|
+
httpFromErrors.status = 400;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
mergeHTTPGraphQLHead(requestContext.response.http, httpFromErrors);
|
|
523
|
+
|
|
524
|
+
if ('singleResult' in fullResult) {
|
|
525
|
+
requestContext.response.body = {
|
|
526
|
+
kind: 'single',
|
|
527
|
+
singleResult: {
|
|
528
|
+
...result,
|
|
529
|
+
errors: formattedErrors,
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
} else {
|
|
533
|
+
requestContext.response.body = {
|
|
534
|
+
kind: 'incremental',
|
|
535
|
+
initialResult: {
|
|
536
|
+
...fullResult.initialResult,
|
|
537
|
+
errors: formattedErrors,
|
|
538
|
+
},
|
|
539
|
+
subsequentResults: fullResult.subsequentResults,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
} catch (executionMaybeError: unknown) {
|
|
543
|
+
const executionError = ensureError(executionMaybeError);
|
|
544
|
+
await Promise.all(
|
|
545
|
+
executionListeners.map((l) => l.executionDidEnd?.(executionError)),
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
return await sendErrorResponse([ensureGraphQLError(executionError)]);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
await Promise.all(executionListeners.map((l) => l.executionDidEnd?.()));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
await invokeWillSendResponse();
|
|
555
|
+
if (!requestContext.response.body) {
|
|
556
|
+
throw Error('got to end of processGraphQLRequest without setting body?');
|
|
557
|
+
}
|
|
558
|
+
return requestContext.response as GraphQLResponse; // cast checked on previous line
|
|
559
|
+
|
|
560
|
+
async function execute({
|
|
561
|
+
useLegacyIncremental,
|
|
562
|
+
...requestContext
|
|
563
|
+
}: GraphQLRequestContextExecutionDidStart<TContext> & {
|
|
564
|
+
useLegacyIncremental?: boolean;
|
|
565
|
+
}): Promise<SemiFormattedExecuteIncrementallyResults> {
|
|
566
|
+
const { request, document } = requestContext;
|
|
567
|
+
|
|
568
|
+
if (internals.__testing_incrementalExecutionResults) {
|
|
569
|
+
return internals.__testing_incrementalExecutionResults;
|
|
570
|
+
} else if (internals.gatewayExecutor) {
|
|
571
|
+
const result = await internals.gatewayExecutor(
|
|
572
|
+
makeGatewayGraphQLRequestContext(requestContext, server, internals),
|
|
573
|
+
);
|
|
574
|
+
return { singleResult: result };
|
|
575
|
+
} else {
|
|
576
|
+
const resultOrResults = await executeIncrementally({
|
|
577
|
+
schema: schemaDerivedData.schema,
|
|
578
|
+
document,
|
|
579
|
+
rootValue:
|
|
580
|
+
typeof internals.rootValue === 'function'
|
|
581
|
+
? internals.rootValue(document)
|
|
582
|
+
: internals.rootValue,
|
|
583
|
+
contextValue: requestContext.contextValue,
|
|
584
|
+
variableValues: request.variables,
|
|
585
|
+
operationName: request.operationName,
|
|
586
|
+
fieldResolver: internals.fieldResolver,
|
|
587
|
+
useLegacyIncremental,
|
|
588
|
+
options: internals.executionOptions,
|
|
589
|
+
legacyExperimentalExecuteIncrementally:
|
|
590
|
+
internals.legacyExperimentalExecuteIncrementally,
|
|
591
|
+
});
|
|
592
|
+
if ('initialResult' in resultOrResults) {
|
|
593
|
+
return {
|
|
594
|
+
initialResult: resultOrResults.initialResult,
|
|
595
|
+
subsequentResults:
|
|
596
|
+
'pending' in resultOrResults.initialResult
|
|
597
|
+
? formatErrorsInSubsequentResultsAlpha9(
|
|
598
|
+
resultOrResults.subsequentResults as AsyncIterable<GraphQLExperimentalInitialIncrementalExecutionResultAlpha9>,
|
|
599
|
+
)
|
|
600
|
+
: formatErrorsInSubsequentResultsAlpha2(
|
|
601
|
+
resultOrResults.subsequentResults,
|
|
602
|
+
),
|
|
603
|
+
};
|
|
604
|
+
} else {
|
|
605
|
+
return { singleResult: resultOrResults };
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
async function* formatErrorsInSubsequentResultsAlpha2(
|
|
611
|
+
results: AsyncIterable<GraphQLExperimentalSubsequentIncrementalExecutionResultAlpha2>,
|
|
612
|
+
): AsyncIterable<GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha2> {
|
|
613
|
+
for await (const result of results) {
|
|
614
|
+
const payload: GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha2 =
|
|
615
|
+
result.incremental
|
|
616
|
+
? {
|
|
617
|
+
...result,
|
|
618
|
+
incremental: await seriesAsyncMap(
|
|
619
|
+
result.incremental,
|
|
620
|
+
async (incrementalResult) => {
|
|
621
|
+
const { errors } = incrementalResult;
|
|
622
|
+
if (errors) {
|
|
623
|
+
await Promise.all(
|
|
624
|
+
requestListeners.map((l) =>
|
|
625
|
+
l.didEncounterSubsequentErrors?.(
|
|
626
|
+
requestContext as GraphQLRequestContextDidEncounterSubsequentErrors<TContext>,
|
|
627
|
+
errors,
|
|
628
|
+
),
|
|
629
|
+
),
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
return {
|
|
633
|
+
...incrementalResult,
|
|
634
|
+
// Note that any `http` extensions in errors have no
|
|
635
|
+
// effect, because we've already sent the status code
|
|
636
|
+
// and response headers.
|
|
637
|
+
errors: formatErrors(errors).formattedErrors,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
return incrementalResult;
|
|
641
|
+
},
|
|
642
|
+
),
|
|
643
|
+
}
|
|
644
|
+
: result;
|
|
645
|
+
|
|
646
|
+
// Invoke hook, which is allowed to mutate payload if it really wants to.
|
|
647
|
+
await Promise.all(
|
|
648
|
+
requestListeners.map((l) =>
|
|
649
|
+
l.willSendSubsequentPayload?.(
|
|
650
|
+
requestContext as GraphQLRequestContextWillSendSubsequentPayload<TContext>,
|
|
651
|
+
payload,
|
|
652
|
+
),
|
|
653
|
+
),
|
|
654
|
+
);
|
|
655
|
+
|
|
656
|
+
yield payload;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
async function* formatErrorsInSubsequentResultsAlpha9(
|
|
661
|
+
results: AsyncIterable<GraphQLExperimentalSubsequentIncrementalExecutionResultAlpha9>,
|
|
662
|
+
): AsyncIterable<GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha9> {
|
|
663
|
+
for await (const result of results) {
|
|
664
|
+
const payload: GraphQLExperimentalFormattedSubsequentIncrementalExecutionResultAlpha9 =
|
|
665
|
+
result.incremental
|
|
666
|
+
? {
|
|
667
|
+
...result,
|
|
668
|
+
incremental: await seriesAsyncMap(
|
|
669
|
+
result.incremental,
|
|
670
|
+
async (incrementalResult) => {
|
|
671
|
+
const { errors } = incrementalResult;
|
|
672
|
+
if (errors) {
|
|
673
|
+
await Promise.all(
|
|
674
|
+
requestListeners.map((l) =>
|
|
675
|
+
l.didEncounterSubsequentErrors?.(
|
|
676
|
+
requestContext as GraphQLRequestContextDidEncounterSubsequentErrors<TContext>,
|
|
677
|
+
errors,
|
|
678
|
+
),
|
|
679
|
+
),
|
|
680
|
+
);
|
|
681
|
+
|
|
682
|
+
return {
|
|
683
|
+
...incrementalResult,
|
|
684
|
+
// Note that any `http` extensions in errors have no
|
|
685
|
+
// effect, because we've already sent the status code
|
|
686
|
+
// and response headers.
|
|
687
|
+
errors: formatErrors(errors).formattedErrors,
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
return incrementalResult;
|
|
691
|
+
},
|
|
692
|
+
),
|
|
693
|
+
}
|
|
694
|
+
: result;
|
|
695
|
+
|
|
696
|
+
if (result.completed) {
|
|
697
|
+
payload.completed = await seriesAsyncMap(
|
|
698
|
+
result.completed,
|
|
699
|
+
async (completedResult) => {
|
|
700
|
+
const { errors } = completedResult;
|
|
701
|
+
|
|
702
|
+
if (errors) {
|
|
703
|
+
await Promise.all(
|
|
704
|
+
requestListeners.map((l) =>
|
|
705
|
+
l.didEncounterSubsequentErrors?.(
|
|
706
|
+
requestContext as GraphQLRequestContextDidEncounterSubsequentErrors<TContext>,
|
|
707
|
+
errors,
|
|
708
|
+
),
|
|
709
|
+
),
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
return {
|
|
713
|
+
...completedResult,
|
|
714
|
+
// Note that any `http` extensions in errors have no
|
|
715
|
+
// effect, because we've already sent the status code
|
|
716
|
+
// and response headers.
|
|
717
|
+
errors: formatErrors(errors).formattedErrors,
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return completedResult;
|
|
722
|
+
},
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Invoke hook, which is allowed to mutate payload if it really wants to.
|
|
727
|
+
await Promise.all(
|
|
728
|
+
requestListeners.map((l) =>
|
|
729
|
+
l.willSendSubsequentPayload?.(
|
|
730
|
+
requestContext as GraphQLRequestContextWillSendSubsequentPayload<TContext>,
|
|
731
|
+
payload,
|
|
732
|
+
),
|
|
733
|
+
),
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
yield payload;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
async function invokeWillSendResponse() {
|
|
741
|
+
await Promise.all(
|
|
742
|
+
requestListeners.map((l) =>
|
|
743
|
+
l.willSendResponse?.(
|
|
744
|
+
requestContext as GraphQLRequestContextWillSendResponse<TContext>,
|
|
745
|
+
),
|
|
746
|
+
),
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// Note that we ensure that all calls to didEncounterErrors are followed by
|
|
751
|
+
// calls to willSendResponse. (The usage reporting plugin depends on this.)
|
|
752
|
+
async function didEncounterErrors(errors: ReadonlyArray<GraphQLError>) {
|
|
753
|
+
requestContext.errors = errors;
|
|
754
|
+
|
|
755
|
+
return await Promise.all(
|
|
756
|
+
requestListeners.map((l) =>
|
|
757
|
+
l.didEncounterErrors?.(
|
|
758
|
+
requestContext as GraphQLRequestContextDidEncounterErrors<TContext>,
|
|
759
|
+
),
|
|
760
|
+
),
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// This function "sends" a response that contains errors and no data (not even
|
|
765
|
+
// `data: null`) because the pipeline does not make it to a successful
|
|
766
|
+
// `execute` call. (It is *not* called for execution that happens to return
|
|
767
|
+
// some errors.) In this case "send" means "update requestContext.response and
|
|
768
|
+
// invoke willSendResponse hooks".
|
|
769
|
+
//
|
|
770
|
+
// If any errors have `extensions.http` set, it sets the response's status code
|
|
771
|
+
// and errors from them.
|
|
772
|
+
//
|
|
773
|
+
// Then, if the HTTP status code is not yet set, it sets it to 500.
|
|
774
|
+
async function sendErrorResponse(
|
|
775
|
+
errors: ReadonlyArray<GraphQLError>,
|
|
776
|
+
): Promise<GraphQLResponse> {
|
|
777
|
+
await didEncounterErrors(errors);
|
|
778
|
+
|
|
779
|
+
const { formattedErrors, httpFromErrors } = formatErrors(errors);
|
|
780
|
+
|
|
781
|
+
requestContext.response.body = {
|
|
782
|
+
kind: 'single',
|
|
783
|
+
singleResult: {
|
|
784
|
+
errors: formattedErrors,
|
|
785
|
+
},
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
mergeHTTPGraphQLHead(requestContext.response.http, httpFromErrors);
|
|
789
|
+
|
|
790
|
+
if (!requestContext.response.http.status) {
|
|
791
|
+
requestContext.response.http.status = 500;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
await invokeWillSendResponse();
|
|
795
|
+
|
|
796
|
+
// cast safe because we assigned to `body` above
|
|
797
|
+
return requestContext.response as GraphQLResponse;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function formatErrors(
|
|
801
|
+
errors: ReadonlyArray<GraphQLError>,
|
|
802
|
+
): ReturnType<typeof normalizeAndFormatErrors> {
|
|
803
|
+
return normalizeAndFormatErrors(errors, {
|
|
804
|
+
formatError: internals.formatError,
|
|
805
|
+
includeStacktraceInErrorResponses:
|
|
806
|
+
internals.includeStacktraceInErrorResponses,
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
async function seriesAsyncMap<T, U>(
|
|
812
|
+
ts: readonly T[],
|
|
813
|
+
fn: (value: T) => Promise<U>,
|
|
814
|
+
): Promise<U[]> {
|
|
815
|
+
const us: U[] = [];
|
|
816
|
+
for (const t of ts) {
|
|
817
|
+
const u = await fn(t);
|
|
818
|
+
us.push(u);
|
|
819
|
+
}
|
|
820
|
+
return us;
|
|
821
|
+
}
|