@nestjs/apollo 13.4.2 → 13.4.4

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.
@@ -14,6 +14,7 @@ export declare abstract class ApolloBaseDriver<T extends Record<string, any> = A
14
14
  protected registerFastify(options: T, { preStartHook }?: {
15
15
  preStartHook?: () => void;
16
16
  }): Promise<void>;
17
+ private createRequestLifecycleHooksPlugin;
17
18
  private createPreserveHttpStatusPlugin;
18
19
  private wrapFormatErrorFn;
19
20
  private createTransformHttpErrorFn;
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-base.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-base.driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAWhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAKxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAUnD,8BAAsB,gBAAgB,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAClD,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAElD,IAAI,QAAQ,IAAI,YAAY,CAAC,WAAW,CAAC,CAExC;IAEY,KAAK,CAAC,aAAa,EAAE,CAAC;IAa5B,IAAI;IAIE,mBAAmB,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA+DjD,sBAAsB,CAC3B,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,CACR,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,GAAG,KACT,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC/B,sBAAsB,EAAE,QAAQ,IAExB,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,K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AE,GAAG,KACT,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC/B,sBAAsB,EAAE,QAAQ,IAExB,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAC3C,GAAG,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,KAC/C,GAAG;cAMQ,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;cAmDtC,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;IAuCtD,OAAO,CAAC,iCAAiC;IAyCzC,OAAO,CAAC,8BAA8B;IA4BtC,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,0BAA0B;IA0ClC,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,iBAAiB;CAgB1B"}
@@ -84,6 +84,10 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
84
84
  this.createPreserveHttpStatusPlugin(),
85
85
  ];
86
86
  }
87
+ options.plugins = [
88
+ ...(options.plugins || []),
89
+ this.createRequestLifecycleHooksPlugin(),
90
+ ];
87
91
  return options;
88
92
  }
89
93
  subscriptionWithFilter(instanceRef, filterFn, createSubscribeContext) {
@@ -148,6 +152,40 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
148
152
  });
149
153
  this.apolloServer = server;
150
154
  }
155
+ createRequestLifecycleHooksPlugin() {
156
+ // Exposes the "request start"/"request end" hooks registered through the
157
+ // `ResolverDecoratorHost` so that consumers can instrument (and measure)
158
+ // the entire lifecycle of a single GraphQL operation.
159
+ const resolverDecoratorHost = () => this.resolverDecoratorHost;
160
+ return {
161
+ async requestDidStart(requestContext) {
162
+ const host = resolverDecoratorHost();
163
+ if (!host?.hasRequestHooks()) {
164
+ return;
165
+ }
166
+ const hookContext = {
167
+ query: requestContext.request?.query,
168
+ operationName: requestContext.request?.operationName,
169
+ variables: requestContext.request?.variables,
170
+ context: requestContext.contextValue,
171
+ };
172
+ const state = host.onRequestStart(hookContext);
173
+ return {
174
+ async willSendResponse(endRequestContext) {
175
+ const body = endRequestContext.response?.body;
176
+ const errors = endRequestContext.errors ??
177
+ (body?.kind === 'single' ? body.singleResult?.errors : undefined);
178
+ host.onRequestEnd({
179
+ ...hookContext,
180
+ operationName: endRequestContext.operationName ?? hookContext.operationName,
181
+ errors,
182
+ state,
183
+ });
184
+ },
185
+ };
186
+ },
187
+ };
188
+ }
151
189
  createPreserveHttpStatusPlugin() {
152
190
  // When a resolver throws an error whose `extensions.http.status` is set
153
191
  // (either directly via GraphQLError or transitively via NestJS HTTP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/apollo",
3
- "version": "13.4.2",
3
+ "version": "13.4.4",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -37,11 +37,11 @@
37
37
  "@apollo/subgraph": "2.11.2",
38
38
  "@as-integrations/express5": "^1.1.2",
39
39
  "@as-integrations/fastify": "3.1.0",
40
- "@nestjs/common": "11.1.21",
41
- "@nestjs/core": "11.1.21",
42
- "@nestjs/platform-express": "11.1.21",
43
- "@nestjs/platform-fastify": "11.1.21",
44
- "@nestjs/testing": "11.1.21",
40
+ "@nestjs/common": "11.1.22",
41
+ "@nestjs/core": "11.1.22",
42
+ "@nestjs/platform-express": "11.1.22",
43
+ "@nestjs/platform-fastify": "11.1.24",
44
+ "@nestjs/testing": "11.1.22",
45
45
  "apollo-cache-inmemory": "1.6.6",
46
46
  "apollo-client": "2.6.10",
47
47
  "apollo-link-ws": "1.0.20"
@@ -76,5 +76,5 @@
76
76
  "optional": true
77
77
  }
78
78
  },
79
- "gitHead": "c639ef8988777577b364a678e98b283798468319"
79
+ "gitHead": "bbb6885caa2213f44b92501c1b1720cae9e2586b"
80
80
  }