@nestjs/apollo 14.0.2 → 14.1.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 CHANGED
@@ -26,16 +26,16 @@
26
26
 
27
27
  ## Installation
28
28
 
29
- If you are using `express` HTTP engine, install the following packages:
29
+ If you are using the `express` HTTP engine, install the following packages:
30
30
 
31
31
  ```bash
32
- $ npm i --save @nestjs/graphql @nestjs/apollo apollo-server-express graphql
32
+ $ npm i --save @nestjs/graphql @nestjs/apollo @apollo/server @as-integrations/express5 graphql
33
33
  ```
34
34
 
35
- In case of `fastify`, you should install `apollo-server-fastify` instead.
35
+ In case of `fastify`, install `@as-integrations/fastify` instead of `@as-integrations/express5`:
36
36
 
37
37
  ```bash
38
- $ npm i --save @nestjs/graphql @nestjs/apollo apollo-server-fastify graphql
38
+ $ npm i --save @nestjs/graphql @nestjs/apollo @apollo/server @as-integrations/fastify graphql
39
39
  ```
40
40
 
41
41
  ## Quick Start
@@ -21,5 +21,6 @@ export declare abstract class ApolloBaseDriver<T extends Record<string, any> = A
21
21
  private createTransformHttpErrorFn;
22
22
  private wrapContextResolver;
23
23
  private assignReqProperty;
24
+ private cloneContext;
24
25
  }
25
26
  //# sourceMappingURL=apollo-base.driver.d.ts.map
@@ -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;AAUhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAKxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAU5D,8BAAsB,gBAAgB,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAClD,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,YA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ApolloBaseDriver extends AbstractGraphQLDriver {
286
286
  }
287
287
  else {
288
288
  targetOptions.context = async (contextOrRequest) => {
289
- return this.assignReqProperty(originalOptions.context, contextOrRequest.req ?? contextOrRequest);
289
+ // The object is shared by all requests, so each one gets its own copy
290
+ return this.assignReqProperty(this.cloneContext(originalOptions.context), contextOrRequest.req ?? contextOrRequest);
290
291
  };
291
292
  }
292
293
  }
@@ -298,7 +299,13 @@ export class ApolloBaseDriver extends AbstractGraphQLDriver {
298
299
  (ctx && ctx.req && typeof ctx.req === 'object')) {
299
300
  return ctx;
300
301
  }
301
- ctx.req = req;
302
- return ctx;
302
+ // Never assign onto `ctx`: when the same object is returned for every
303
+ // request, all of them would see the `req` of the first one.
304
+ return this.cloneContext(ctx, { req });
305
+ }
306
+ cloneContext(ctx, properties) {
307
+ // Keeps the prototype (and so the methods of class-based contexts), just
308
+ // like the copy Apollo Server makes of the context for every operation.
309
+ return Object.assign(Object.create(Object.getPrototypeOf(ctx)), ctx, properties);
303
310
  }
304
311
  }
@@ -13,5 +13,6 @@ export declare class ApolloFederationDriver extends ApolloBaseDriver {
13
13
  constructor(graphqlFederationFactory: GraphQLFederationFactory, modulesContainer: ModulesContainer);
14
14
  start(options: ApolloDriverConfig): Promise<void>;
15
15
  generateSchema(options: ApolloDriverConfig): Promise<GraphQLSchema>;
16
+ stop(): Promise<void>;
16
17
  }
17
18
  //# sourceMappingURL=apollo-federation.driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-federation.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-federation.driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAGL,wBAAwB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,qBACa,sBAAuB,SAAQ,gBAAgB;IAKxD,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IAJ3C,OAAO,CAAC,oBAAoB,CAAC,CAAyB;IACtD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyB;gBAG7C,wBAAwB,EAAE,wBAAwB,EACnE,gBAAgB,EAAE,gBAAgB;IAMvB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCvD,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;CAG3E"}
1
+ {"version":3,"file":"apollo-federation.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-federation.driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAGL,wBAAwB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,qBACa,sBAAuB,SAAQ,gBAAgB;IAKxD,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IAJ3C,OAAO,CAAC,oBAAoB,CAAC,CAAyB;IACtD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyB;gBAG7C,wBAAwB,EAAE,wBAAwB,EACnE,gBAAgB,EAAE,gBAAgB;IAMvB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCvD,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI7D,IAAI;CAIlB"}
@@ -34,6 +34,10 @@ let ApolloFederationDriver = class ApolloFederationDriver extends ApolloBaseDriv
34
34
  generateSchema(options) {
35
35
  return this.graphqlFederationFactory.generateSchema(options);
36
36
  }
37
+ async stop() {
38
+ await this._subscriptionService?.stop();
39
+ await super.stop();
40
+ }
37
41
  };
38
42
  ApolloFederationDriver = __decorate([
39
43
  Injectable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/apollo",
3
- "version": "14.0.2",
3
+ "version": "14.1.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -38,11 +38,11 @@
38
38
  "@apollo/subgraph": "2.15.1",
39
39
  "@as-integrations/express5": "^1.1.2",
40
40
  "@as-integrations/fastify": "3.1.0",
41
- "@nestjs/common": "12.0.4",
42
- "@nestjs/core": "12.0.4",
43
- "@nestjs/platform-express": "12.0.4",
44
- "@nestjs/platform-fastify": "12.0.4",
45
- "@nestjs/testing": "12.0.4",
41
+ "@nestjs/common": "12.2.0",
42
+ "@nestjs/core": "12.2.0",
43
+ "@nestjs/platform-express": "12.2.0",
44
+ "@nestjs/platform-fastify": "12.2.0",
45
+ "@nestjs/testing": "12.2.0",
46
46
  "apollo-cache-inmemory": "1.6.6",
47
47
  "apollo-client": "2.6.10"
48
48
  },
@@ -55,7 +55,8 @@
55
55
  "@apollo/gateway": "^2.0.0",
56
56
  "@apollo/server": "^5.0.0",
57
57
  "@apollo/subgraph": "^2.0.0",
58
- "@as-integrations/fastify": "^2.1.1 || ^3.0.0",
58
+ "@as-integrations/express5": "^1.1.2",
59
+ "@as-integrations/fastify": "^3.1.0",
59
60
  "@nestjs/common": "^12.0.0",
60
61
  "@nestjs/core": "^12.0.0",
61
62
  "@nestjs/graphql": "^14.0.0",
@@ -75,5 +76,5 @@
75
76
  "optional": true
76
77
  }
77
78
  },
78
- "gitHead": "877594054affa807736db0e13e014be52afce7c9"
79
+ "gitHead": "41abe24538f9999a49faeeee6c8d7136f1315a5f"
79
80
  }