@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.
Files changed (557) hide show
  1. package/README.md +40 -0
  2. package/changes.json +46 -0
  3. package/dist/cjs/ApolloServer.d.ts +126 -0
  4. package/dist/cjs/ApolloServer.d.ts.map +1 -0
  5. package/dist/cjs/ApolloServer.js +726 -0
  6. package/dist/cjs/ApolloServer.js.map +1 -0
  7. package/dist/cjs/cachePolicy.d.ts +3 -0
  8. package/dist/cjs/cachePolicy.d.ts.map +1 -0
  9. package/dist/cjs/cachePolicy.js +33 -0
  10. package/dist/cjs/cachePolicy.js.map +1 -0
  11. package/dist/cjs/determineApolloConfig.d.ts +4 -0
  12. package/dist/cjs/determineApolloConfig.d.ts.map +1 -0
  13. package/dist/cjs/determineApolloConfig.js +58 -0
  14. package/dist/cjs/determineApolloConfig.js.map +1 -0
  15. package/dist/cjs/errorNormalize.d.ts +12 -0
  16. package/dist/cjs/errorNormalize.d.ts.map +1 -0
  17. package/dist/cjs/errorNormalize.js +71 -0
  18. package/dist/cjs/errorNormalize.js.map +1 -0
  19. package/dist/cjs/errors/index.d.ts +16 -0
  20. package/dist/cjs/errors/index.d.ts.map +1 -0
  21. package/dist/cjs/errors/index.js +28 -0
  22. package/dist/cjs/errors/index.js.map +1 -0
  23. package/dist/cjs/externalTypes/constructor.d.ts +78 -0
  24. package/dist/cjs/externalTypes/constructor.d.ts.map +1 -0
  25. package/dist/cjs/externalTypes/constructor.js +3 -0
  26. package/dist/cjs/externalTypes/constructor.js.map +1 -0
  27. package/dist/cjs/externalTypes/context.d.ts +4 -0
  28. package/dist/cjs/externalTypes/context.d.ts.map +1 -0
  29. package/dist/cjs/externalTypes/context.js +3 -0
  30. package/dist/cjs/externalTypes/context.js.map +1 -0
  31. package/dist/cjs/externalTypes/graphql.d.ts +41 -0
  32. package/dist/cjs/externalTypes/graphql.d.ts.map +1 -0
  33. package/dist/cjs/externalTypes/graphql.js +3 -0
  34. package/dist/cjs/externalTypes/graphql.js.map +1 -0
  35. package/dist/cjs/externalTypes/http.d.ts +22 -0
  36. package/dist/cjs/externalTypes/http.d.ts.map +1 -0
  37. package/dist/cjs/externalTypes/http.js +3 -0
  38. package/dist/cjs/externalTypes/http.js.map +1 -0
  39. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts +28 -0
  40. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts.map +1 -0
  41. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.js +3 -0
  42. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha2.js.map +1 -0
  43. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts +43 -0
  44. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts.map +1 -0
  45. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.js +3 -0
  46. package/dist/cjs/externalTypes/incrementalDeliveryPolyfillAlpha9.js.map +1 -0
  47. package/dist/cjs/externalTypes/index.d.ts +9 -0
  48. package/dist/cjs/externalTypes/index.d.ts.map +1 -0
  49. package/dist/cjs/externalTypes/index.js +3 -0
  50. package/dist/cjs/externalTypes/index.js.map +1 -0
  51. package/dist/cjs/externalTypes/plugins.d.ts +75 -0
  52. package/dist/cjs/externalTypes/plugins.d.ts.map +1 -0
  53. package/dist/cjs/externalTypes/plugins.js +3 -0
  54. package/dist/cjs/externalTypes/plugins.js.map +1 -0
  55. package/dist/cjs/externalTypes/requestPipeline.d.ts +50 -0
  56. package/dist/cjs/externalTypes/requestPipeline.d.ts.map +1 -0
  57. package/dist/cjs/externalTypes/requestPipeline.js +3 -0
  58. package/dist/cjs/externalTypes/requestPipeline.js.map +1 -0
  59. package/dist/cjs/generated/packageVersion.d.ts +2 -0
  60. package/dist/cjs/generated/packageVersion.d.ts.map +1 -0
  61. package/dist/cjs/generated/packageVersion.js +5 -0
  62. package/dist/cjs/generated/packageVersion.js.map +1 -0
  63. package/dist/cjs/httpBatching.d.ts +4 -0
  64. package/dist/cjs/httpBatching.d.ts.map +1 -0
  65. package/dist/cjs/httpBatching.js +58 -0
  66. package/dist/cjs/httpBatching.js.map +1 -0
  67. package/dist/cjs/incrementalDeliveryPolyfill.d.ts +82 -0
  68. package/dist/cjs/incrementalDeliveryPolyfill.d.ts.map +1 -0
  69. package/dist/cjs/incrementalDeliveryPolyfill.js +74 -0
  70. package/dist/cjs/incrementalDeliveryPolyfill.js.map +1 -0
  71. package/dist/cjs/index.d.ts +4 -0
  72. package/dist/cjs/index.d.ts.map +1 -0
  73. package/dist/cjs/index.js +23 -0
  74. package/dist/cjs/index.js.map +1 -0
  75. package/dist/cjs/internalErrorClasses.d.ts +28 -0
  76. package/dist/cjs/internalErrorClasses.d.ts.map +1 -0
  77. package/dist/cjs/internalErrorClasses.js +91 -0
  78. package/dist/cjs/internalErrorClasses.js.map +1 -0
  79. package/dist/cjs/internalPlugin.d.ts +9 -0
  80. package/dist/cjs/internalPlugin.d.ts.map +1 -0
  81. package/dist/cjs/internalPlugin.js +11 -0
  82. package/dist/cjs/internalPlugin.js.map +1 -0
  83. package/dist/cjs/package.json +1 -0
  84. package/dist/cjs/plugin/cacheControl/index.d.ts +9 -0
  85. package/dist/cjs/plugin/cacheControl/index.d.ts.map +1 -0
  86. package/dist/cjs/plugin/cacheControl/index.js +223 -0
  87. package/dist/cjs/plugin/cacheControl/index.js.map +1 -0
  88. package/dist/cjs/plugin/disableSuggestions/index.d.ts +3 -0
  89. package/dist/cjs/plugin/disableSuggestions/index.d.ts.map +1 -0
  90. package/dist/cjs/plugin/disableSuggestions/index.js +22 -0
  91. package/dist/cjs/plugin/disableSuggestions/index.js.map +1 -0
  92. package/dist/cjs/plugin/disabled/index.d.ts +7 -0
  93. package/dist/cjs/plugin/disabled/index.d.ts.map +1 -0
  94. package/dist/cjs/plugin/disabled/index.js +30 -0
  95. package/dist/cjs/plugin/disabled/index.js.map +1 -0
  96. package/dist/cjs/plugin/drainHttpServer/index.d.ts +8 -0
  97. package/dist/cjs/plugin/drainHttpServer/index.d.ts.map +1 -0
  98. package/dist/cjs/plugin/drainHttpServer/index.js +19 -0
  99. package/dist/cjs/plugin/drainHttpServer/index.js.map +1 -0
  100. package/dist/cjs/plugin/drainHttpServer/stoppable.d.ts +10 -0
  101. package/dist/cjs/plugin/drainHttpServer/stoppable.d.ts.map +1 -0
  102. package/dist/cjs/plugin/drainHttpServer/stoppable.js +54 -0
  103. package/dist/cjs/plugin/drainHttpServer/stoppable.js.map +1 -0
  104. package/dist/cjs/plugin/inlineTrace/index.d.ts +8 -0
  105. package/dist/cjs/plugin/inlineTrace/index.d.ts.map +1 -0
  106. package/dist/cjs/plugin/inlineTrace/index.js +70 -0
  107. package/dist/cjs/plugin/inlineTrace/index.js.map +1 -0
  108. package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.d.ts +4 -0
  109. package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.d.ts.map +1 -0
  110. package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.js +143 -0
  111. package/dist/cjs/plugin/landingPage/default/getEmbeddedHTML.js.map +1 -0
  112. package/dist/cjs/plugin/landingPage/default/index.d.ts +9 -0
  113. package/dist/cjs/plugin/landingPage/default/index.d.ts.map +1 -0
  114. package/dist/cjs/plugin/landingPage/default/index.js +146 -0
  115. package/dist/cjs/plugin/landingPage/default/index.js.map +1 -0
  116. package/dist/cjs/plugin/landingPage/default/types.d.ts +56 -0
  117. package/dist/cjs/plugin/landingPage/default/types.d.ts.map +1 -0
  118. package/dist/cjs/plugin/landingPage/default/types.js +3 -0
  119. package/dist/cjs/plugin/landingPage/default/types.js.map +1 -0
  120. package/dist/cjs/plugin/schemaIsSubgraph.d.ts +3 -0
  121. package/dist/cjs/plugin/schemaIsSubgraph.d.ts.map +1 -0
  122. package/dist/cjs/plugin/schemaIsSubgraph.js +23 -0
  123. package/dist/cjs/plugin/schemaIsSubgraph.js.map +1 -0
  124. package/dist/cjs/plugin/schemaReporting/index.d.ts +10 -0
  125. package/dist/cjs/plugin/schemaReporting/index.d.ts.map +1 -0
  126. package/dist/cjs/plugin/schemaReporting/index.js +104 -0
  127. package/dist/cjs/plugin/schemaReporting/index.js.map +1 -0
  128. package/dist/cjs/plugin/schemaReporting/schemaReporter.d.ts +33 -0
  129. package/dist/cjs/plugin/schemaReporting/schemaReporter.d.ts.map +1 -0
  130. package/dist/cjs/plugin/schemaReporting/schemaReporter.js +147 -0
  131. package/dist/cjs/plugin/schemaReporting/schemaReporter.js.map +1 -0
  132. package/dist/cjs/plugin/subscriptionCallback/index.d.ts +12 -0
  133. package/dist/cjs/plugin/subscriptionCallback/index.d.ts.map +1 -0
  134. package/dist/cjs/plugin/subscriptionCallback/index.js +434 -0
  135. package/dist/cjs/plugin/subscriptionCallback/index.js.map +1 -0
  136. package/dist/cjs/plugin/traceTreeBuilder.d.ts +25 -0
  137. package/dist/cjs/plugin/traceTreeBuilder.d.ts.map +1 -0
  138. package/dist/cjs/plugin/traceTreeBuilder.js +201 -0
  139. package/dist/cjs/plugin/traceTreeBuilder.js.map +1 -0
  140. package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts +3 -0
  141. package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts.map +1 -0
  142. package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.js +44 -0
  143. package/dist/cjs/plugin/usageReporting/defaultSendOperationsAsTrace.js.map +1 -0
  144. package/dist/cjs/plugin/usageReporting/durationHistogram.d.ts +16 -0
  145. package/dist/cjs/plugin/usageReporting/durationHistogram.d.ts.map +1 -0
  146. package/dist/cjs/plugin/usageReporting/durationHistogram.js +68 -0
  147. package/dist/cjs/plugin/usageReporting/durationHistogram.js.map +1 -0
  148. package/dist/cjs/plugin/usageReporting/index.d.ts +3 -0
  149. package/dist/cjs/plugin/usageReporting/index.d.ts.map +1 -0
  150. package/dist/cjs/plugin/usageReporting/index.js +6 -0
  151. package/dist/cjs/plugin/usageReporting/index.js.map +1 -0
  152. package/dist/cjs/plugin/usageReporting/iterateOverTrace.d.ts +7 -0
  153. package/dist/cjs/plugin/usageReporting/iterateOverTrace.d.ts.map +1 -0
  154. package/dist/cjs/plugin/usageReporting/iterateOverTrace.js +81 -0
  155. package/dist/cjs/plugin/usageReporting/iterateOverTrace.js.map +1 -0
  156. package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.d.ts +12 -0
  157. package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.d.ts.map +1 -0
  158. package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.js +33 -0
  159. package/dist/cjs/plugin/usageReporting/operationDerivedDataCache.js.map +1 -0
  160. package/dist/cjs/plugin/usageReporting/options.d.ts +60 -0
  161. package/dist/cjs/plugin/usageReporting/options.d.ts.map +1 -0
  162. package/dist/cjs/plugin/usageReporting/options.js +3 -0
  163. package/dist/cjs/plugin/usageReporting/options.js.map +1 -0
  164. package/dist/cjs/plugin/usageReporting/plugin.d.ts +7 -0
  165. package/dist/cjs/plugin/usageReporting/plugin.d.ts.map +1 -0
  166. package/dist/cjs/plugin/usageReporting/plugin.js +494 -0
  167. package/dist/cjs/plugin/usageReporting/plugin.js.map +1 -0
  168. package/dist/cjs/plugin/usageReporting/stats.d.ts +96 -0
  169. package/dist/cjs/plugin/usageReporting/stats.d.ts.map +1 -0
  170. package/dist/cjs/plugin/usageReporting/stats.js +289 -0
  171. package/dist/cjs/plugin/usageReporting/stats.js.map +1 -0
  172. package/dist/cjs/plugin/usageReporting/traceDetails.d.ts +4 -0
  173. package/dist/cjs/plugin/usageReporting/traceDetails.d.ts.map +1 -0
  174. package/dist/cjs/plugin/usageReporting/traceDetails.js +63 -0
  175. package/dist/cjs/plugin/usageReporting/traceDetails.js.map +1 -0
  176. package/dist/cjs/preventCsrf.d.ts +4 -0
  177. package/dist/cjs/preventCsrf.d.ts.map +1 -0
  178. package/dist/cjs/preventCsrf.js +41 -0
  179. package/dist/cjs/preventCsrf.js.map +1 -0
  180. package/dist/cjs/requestPipeline.d.ts +9 -0
  181. package/dist/cjs/requestPipeline.d.ts.map +1 -0
  182. package/dist/cjs/requestPipeline.js +371 -0
  183. package/dist/cjs/requestPipeline.js.map +1 -0
  184. package/dist/cjs/runHttpQuery.d.ts +15 -0
  185. package/dist/cjs/runHttpQuery.d.ts.map +1 -0
  186. package/dist/cjs/runHttpQuery.js +230 -0
  187. package/dist/cjs/runHttpQuery.js.map +1 -0
  188. package/dist/cjs/standalone/index.d.ts +25 -0
  189. package/dist/cjs/standalone/index.d.ts.map +1 -0
  190. package/dist/cjs/standalone/index.js +97 -0
  191. package/dist/cjs/standalone/index.js.map +1 -0
  192. package/dist/cjs/utils/HeaderMap.d.ts +8 -0
  193. package/dist/cjs/utils/HeaderMap.d.ts.map +1 -0
  194. package/dist/cjs/utils/HeaderMap.js +20 -0
  195. package/dist/cjs/utils/HeaderMap.js.map +1 -0
  196. package/dist/cjs/utils/UnreachableCaseError.d.ts +4 -0
  197. package/dist/cjs/utils/UnreachableCaseError.d.ts.map +1 -0
  198. package/dist/cjs/utils/UnreachableCaseError.js +10 -0
  199. package/dist/cjs/utils/UnreachableCaseError.js.map +1 -0
  200. package/dist/cjs/utils/computeCoreSchemaHash.d.ts +2 -0
  201. package/dist/cjs/utils/computeCoreSchemaHash.d.ts.map +1 -0
  202. package/dist/cjs/utils/computeCoreSchemaHash.js +8 -0
  203. package/dist/cjs/utils/computeCoreSchemaHash.js.map +1 -0
  204. package/dist/cjs/utils/invokeHooks.d.ts +7 -0
  205. package/dist/cjs/utils/invokeHooks.d.ts.map +1 -0
  206. package/dist/cjs/utils/invokeHooks.js +36 -0
  207. package/dist/cjs/utils/invokeHooks.js.map +1 -0
  208. package/dist/cjs/utils/isDefined.d.ts +2 -0
  209. package/dist/cjs/utils/isDefined.d.ts.map +1 -0
  210. package/dist/cjs/utils/isDefined.js +7 -0
  211. package/dist/cjs/utils/isDefined.js.map +1 -0
  212. package/dist/cjs/utils/makeGatewayGraphQLRequestContext.d.ts +5 -0
  213. package/dist/cjs/utils/makeGatewayGraphQLRequestContext.d.ts.map +1 -0
  214. package/dist/cjs/utils/makeGatewayGraphQLRequestContext.js +96 -0
  215. package/dist/cjs/utils/makeGatewayGraphQLRequestContext.js.map +1 -0
  216. package/dist/cjs/utils/resolvable.d.ts +7 -0
  217. package/dist/cjs/utils/resolvable.d.ts.map +1 -0
  218. package/dist/cjs/utils/resolvable.js +14 -0
  219. package/dist/cjs/utils/resolvable.js.map +1 -0
  220. package/dist/cjs/utils/schemaInstrumentation.d.ts +16 -0
  221. package/dist/cjs/utils/schemaInstrumentation.d.ts.map +1 -0
  222. package/dist/cjs/utils/schemaInstrumentation.js +75 -0
  223. package/dist/cjs/utils/schemaInstrumentation.js.map +1 -0
  224. package/dist/cjs/utils/schemaManager.d.ts +31 -0
  225. package/dist/cjs/utils/schemaManager.d.ts.map +1 -0
  226. package/dist/cjs/utils/schemaManager.js +103 -0
  227. package/dist/cjs/utils/schemaManager.js.map +1 -0
  228. package/dist/cjs/utils/urlForHttpServer.d.ts +3 -0
  229. package/dist/cjs/utils/urlForHttpServer.d.ts.map +1 -0
  230. package/dist/cjs/utils/urlForHttpServer.js +15 -0
  231. package/dist/cjs/utils/urlForHttpServer.js.map +1 -0
  232. package/dist/cjs/validationRules/NoIntrospection.d.ts +3 -0
  233. package/dist/cjs/validationRules/NoIntrospection.d.ts.map +1 -0
  234. package/dist/cjs/validationRules/NoIntrospection.js +19 -0
  235. package/dist/cjs/validationRules/NoIntrospection.js.map +1 -0
  236. package/dist/cjs/validationRules/RecursiveSelectionsLimit.d.ts +4 -0
  237. package/dist/cjs/validationRules/RecursiveSelectionsLimit.d.ts.map +1 -0
  238. package/dist/cjs/validationRules/RecursiveSelectionsLimit.js +150 -0
  239. package/dist/cjs/validationRules/RecursiveSelectionsLimit.js.map +1 -0
  240. package/dist/cjs/validationRules/index.d.ts +3 -0
  241. package/dist/cjs/validationRules/index.d.ts.map +1 -0
  242. package/dist/cjs/validationRules/index.js +9 -0
  243. package/dist/cjs/validationRules/index.js.map +1 -0
  244. package/dist/esm/ApolloServer.d.ts +126 -0
  245. package/dist/esm/ApolloServer.d.ts.map +1 -0
  246. package/dist/esm/ApolloServer.js +683 -0
  247. package/dist/esm/ApolloServer.js.map +1 -0
  248. package/dist/esm/cachePolicy.d.ts +3 -0
  249. package/dist/esm/cachePolicy.d.ts.map +1 -0
  250. package/dist/esm/cachePolicy.js +30 -0
  251. package/dist/esm/cachePolicy.js.map +1 -0
  252. package/dist/esm/determineApolloConfig.d.ts +4 -0
  253. package/dist/esm/determineApolloConfig.d.ts.map +1 -0
  254. package/dist/esm/determineApolloConfig.js +55 -0
  255. package/dist/esm/determineApolloConfig.js.map +1 -0
  256. package/dist/esm/errorNormalize.d.ts +12 -0
  257. package/dist/esm/errorNormalize.d.ts.map +1 -0
  258. package/dist/esm/errorNormalize.js +66 -0
  259. package/dist/esm/errorNormalize.js.map +1 -0
  260. package/dist/esm/errors/index.d.ts +16 -0
  261. package/dist/esm/errors/index.d.ts.map +1 -0
  262. package/dist/esm/errors/index.js +24 -0
  263. package/dist/esm/errors/index.js.map +1 -0
  264. package/dist/esm/externalTypes/constructor.d.ts +78 -0
  265. package/dist/esm/externalTypes/constructor.d.ts.map +1 -0
  266. package/dist/esm/externalTypes/constructor.js +2 -0
  267. package/dist/esm/externalTypes/constructor.js.map +1 -0
  268. package/dist/esm/externalTypes/context.d.ts +4 -0
  269. package/dist/esm/externalTypes/context.d.ts.map +1 -0
  270. package/dist/esm/externalTypes/context.js +2 -0
  271. package/dist/esm/externalTypes/context.js.map +1 -0
  272. package/dist/esm/externalTypes/graphql.d.ts +41 -0
  273. package/dist/esm/externalTypes/graphql.d.ts.map +1 -0
  274. package/dist/esm/externalTypes/graphql.js +2 -0
  275. package/dist/esm/externalTypes/graphql.js.map +1 -0
  276. package/dist/esm/externalTypes/http.d.ts +22 -0
  277. package/dist/esm/externalTypes/http.d.ts.map +1 -0
  278. package/dist/esm/externalTypes/http.js +2 -0
  279. package/dist/esm/externalTypes/http.js.map +1 -0
  280. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts +28 -0
  281. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.d.ts.map +1 -0
  282. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.js +2 -0
  283. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha2.js.map +1 -0
  284. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts +43 -0
  285. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.d.ts.map +1 -0
  286. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.js +2 -0
  287. package/dist/esm/externalTypes/incrementalDeliveryPolyfillAlpha9.js.map +1 -0
  288. package/dist/esm/externalTypes/index.d.ts +9 -0
  289. package/dist/esm/externalTypes/index.d.ts.map +1 -0
  290. package/dist/esm/externalTypes/index.js +2 -0
  291. package/dist/esm/externalTypes/index.js.map +1 -0
  292. package/dist/esm/externalTypes/plugins.d.ts +75 -0
  293. package/dist/esm/externalTypes/plugins.d.ts.map +1 -0
  294. package/dist/esm/externalTypes/plugins.js +2 -0
  295. package/dist/esm/externalTypes/plugins.js.map +1 -0
  296. package/dist/esm/externalTypes/requestPipeline.d.ts +50 -0
  297. package/dist/esm/externalTypes/requestPipeline.d.ts.map +1 -0
  298. package/dist/esm/externalTypes/requestPipeline.js +2 -0
  299. package/dist/esm/externalTypes/requestPipeline.js.map +1 -0
  300. package/dist/esm/generated/packageVersion.d.ts +2 -0
  301. package/dist/esm/generated/packageVersion.d.ts.map +1 -0
  302. package/dist/esm/generated/packageVersion.js +2 -0
  303. package/dist/esm/generated/packageVersion.js.map +1 -0
  304. package/dist/esm/httpBatching.d.ts +4 -0
  305. package/dist/esm/httpBatching.d.ts.map +1 -0
  306. package/dist/esm/httpBatching.js +55 -0
  307. package/dist/esm/httpBatching.js.map +1 -0
  308. package/dist/esm/incrementalDeliveryPolyfill.d.ts +82 -0
  309. package/dist/esm/incrementalDeliveryPolyfill.d.ts.map +1 -0
  310. package/dist/esm/incrementalDeliveryPolyfill.js +38 -0
  311. package/dist/esm/incrementalDeliveryPolyfill.js.map +1 -0
  312. package/dist/esm/index.d.ts +4 -0
  313. package/dist/esm/index.d.ts.map +1 -0
  314. package/dist/esm/index.js +4 -0
  315. package/dist/esm/index.js.map +1 -0
  316. package/dist/esm/internalErrorClasses.d.ts +28 -0
  317. package/dist/esm/internalErrorClasses.d.ts.map +1 -0
  318. package/dist/esm/internalErrorClasses.js +81 -0
  319. package/dist/esm/internalErrorClasses.js.map +1 -0
  320. package/dist/esm/internalPlugin.d.ts +9 -0
  321. package/dist/esm/internalPlugin.d.ts.map +1 -0
  322. package/dist/esm/internalPlugin.js +7 -0
  323. package/dist/esm/internalPlugin.js.map +1 -0
  324. package/dist/esm/package.json +1 -0
  325. package/dist/esm/plugin/cacheControl/index.d.ts +9 -0
  326. package/dist/esm/plugin/cacheControl/index.d.ts.map +1 -0
  327. package/dist/esm/plugin/cacheControl/index.js +220 -0
  328. package/dist/esm/plugin/cacheControl/index.js.map +1 -0
  329. package/dist/esm/plugin/disableSuggestions/index.d.ts +3 -0
  330. package/dist/esm/plugin/disableSuggestions/index.d.ts.map +1 -0
  331. package/dist/esm/plugin/disableSuggestions/index.js +19 -0
  332. package/dist/esm/plugin/disableSuggestions/index.js.map +1 -0
  333. package/dist/esm/plugin/disabled/index.d.ts +7 -0
  334. package/dist/esm/plugin/disabled/index.d.ts.map +1 -0
  335. package/dist/esm/plugin/disabled/index.js +23 -0
  336. package/dist/esm/plugin/disabled/index.js.map +1 -0
  337. package/dist/esm/plugin/drainHttpServer/index.d.ts +8 -0
  338. package/dist/esm/plugin/drainHttpServer/index.d.ts.map +1 -0
  339. package/dist/esm/plugin/drainHttpServer/index.js +16 -0
  340. package/dist/esm/plugin/drainHttpServer/index.js.map +1 -0
  341. package/dist/esm/plugin/drainHttpServer/stoppable.d.ts +10 -0
  342. package/dist/esm/plugin/drainHttpServer/stoppable.d.ts.map +1 -0
  343. package/dist/esm/plugin/drainHttpServer/stoppable.js +47 -0
  344. package/dist/esm/plugin/drainHttpServer/stoppable.js.map +1 -0
  345. package/dist/esm/plugin/inlineTrace/index.d.ts +8 -0
  346. package/dist/esm/plugin/inlineTrace/index.d.ts.map +1 -0
  347. package/dist/esm/plugin/inlineTrace/index.js +67 -0
  348. package/dist/esm/plugin/inlineTrace/index.js.map +1 -0
  349. package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.d.ts +4 -0
  350. package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.d.ts.map +1 -0
  351. package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.js +138 -0
  352. package/dist/esm/plugin/landingPage/default/getEmbeddedHTML.js.map +1 -0
  353. package/dist/esm/plugin/landingPage/default/index.d.ts +9 -0
  354. package/dist/esm/plugin/landingPage/default/index.d.ts.map +1 -0
  355. package/dist/esm/plugin/landingPage/default/index.js +141 -0
  356. package/dist/esm/plugin/landingPage/default/index.js.map +1 -0
  357. package/dist/esm/plugin/landingPage/default/types.d.ts +56 -0
  358. package/dist/esm/plugin/landingPage/default/types.d.ts.map +1 -0
  359. package/dist/esm/plugin/landingPage/default/types.js +2 -0
  360. package/dist/esm/plugin/landingPage/default/types.js.map +1 -0
  361. package/dist/esm/plugin/schemaIsSubgraph.d.ts +3 -0
  362. package/dist/esm/plugin/schemaIsSubgraph.d.ts.map +1 -0
  363. package/dist/esm/plugin/schemaIsSubgraph.js +20 -0
  364. package/dist/esm/plugin/schemaIsSubgraph.js.map +1 -0
  365. package/dist/esm/plugin/schemaReporting/index.d.ts +10 -0
  366. package/dist/esm/plugin/schemaReporting/index.d.ts.map +1 -0
  367. package/dist/esm/plugin/schemaReporting/index.js +98 -0
  368. package/dist/esm/plugin/schemaReporting/index.js.map +1 -0
  369. package/dist/esm/plugin/schemaReporting/schemaReporter.d.ts +33 -0
  370. package/dist/esm/plugin/schemaReporting/schemaReporter.d.ts.map +1 -0
  371. package/dist/esm/plugin/schemaReporting/schemaReporter.js +143 -0
  372. package/dist/esm/plugin/schemaReporting/schemaReporter.js.map +1 -0
  373. package/dist/esm/plugin/subscriptionCallback/index.d.ts +12 -0
  374. package/dist/esm/plugin/subscriptionCallback/index.d.ts.map +1 -0
  375. package/dist/esm/plugin/subscriptionCallback/index.js +428 -0
  376. package/dist/esm/plugin/subscriptionCallback/index.js.map +1 -0
  377. package/dist/esm/plugin/traceTreeBuilder.d.ts +25 -0
  378. package/dist/esm/plugin/traceTreeBuilder.d.ts.map +1 -0
  379. package/dist/esm/plugin/traceTreeBuilder.js +196 -0
  380. package/dist/esm/plugin/traceTreeBuilder.js.map +1 -0
  381. package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts +3 -0
  382. package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.d.ts.map +1 -0
  383. package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.js +41 -0
  384. package/dist/esm/plugin/usageReporting/defaultSendOperationsAsTrace.js.map +1 -0
  385. package/dist/esm/plugin/usageReporting/durationHistogram.d.ts +16 -0
  386. package/dist/esm/plugin/usageReporting/durationHistogram.d.ts.map +1 -0
  387. package/dist/esm/plugin/usageReporting/durationHistogram.js +64 -0
  388. package/dist/esm/plugin/usageReporting/durationHistogram.js.map +1 -0
  389. package/dist/esm/plugin/usageReporting/index.d.ts +3 -0
  390. package/dist/esm/plugin/usageReporting/index.d.ts.map +1 -0
  391. package/dist/esm/plugin/usageReporting/index.js +2 -0
  392. package/dist/esm/plugin/usageReporting/index.js.map +1 -0
  393. package/dist/esm/plugin/usageReporting/iterateOverTrace.d.ts +7 -0
  394. package/dist/esm/plugin/usageReporting/iterateOverTrace.d.ts.map +1 -0
  395. package/dist/esm/plugin/usageReporting/iterateOverTrace.js +78 -0
  396. package/dist/esm/plugin/usageReporting/iterateOverTrace.js.map +1 -0
  397. package/dist/esm/plugin/usageReporting/operationDerivedDataCache.d.ts +12 -0
  398. package/dist/esm/plugin/usageReporting/operationDerivedDataCache.d.ts.map +1 -0
  399. package/dist/esm/plugin/usageReporting/operationDerivedDataCache.js +29 -0
  400. package/dist/esm/plugin/usageReporting/operationDerivedDataCache.js.map +1 -0
  401. package/dist/esm/plugin/usageReporting/options.d.ts +60 -0
  402. package/dist/esm/plugin/usageReporting/options.d.ts.map +1 -0
  403. package/dist/esm/plugin/usageReporting/options.js +2 -0
  404. package/dist/esm/plugin/usageReporting/options.js.map +1 -0
  405. package/dist/esm/plugin/usageReporting/plugin.d.ts +7 -0
  406. package/dist/esm/plugin/usageReporting/plugin.d.ts.map +1 -0
  407. package/dist/esm/plugin/usageReporting/plugin.js +487 -0
  408. package/dist/esm/plugin/usageReporting/plugin.js.map +1 -0
  409. package/dist/esm/plugin/usageReporting/stats.d.ts +96 -0
  410. package/dist/esm/plugin/usageReporting/stats.d.ts.map +1 -0
  411. package/dist/esm/plugin/usageReporting/stats.js +283 -0
  412. package/dist/esm/plugin/usageReporting/stats.js.map +1 -0
  413. package/dist/esm/plugin/usageReporting/traceDetails.d.ts +4 -0
  414. package/dist/esm/plugin/usageReporting/traceDetails.d.ts.map +1 -0
  415. package/dist/esm/plugin/usageReporting/traceDetails.js +60 -0
  416. package/dist/esm/plugin/usageReporting/traceDetails.js.map +1 -0
  417. package/dist/esm/preventCsrf.d.ts +4 -0
  418. package/dist/esm/preventCsrf.d.ts.map +1 -0
  419. package/dist/esm/preventCsrf.js +34 -0
  420. package/dist/esm/preventCsrf.js.map +1 -0
  421. package/dist/esm/requestPipeline.d.ts +9 -0
  422. package/dist/esm/requestPipeline.d.ts.map +1 -0
  423. package/dist/esm/requestPipeline.js +364 -0
  424. package/dist/esm/requestPipeline.js.map +1 -0
  425. package/dist/esm/runHttpQuery.d.ts +15 -0
  426. package/dist/esm/runHttpQuery.d.ts.map +1 -0
  427. package/dist/esm/runHttpQuery.js +221 -0
  428. package/dist/esm/runHttpQuery.js.map +1 -0
  429. package/dist/esm/standalone/index.d.ts +25 -0
  430. package/dist/esm/standalone/index.d.ts.map +1 -0
  431. package/dist/esm/standalone/index.js +91 -0
  432. package/dist/esm/standalone/index.js.map +1 -0
  433. package/dist/esm/utils/HeaderMap.d.ts +8 -0
  434. package/dist/esm/utils/HeaderMap.d.ts.map +1 -0
  435. package/dist/esm/utils/HeaderMap.js +16 -0
  436. package/dist/esm/utils/HeaderMap.js.map +1 -0
  437. package/dist/esm/utils/UnreachableCaseError.d.ts +4 -0
  438. package/dist/esm/utils/UnreachableCaseError.d.ts.map +1 -0
  439. package/dist/esm/utils/UnreachableCaseError.js +6 -0
  440. package/dist/esm/utils/UnreachableCaseError.js.map +1 -0
  441. package/dist/esm/utils/computeCoreSchemaHash.d.ts +2 -0
  442. package/dist/esm/utils/computeCoreSchemaHash.d.ts.map +1 -0
  443. package/dist/esm/utils/computeCoreSchemaHash.js +5 -0
  444. package/dist/esm/utils/computeCoreSchemaHash.js.map +1 -0
  445. package/dist/esm/utils/invokeHooks.d.ts +7 -0
  446. package/dist/esm/utils/invokeHooks.d.ts.map +1 -0
  447. package/dist/esm/utils/invokeHooks.js +31 -0
  448. package/dist/esm/utils/invokeHooks.js.map +1 -0
  449. package/dist/esm/utils/isDefined.d.ts +2 -0
  450. package/dist/esm/utils/isDefined.d.ts.map +1 -0
  451. package/dist/esm/utils/isDefined.js +4 -0
  452. package/dist/esm/utils/isDefined.js.map +1 -0
  453. package/dist/esm/utils/makeGatewayGraphQLRequestContext.d.ts +5 -0
  454. package/dist/esm/utils/makeGatewayGraphQLRequestContext.d.ts.map +1 -0
  455. package/dist/esm/utils/makeGatewayGraphQLRequestContext.js +93 -0
  456. package/dist/esm/utils/makeGatewayGraphQLRequestContext.js.map +1 -0
  457. package/dist/esm/utils/resolvable.d.ts +7 -0
  458. package/dist/esm/utils/resolvable.d.ts.map +1 -0
  459. package/dist/esm/utils/resolvable.js +12 -0
  460. package/dist/esm/utils/resolvable.js.map +1 -0
  461. package/dist/esm/utils/schemaInstrumentation.d.ts +16 -0
  462. package/dist/esm/utils/schemaInstrumentation.d.ts.map +1 -0
  463. package/dist/esm/utils/schemaInstrumentation.js +69 -0
  464. package/dist/esm/utils/schemaInstrumentation.js.map +1 -0
  465. package/dist/esm/utils/schemaManager.d.ts +31 -0
  466. package/dist/esm/utils/schemaManager.d.ts.map +1 -0
  467. package/dist/esm/utils/schemaManager.js +99 -0
  468. package/dist/esm/utils/schemaManager.js.map +1 -0
  469. package/dist/esm/utils/urlForHttpServer.d.ts +3 -0
  470. package/dist/esm/utils/urlForHttpServer.d.ts.map +1 -0
  471. package/dist/esm/utils/urlForHttpServer.js +12 -0
  472. package/dist/esm/utils/urlForHttpServer.js.map +1 -0
  473. package/dist/esm/validationRules/NoIntrospection.d.ts +3 -0
  474. package/dist/esm/validationRules/NoIntrospection.d.ts.map +1 -0
  475. package/dist/esm/validationRules/NoIntrospection.js +15 -0
  476. package/dist/esm/validationRules/NoIntrospection.js.map +1 -0
  477. package/dist/esm/validationRules/RecursiveSelectionsLimit.d.ts +4 -0
  478. package/dist/esm/validationRules/RecursiveSelectionsLimit.d.ts.map +1 -0
  479. package/dist/esm/validationRules/RecursiveSelectionsLimit.js +146 -0
  480. package/dist/esm/validationRules/RecursiveSelectionsLimit.js.map +1 -0
  481. package/dist/esm/validationRules/index.d.ts +3 -0
  482. package/dist/esm/validationRules/index.d.ts.map +1 -0
  483. package/dist/esm/validationRules/index.js +3 -0
  484. package/dist/esm/validationRules/index.js.map +1 -0
  485. package/errors/package.json +8 -0
  486. package/package.json +208 -0
  487. package/plugin/cacheControl/package.json +8 -0
  488. package/plugin/disableSuggestions/package.json +8 -0
  489. package/plugin/disabled/package.json +8 -0
  490. package/plugin/drainHttpServer/package.json +8 -0
  491. package/plugin/inlineTrace/package.json +8 -0
  492. package/plugin/landingPage/default/package.json +8 -0
  493. package/plugin/schemaReporting/package.json +8 -0
  494. package/plugin/subscriptionCallback/package.json +8 -0
  495. package/plugin/usageReporting/package.json +8 -0
  496. package/src/ApolloServer.ts +1456 -0
  497. package/src/cachePolicy.ts +33 -0
  498. package/src/determineApolloConfig.ts +95 -0
  499. package/src/errorNormalize.ts +114 -0
  500. package/src/errors/index.ts +33 -0
  501. package/src/externalTypes/constructor.ts +174 -0
  502. package/src/externalTypes/context.ts +18 -0
  503. package/src/externalTypes/graphql.ts +81 -0
  504. package/src/externalTypes/http.ts +44 -0
  505. package/src/externalTypes/incrementalDeliveryPolyfillAlpha2.ts +63 -0
  506. package/src/externalTypes/incrementalDeliveryPolyfillAlpha9.ts +82 -0
  507. package/src/externalTypes/index.ts +73 -0
  508. package/src/externalTypes/plugins.ts +222 -0
  509. package/src/externalTypes/requestPipeline.ts +123 -0
  510. package/src/generated/packageVersion.ts +1 -0
  511. package/src/httpBatching.ts +105 -0
  512. package/src/incrementalDeliveryPolyfill.ts +253 -0
  513. package/src/index.ts +4 -0
  514. package/src/internalErrorClasses.ts +123 -0
  515. package/src/internalPlugin.ts +42 -0
  516. package/src/plugin/cacheControl/index.ts +453 -0
  517. package/src/plugin/disableSuggestions/index.ts +23 -0
  518. package/src/plugin/disabled/index.ts +41 -0
  519. package/src/plugin/drainHttpServer/index.ts +42 -0
  520. package/src/plugin/drainHttpServer/stoppable.ts +109 -0
  521. package/src/plugin/inlineTrace/index.ts +156 -0
  522. package/src/plugin/landingPage/default/getEmbeddedHTML.ts +204 -0
  523. package/src/plugin/landingPage/default/index.ts +219 -0
  524. package/src/plugin/landingPage/default/types.ts +198 -0
  525. package/src/plugin/schemaIsSubgraph.ts +41 -0
  526. package/src/plugin/schemaReporting/generated/operations.d.ts +18359 -0
  527. package/src/plugin/schemaReporting/index.ts +198 -0
  528. package/src/plugin/schemaReporting/schemaReporter.ts +207 -0
  529. package/src/plugin/subscriptionCallback/index.ts +724 -0
  530. package/src/plugin/traceTreeBuilder.ts +356 -0
  531. package/src/plugin/usageReporting/defaultSendOperationsAsTrace.ts +74 -0
  532. package/src/plugin/usageReporting/durationHistogram.ts +87 -0
  533. package/src/plugin/usageReporting/index.ts +9 -0
  534. package/src/plugin/usageReporting/iterateOverTrace.ts +140 -0
  535. package/src/plugin/usageReporting/operationDerivedDataCache.ts +61 -0
  536. package/src/plugin/usageReporting/options.ts +414 -0
  537. package/src/plugin/usageReporting/plugin.ts +871 -0
  538. package/src/plugin/usageReporting/stats.ts +492 -0
  539. package/src/plugin/usageReporting/traceDetails.ts +96 -0
  540. package/src/preventCsrf.ts +99 -0
  541. package/src/requestPipeline.ts +821 -0
  542. package/src/runHttpQuery.ts +408 -0
  543. package/src/standalone/index.ts +155 -0
  544. package/src/utils/HeaderMap.ts +22 -0
  545. package/src/utils/UnreachableCaseError.ts +10 -0
  546. package/src/utils/computeCoreSchemaHash.ts +9 -0
  547. package/src/utils/invokeHooks.ts +53 -0
  548. package/src/utils/isDefined.ts +3 -0
  549. package/src/utils/makeGatewayGraphQLRequestContext.ts +197 -0
  550. package/src/utils/resolvable.ts +30 -0
  551. package/src/utils/schemaInstrumentation.ts +132 -0
  552. package/src/utils/schemaManager.ts +212 -0
  553. package/src/utils/urlForHttpServer.ts +21 -0
  554. package/src/validationRules/NoIntrospection.ts +27 -0
  555. package/src/validationRules/RecursiveSelectionsLimit.ts +198 -0
  556. package/src/validationRules/index.ts +5 -0
  557. 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
+ }