@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,197 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GatewayGraphQLRequest,
|
|
3
|
+
GatewayGraphQLRequestContext,
|
|
4
|
+
GatewayGraphQLResponse,
|
|
5
|
+
GatewaySchemaHash,
|
|
6
|
+
} from '@apollo/server-gateway-interface';
|
|
7
|
+
import type { FetcherHeaders } from '@apollo/utils.fetcher';
|
|
8
|
+
import type { ApolloServer, ApolloServerInternals } from '../ApolloServer';
|
|
9
|
+
import type {
|
|
10
|
+
BaseContext,
|
|
11
|
+
GraphQLRequestContextExecutionDidStart,
|
|
12
|
+
} from '../externalTypes';
|
|
13
|
+
import type { HeaderMap } from './HeaderMap';
|
|
14
|
+
|
|
15
|
+
// Apollo Gateway's API included `GraphQLRequestContext` from AS2/AS3.
|
|
16
|
+
// Specifically, a request context is passed to the main executor method, which
|
|
17
|
+
// it then exposes to user-configurable `GraphQLDataSource`s.
|
|
18
|
+
// `GraphQLRequestContext` has changed in incompatible ways since AS4; for example,
|
|
19
|
+
// we represent HTTP messages using our own data structures rather than Fetches,
|
|
20
|
+
// and some fields have been removed because they relate to features that don't
|
|
21
|
+
// exist any more.
|
|
22
|
+
//
|
|
23
|
+
// In general, the future of Apollo's development is in Apollo Router, not
|
|
24
|
+
// Gateway. So rather than have a big transition where a new version of Gateway
|
|
25
|
+
// supports AS5's GraphQLRequestContext instead of AS3's, we simply teach AS5
|
|
26
|
+
// how to produce AS3-style GraphQLRequestContext objects specifically for use
|
|
27
|
+
// by Gateway. We have changed Gateway to get its TS type definitions from a new
|
|
28
|
+
// package rather than from AS3 itself, so that Gateway no longer needs to
|
|
29
|
+
// depend on Apollo Server.
|
|
30
|
+
//
|
|
31
|
+
// This function turns an AS5 GraphQLRequestContext into a
|
|
32
|
+
// GatewayGraphQLRequestContext (which is basically an AS3
|
|
33
|
+
// GraphQLRequestContext).
|
|
34
|
+
//
|
|
35
|
+
// You might think that *after* invoking the executor, we would then need to
|
|
36
|
+
// propagate any changes made by the gateway back onto the "real"
|
|
37
|
+
// GraphQLRequestContext. It turns out that for each bit of data on the request
|
|
38
|
+
// context, this is either unnecessary or impossible. (We don't need to support
|
|
39
|
+
// use cases where people break type safe, eg by changing the values of readonly
|
|
40
|
+
// fields.) Here's why:
|
|
41
|
+
//
|
|
42
|
+
// Many fields on GatewayGraphQLRequestContext are declared readonly and their
|
|
43
|
+
// values are taken directly from the real GraphQLRequestContext. This means
|
|
44
|
+
// that gateways should not change the field's value, and any mutations of the
|
|
45
|
+
// object stored in the field (say, calling
|
|
46
|
+
// `requestContext.overallCachePolicy.restrict`, as RemoteGraphQLDataSource
|
|
47
|
+
// does) already take effect.
|
|
48
|
+
//
|
|
49
|
+
// The only two fields not declared as readonly are `logger` and `debug`.
|
|
50
|
+
//
|
|
51
|
+
// Technically, a gateway implementation could set `requestContext.logger` to a
|
|
52
|
+
// different Logger without breaking the TypeScript declarations. In AS5 we
|
|
53
|
+
// don't actually have a requestContext.logger; we have `readonly
|
|
54
|
+
// requestContext.server` and `readonly server.logger`. So there's not an easy
|
|
55
|
+
// way for us to carry out this change: AS5 just doesn't let gateway or plugins
|
|
56
|
+
// override the server's logger (and generally doesn't allow the logger to
|
|
57
|
+
// change after the server is created), which seems like a simpler model. If it
|
|
58
|
+
// turns out there is a real use case for the gateway to be able to change the
|
|
59
|
+
// overall logger for the request as seen by plugins, we can fix that later.
|
|
60
|
+
//
|
|
61
|
+
// Similarly, it's not clear what the intended use case of mutating `debug` in
|
|
62
|
+
// gateway would be. `debug` has now mostly changed into
|
|
63
|
+
// `includeStacktraceInErrorResponses`. So perhaps this could be used to let you
|
|
64
|
+
// decide whether or not to include the stacktrace on a per-operation basis...
|
|
65
|
+
// but you can also use `formatError` or `didEncounterErrors` for this perhaps?
|
|
66
|
+
// In any case, AS5 doesn't track `includeStacktraceInErrorResponses` on a
|
|
67
|
+
// per-operation basis; if we find a use case for this we can add it later.
|
|
68
|
+
//
|
|
69
|
+
// So we'll just ignore changes to `logger` and `debug`.
|
|
70
|
+
//
|
|
71
|
+
// Next, there's `request`. We don't know of a use case for mutating the
|
|
72
|
+
// *request* at execution time. If there was a real use case, we could add a
|
|
73
|
+
// function that copies pieces back from the gateway `request` to the AS5
|
|
74
|
+
// request, but we're not bothering to yet.
|
|
75
|
+
//
|
|
76
|
+
// Finally, there's `response`. Sure, the executor *could* mutate `response`.
|
|
77
|
+
// But the main thing the executor is doing is *returning* a response, which
|
|
78
|
+
// then semi-overwrites `requestContext.response` anyway. So it doesn't seem
|
|
79
|
+
// like we need to support `executor` *also* overwriting response. Yet again, we
|
|
80
|
+
// can fix this if it turns out it's necessary. (That said, the executor could
|
|
81
|
+
// in theory write HTTP response headers or status, so we make sure to hook them
|
|
82
|
+
// up directly to the appropriate data in the real GraphQLRequestContext.)
|
|
83
|
+
//
|
|
84
|
+
// So all in all, it looks like it's OK for this to be a "one-way" conversion.
|
|
85
|
+
export function makeGatewayGraphQLRequestContext<TContext extends BaseContext>(
|
|
86
|
+
newRequestContext: GraphQLRequestContextExecutionDidStart<TContext>,
|
|
87
|
+
server: ApolloServer<TContext>,
|
|
88
|
+
internals: ApolloServerInternals<TContext>,
|
|
89
|
+
): GatewayGraphQLRequestContext {
|
|
90
|
+
const request: GatewayGraphQLRequest = {};
|
|
91
|
+
if ('query' in newRequestContext.request) {
|
|
92
|
+
request.query = newRequestContext.request.query;
|
|
93
|
+
}
|
|
94
|
+
if ('operationName' in newRequestContext.request) {
|
|
95
|
+
request.operationName = newRequestContext.request.operationName;
|
|
96
|
+
}
|
|
97
|
+
if ('variables' in newRequestContext.request) {
|
|
98
|
+
request.variables = newRequestContext.request.variables;
|
|
99
|
+
}
|
|
100
|
+
if ('extensions' in newRequestContext.request) {
|
|
101
|
+
request.extensions = newRequestContext.request.extensions;
|
|
102
|
+
}
|
|
103
|
+
if (newRequestContext.request.http) {
|
|
104
|
+
const newHttp = newRequestContext.request.http;
|
|
105
|
+
const needQuestion =
|
|
106
|
+
newHttp.search !== '' && !newHttp.search.startsWith('?');
|
|
107
|
+
request.http = {
|
|
108
|
+
method: newHttp.method,
|
|
109
|
+
// As of AS4, we no longer attempt to track complete URLs (just the search
|
|
110
|
+
// parameters used in GET requests). So we have to fake them for Gateway.
|
|
111
|
+
url: `https://unknown-url.invalid/${needQuestion ? '?' : ''}${
|
|
112
|
+
newHttp.search
|
|
113
|
+
}`,
|
|
114
|
+
headers: new FetcherHeadersForHeaderMap(newHttp.headers),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const response: GatewayGraphQLResponse = {
|
|
119
|
+
http: {
|
|
120
|
+
headers: new FetcherHeadersForHeaderMap(
|
|
121
|
+
newRequestContext.response.http.headers,
|
|
122
|
+
),
|
|
123
|
+
get status() {
|
|
124
|
+
return newRequestContext.response.http.status;
|
|
125
|
+
},
|
|
126
|
+
set status(newStatus) {
|
|
127
|
+
newRequestContext.response.http.status = newStatus;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
// We leave off `body` because it hasn't been set yet.
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
request,
|
|
135
|
+
response,
|
|
136
|
+
logger: server.logger,
|
|
137
|
+
schema: newRequestContext.schema,
|
|
138
|
+
// For the sake of typechecking, we still provide this field, but we don't
|
|
139
|
+
// calculate it. If somebody really needs it in their gateway
|
|
140
|
+
// implementation, they're welcome to copy
|
|
141
|
+
// https://github.com/apollographql/apollo-server/blob/3f218e78/packages/apollo-server-core/src/utils/schemaHash.ts
|
|
142
|
+
// into their code.
|
|
143
|
+
schemaHash:
|
|
144
|
+
'schemaHash no longer exists since Apollo Server 4' as GatewaySchemaHash,
|
|
145
|
+
context: newRequestContext.contextValue,
|
|
146
|
+
cache: server.cache,
|
|
147
|
+
queryHash: newRequestContext.queryHash,
|
|
148
|
+
document: newRequestContext.document,
|
|
149
|
+
source: newRequestContext.source,
|
|
150
|
+
operationName: newRequestContext.operationName,
|
|
151
|
+
operation: newRequestContext.operation,
|
|
152
|
+
errors: newRequestContext.errors,
|
|
153
|
+
metrics: newRequestContext.metrics,
|
|
154
|
+
debug: internals.includeStacktraceInErrorResponses,
|
|
155
|
+
overallCachePolicy: newRequestContext.overallCachePolicy,
|
|
156
|
+
requestIsBatched: newRequestContext.requestIsBatched,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// An implementation of the W3C-style headers class used by Gateway (and AS3),
|
|
161
|
+
// backed by AS5's HeaderMap. Changes are written directly to the HeaderMap, so
|
|
162
|
+
// any concurrent writes to the underlying HeaderMap (eg from a plugin) can be
|
|
163
|
+
// seen immediately by the gateway and vice versa.
|
|
164
|
+
class FetcherHeadersForHeaderMap implements FetcherHeaders {
|
|
165
|
+
constructor(private map: HeaderMap) {}
|
|
166
|
+
append(name: string, value: string) {
|
|
167
|
+
if (this.map.has(name)) {
|
|
168
|
+
this.map.set(name, this.map.get(name) + ', ' + value);
|
|
169
|
+
} else {
|
|
170
|
+
this.map.set(name, value);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
delete(name: string) {
|
|
174
|
+
this.map.delete(name);
|
|
175
|
+
}
|
|
176
|
+
get(name: string): string | null {
|
|
177
|
+
return this.map.get(name) ?? null;
|
|
178
|
+
}
|
|
179
|
+
has(name: string): boolean {
|
|
180
|
+
return this.map.has(name);
|
|
181
|
+
}
|
|
182
|
+
set(name: string, value: string) {
|
|
183
|
+
this.map.set(name, value);
|
|
184
|
+
}
|
|
185
|
+
entries(): Iterator<[string, string]> {
|
|
186
|
+
return this.map.entries();
|
|
187
|
+
}
|
|
188
|
+
keys(): Iterator<string> {
|
|
189
|
+
return this.map.keys();
|
|
190
|
+
}
|
|
191
|
+
values(): Iterator<string> {
|
|
192
|
+
return this.map.values();
|
|
193
|
+
}
|
|
194
|
+
[Symbol.iterator](): Iterator<[string, string]> {
|
|
195
|
+
return this.map.entries();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2019 Joseph Gentle
|
|
2
|
+
|
|
3
|
+
// Permission to use, copy, modify, and / or distribute this software for any
|
|
4
|
+
// purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
// copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
9
|
+
// FITNESS.IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
// PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
|
|
15
|
+
export type Resolvable<T> = Promise<T> & {
|
|
16
|
+
resolve: (t: T) => void;
|
|
17
|
+
reject: (e: any) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default <T = void>(): Resolvable<T> => {
|
|
21
|
+
let resolve: (val: T) => void;
|
|
22
|
+
let reject: (err: any) => void;
|
|
23
|
+
const promise = new Promise<T>((_resolve, _reject) => {
|
|
24
|
+
resolve = _resolve;
|
|
25
|
+
reject = _reject;
|
|
26
|
+
}) as Resolvable<T>;
|
|
27
|
+
promise.resolve = resolve!;
|
|
28
|
+
promise.reject = reject!;
|
|
29
|
+
return promise;
|
|
30
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GraphQLSchema,
|
|
3
|
+
type GraphQLField,
|
|
4
|
+
getNamedType,
|
|
5
|
+
GraphQLObjectType,
|
|
6
|
+
type GraphQLFieldResolver,
|
|
7
|
+
defaultFieldResolver,
|
|
8
|
+
} from 'graphql';
|
|
9
|
+
import type {
|
|
10
|
+
BaseContext,
|
|
11
|
+
GraphQLRequestExecutionListener,
|
|
12
|
+
} from '../externalTypes/index.js';
|
|
13
|
+
|
|
14
|
+
export const symbolExecutionDispatcherWillResolveField = Symbol(
|
|
15
|
+
'apolloServerExecutionDispatcherWillResolveField',
|
|
16
|
+
);
|
|
17
|
+
export const symbolUserFieldResolver = Symbol('apolloServerUserFieldResolver');
|
|
18
|
+
const symbolPluginsEnabled = Symbol('apolloServerPluginsEnabled');
|
|
19
|
+
|
|
20
|
+
export function enablePluginsForSchemaResolvers<TContext extends BaseContext>(
|
|
21
|
+
schema: GraphQLSchema & { [symbolPluginsEnabled]?: boolean },
|
|
22
|
+
) {
|
|
23
|
+
if (pluginsEnabledForSchemaResolvers(schema)) {
|
|
24
|
+
return schema;
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(schema, symbolPluginsEnabled, {
|
|
27
|
+
value: true,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const typeMap = schema.getTypeMap();
|
|
31
|
+
Object.values(typeMap).forEach((type) => {
|
|
32
|
+
if (
|
|
33
|
+
!getNamedType(type).name.startsWith('__') &&
|
|
34
|
+
type instanceof GraphQLObjectType
|
|
35
|
+
) {
|
|
36
|
+
const fields = type.getFields();
|
|
37
|
+
Object.values(fields).forEach((field) => {
|
|
38
|
+
wrapField<TContext>(field);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return schema;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function pluginsEnabledForSchemaResolvers(
|
|
47
|
+
schema: GraphQLSchema & { [symbolPluginsEnabled]?: boolean },
|
|
48
|
+
): boolean {
|
|
49
|
+
return !!schema[symbolPluginsEnabled];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function wrapField<TContext extends BaseContext>(
|
|
53
|
+
field: GraphQLField<any, any>,
|
|
54
|
+
): void {
|
|
55
|
+
const originalFieldResolve = field.resolve;
|
|
56
|
+
|
|
57
|
+
field.resolve = (source, args, contextValue, info) => {
|
|
58
|
+
const willResolveField = contextValue?.[
|
|
59
|
+
symbolExecutionDispatcherWillResolveField
|
|
60
|
+
] as
|
|
61
|
+
| GraphQLRequestExecutionListener<TContext>['willResolveField']
|
|
62
|
+
| undefined;
|
|
63
|
+
|
|
64
|
+
const userFieldResolver = contextValue?.[symbolUserFieldResolver] as
|
|
65
|
+
| GraphQLFieldResolver<any, any>
|
|
66
|
+
| undefined;
|
|
67
|
+
|
|
68
|
+
// The technique for implementing a "did resolve field" is accomplished by
|
|
69
|
+
// returning a function from the `willResolveField` handler. While there
|
|
70
|
+
// may be several callbacks, depending on the number of plugins which have
|
|
71
|
+
// implemented a `willResolveField` hook, this hook will call them all
|
|
72
|
+
// as dictated by the dispatcher. We will call this when object
|
|
73
|
+
// resolution is complete.
|
|
74
|
+
const didResolveField =
|
|
75
|
+
typeof willResolveField === 'function' &&
|
|
76
|
+
willResolveField({ source, args, contextValue, info });
|
|
77
|
+
|
|
78
|
+
const fieldResolver =
|
|
79
|
+
originalFieldResolve || userFieldResolver || defaultFieldResolver;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const result = fieldResolver(source, args, contextValue, info);
|
|
83
|
+
|
|
84
|
+
// Call the stack's handlers either immediately (if result is not a
|
|
85
|
+
// Promise) or once the Promise is done. Then return that same
|
|
86
|
+
// maybe-Promise value.
|
|
87
|
+
if (typeof didResolveField === 'function') {
|
|
88
|
+
whenResultIsFinished(result, didResolveField);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
// Normally it's a bad sign to see an error both handled and
|
|
93
|
+
// re-thrown. But it is useful to allow extensions to track errors while
|
|
94
|
+
// still handling them in the normal GraphQL way.
|
|
95
|
+
if (typeof didResolveField === 'function') {
|
|
96
|
+
didResolveField(error as Error);
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isPromise(x: any): boolean {
|
|
104
|
+
return x && typeof x.then === 'function';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Given result (which may be a Promise or an array some of whose elements are
|
|
108
|
+
// promises) Promises, set up 'callback' to be invoked when result is fully
|
|
109
|
+
// resolved. (Unfortunately, this does not perfectly handle every possible
|
|
110
|
+
// return value shape, such as arrays of arrays of Promises.)
|
|
111
|
+
export function whenResultIsFinished(
|
|
112
|
+
result: any,
|
|
113
|
+
callback: (err: Error | null, result?: any) => void,
|
|
114
|
+
) {
|
|
115
|
+
if (isPromise(result)) {
|
|
116
|
+
result.then(
|
|
117
|
+
(r: any) => whenResultIsFinished(r, callback),
|
|
118
|
+
(err: Error) => callback(err),
|
|
119
|
+
);
|
|
120
|
+
} else if (Array.isArray(result)) {
|
|
121
|
+
if (result.some(isPromise)) {
|
|
122
|
+
Promise.all(result).then(
|
|
123
|
+
(r: any) => callback(null, r),
|
|
124
|
+
(err: Error) => callback(err),
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
callback(null, result);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
callback(null, result);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { Logger } from '@apollo/utils.logger';
|
|
2
|
+
import type { GraphQLSchema } from 'graphql';
|
|
3
|
+
import type {
|
|
4
|
+
GatewayExecutor,
|
|
5
|
+
GatewayInterface,
|
|
6
|
+
GatewayUnsubscriber,
|
|
7
|
+
} from '@apollo/server-gateway-interface';
|
|
8
|
+
import type { SchemaDerivedData } from '../ApolloServer.js';
|
|
9
|
+
import type {
|
|
10
|
+
ApolloConfig,
|
|
11
|
+
GraphQLSchemaContext,
|
|
12
|
+
} from '../externalTypes/index.js';
|
|
13
|
+
|
|
14
|
+
type SchemaDerivedDataProvider = (
|
|
15
|
+
apiSchema: GraphQLSchema,
|
|
16
|
+
) => SchemaDerivedData;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An async-safe class for tracking changes in schemas and schema-derived data.
|
|
20
|
+
*
|
|
21
|
+
* Specifically, as long as start() is called (and completes) before stop() is
|
|
22
|
+
* called, any set of executions of public methods is linearizable.
|
|
23
|
+
*
|
|
24
|
+
* Note that linearizability in Javascript is trivial if all public methods are
|
|
25
|
+
* non-async, but increasingly difficult to guarantee if public methods become
|
|
26
|
+
* async. Accordingly, if you believe a public method should be async, think
|
|
27
|
+
* carefully on whether it's worth the mental overhead. (E.g. if you wished that
|
|
28
|
+
* a callback was async, consider instead resolving a Promise in a non-async
|
|
29
|
+
* callback and having your async code wait on the Promise in setTimeout().)
|
|
30
|
+
*/
|
|
31
|
+
export class SchemaManager {
|
|
32
|
+
private readonly logger: Logger;
|
|
33
|
+
private readonly schemaDerivedDataProvider: SchemaDerivedDataProvider;
|
|
34
|
+
private readonly onSchemaLoadOrUpdateListeners = new Set<
|
|
35
|
+
(schemaContext: GraphQLSchemaContext) => void
|
|
36
|
+
>();
|
|
37
|
+
private isStopped = false;
|
|
38
|
+
private schemaDerivedData?: SchemaDerivedData;
|
|
39
|
+
private schemaContext?: GraphQLSchemaContext;
|
|
40
|
+
|
|
41
|
+
// For state that's specific to the mode of operation.
|
|
42
|
+
private readonly modeSpecificState:
|
|
43
|
+
| {
|
|
44
|
+
readonly mode: 'gateway';
|
|
45
|
+
readonly gateway: GatewayInterface;
|
|
46
|
+
readonly apolloConfig: ApolloConfig;
|
|
47
|
+
unsubscribeFromGateway?: GatewayUnsubscriber;
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
readonly mode: 'schema';
|
|
51
|
+
readonly apiSchema: GraphQLSchema;
|
|
52
|
+
readonly schemaDerivedData: SchemaDerivedData;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
options: (
|
|
57
|
+
| { gateway: GatewayInterface; apolloConfig: ApolloConfig }
|
|
58
|
+
| { apiSchema: GraphQLSchema }
|
|
59
|
+
) & {
|
|
60
|
+
logger: Logger;
|
|
61
|
+
schemaDerivedDataProvider: SchemaDerivedDataProvider;
|
|
62
|
+
},
|
|
63
|
+
) {
|
|
64
|
+
this.logger = options.logger;
|
|
65
|
+
this.schemaDerivedDataProvider = options.schemaDerivedDataProvider;
|
|
66
|
+
if ('gateway' in options) {
|
|
67
|
+
this.modeSpecificState = {
|
|
68
|
+
mode: 'gateway',
|
|
69
|
+
gateway: options.gateway,
|
|
70
|
+
apolloConfig: options.apolloConfig,
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
this.modeSpecificState = {
|
|
74
|
+
mode: 'schema',
|
|
75
|
+
apiSchema: options.apiSchema,
|
|
76
|
+
// The caller of the constructor expects us to fail early if the schema
|
|
77
|
+
// given is invalid/has errors, so we call the provider here. We also
|
|
78
|
+
// pass the result to start(), as the provider can be expensive to call.
|
|
79
|
+
schemaDerivedData: options.schemaDerivedDataProvider(options.apiSchema),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Calling start() will:
|
|
86
|
+
* - Start gateway schema fetching (if a gateway was provided).
|
|
87
|
+
* - Initialize schema-derived data.
|
|
88
|
+
* - Synchronously notify onSchemaLoadOrUpdate() listeners of schema load, and
|
|
89
|
+
* asynchronously notify them of schema updates.
|
|
90
|
+
* - If we started a gateway, returns the gateway's executor; otherwise null.
|
|
91
|
+
*/
|
|
92
|
+
public async start(): Promise<GatewayExecutor | null> {
|
|
93
|
+
if (this.modeSpecificState.mode === 'gateway') {
|
|
94
|
+
const gateway = this.modeSpecificState.gateway;
|
|
95
|
+
if (gateway.onSchemaLoadOrUpdate) {
|
|
96
|
+
// Use onSchemaLoadOrUpdate, as it reports the core supergraph SDL and
|
|
97
|
+
// always reports the initial schema load.
|
|
98
|
+
this.modeSpecificState.unsubscribeFromGateway =
|
|
99
|
+
gateway.onSchemaLoadOrUpdate((schemaContext) => {
|
|
100
|
+
this.processSchemaLoadOrUpdateEvent(schemaContext);
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error(
|
|
104
|
+
"Unexpectedly couldn't find onSchemaLoadOrUpdate on gateway",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const config = await this.modeSpecificState.gateway.load({
|
|
109
|
+
apollo: this.modeSpecificState.apolloConfig,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return config.executor;
|
|
113
|
+
} else {
|
|
114
|
+
this.processSchemaLoadOrUpdateEvent(
|
|
115
|
+
{
|
|
116
|
+
apiSchema: this.modeSpecificState.apiSchema,
|
|
117
|
+
},
|
|
118
|
+
this.modeSpecificState.schemaDerivedData,
|
|
119
|
+
);
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Registers a listener for schema load/update events. Note that the latest
|
|
126
|
+
* event is buffered, i.e.
|
|
127
|
+
* - If registered before start(), this method will throw. (We have no need
|
|
128
|
+
* for registration before start(), but this is easy enough to change.)
|
|
129
|
+
* - If registered after start() but before stop(), the callback will be first
|
|
130
|
+
* called in this method (for whatever the current schema is), and then
|
|
131
|
+
* later for updates.
|
|
132
|
+
* - If registered after stop(), the callback will never be called.
|
|
133
|
+
*
|
|
134
|
+
* For gateways, a core supergraph SDL will be provided to the callback.
|
|
135
|
+
*
|
|
136
|
+
* @param callback The listener to execute on schema load/updates.
|
|
137
|
+
*/
|
|
138
|
+
public onSchemaLoadOrUpdate(
|
|
139
|
+
callback: (schemaContext: GraphQLSchemaContext) => void,
|
|
140
|
+
): GatewayUnsubscriber {
|
|
141
|
+
if (!this.schemaContext) {
|
|
142
|
+
throw new Error('You must call start() before onSchemaLoadOrUpdate()');
|
|
143
|
+
}
|
|
144
|
+
if (!this.isStopped) {
|
|
145
|
+
try {
|
|
146
|
+
callback(this.schemaContext);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
// Note that onSchemaLoadOrUpdate() is currently only called from
|
|
149
|
+
// ApolloServer._start(), so we throw here to alert the user early
|
|
150
|
+
// that their callback is failing.
|
|
151
|
+
throw new Error(
|
|
152
|
+
`An error was thrown from an 'onSchemaLoadOrUpdate' listener: ${
|
|
153
|
+
(e as Error).message
|
|
154
|
+
}`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.onSchemaLoadOrUpdateListeners.add(callback);
|
|
159
|
+
|
|
160
|
+
return () => {
|
|
161
|
+
this.onSchemaLoadOrUpdateListeners.delete(callback);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Get the schema-derived state for the current schema. This throws if called
|
|
167
|
+
* before start() is called.
|
|
168
|
+
*/
|
|
169
|
+
public getSchemaDerivedData(): SchemaDerivedData {
|
|
170
|
+
if (!this.schemaDerivedData) {
|
|
171
|
+
throw new Error('You must call start() before getSchemaDerivedData()');
|
|
172
|
+
}
|
|
173
|
+
return this.schemaDerivedData;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Calling stop() will:
|
|
178
|
+
* - Stop gateway schema fetching (if a gateway was provided).
|
|
179
|
+
* - Note that this specific step may not succeed if gateway is old.
|
|
180
|
+
* - Stop updating schema-derived data.
|
|
181
|
+
* - Stop notifying onSchemaLoadOrUpdate() listeners.
|
|
182
|
+
*/
|
|
183
|
+
public async stop(): Promise<void> {
|
|
184
|
+
this.isStopped = true;
|
|
185
|
+
if (this.modeSpecificState.mode === 'gateway') {
|
|
186
|
+
this.modeSpecificState.unsubscribeFromGateway?.();
|
|
187
|
+
await this.modeSpecificState.gateway.stop?.();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private processSchemaLoadOrUpdateEvent(
|
|
192
|
+
schemaContext: GraphQLSchemaContext,
|
|
193
|
+
schemaDerivedData?: SchemaDerivedData,
|
|
194
|
+
): void {
|
|
195
|
+
if (!this.isStopped) {
|
|
196
|
+
this.schemaDerivedData =
|
|
197
|
+
schemaDerivedData ??
|
|
198
|
+
this.schemaDerivedDataProvider(schemaContext.apiSchema);
|
|
199
|
+
this.schemaContext = schemaContext;
|
|
200
|
+
this.onSchemaLoadOrUpdateListeners.forEach((listener) => {
|
|
201
|
+
try {
|
|
202
|
+
listener(schemaContext);
|
|
203
|
+
} catch (e) {
|
|
204
|
+
this.logger.error(
|
|
205
|
+
"An error was thrown from an 'onSchemaLoadOrUpdate' listener",
|
|
206
|
+
);
|
|
207
|
+
this.logger.error(e);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Server } from 'http';
|
|
2
|
+
import type { AddressInfo } from 'net';
|
|
3
|
+
import { format } from 'url';
|
|
4
|
+
|
|
5
|
+
export function urlForHttpServer(httpServer: Server): string {
|
|
6
|
+
const { address, port } = httpServer.address() as AddressInfo;
|
|
7
|
+
|
|
8
|
+
// Convert IPs which mean "any address" (IPv4 or IPv6) into localhost
|
|
9
|
+
// corresponding loopback ip. Note that the url field we're setting is
|
|
10
|
+
// primarily for consumption by our test suite. If this heuristic is wrong for
|
|
11
|
+
// your use case, explicitly specify a frontend host (in the `host` option
|
|
12
|
+
// when listening).
|
|
13
|
+
const hostname = address === '' || address === '::' ? 'localhost' : address;
|
|
14
|
+
|
|
15
|
+
return format({
|
|
16
|
+
protocol: 'http',
|
|
17
|
+
hostname,
|
|
18
|
+
port,
|
|
19
|
+
pathname: '/',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphQLError,
|
|
3
|
+
type ValidationRule,
|
|
4
|
+
type ValidationContext,
|
|
5
|
+
} from 'graphql';
|
|
6
|
+
import { ApolloServerValidationErrorCode } from '../errors/index.js';
|
|
7
|
+
|
|
8
|
+
export const NoIntrospection: ValidationRule = (
|
|
9
|
+
context: ValidationContext,
|
|
10
|
+
) => ({
|
|
11
|
+
Field(node) {
|
|
12
|
+
if (node.name.value === '__schema' || node.name.value === '__type') {
|
|
13
|
+
context.reportError(
|
|
14
|
+
new GraphQLError(
|
|
15
|
+
'GraphQL introspection is not allowed by Apollo Server, but the query contained __schema or __type. To enable introspection, pass introspection: true to ApolloServer in production',
|
|
16
|
+
{
|
|
17
|
+
nodes: [node],
|
|
18
|
+
extensions: {
|
|
19
|
+
validationErrorCode:
|
|
20
|
+
ApolloServerValidationErrorCode.INTROSPECTION_DISABLED,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
});
|