@nestjs/apollo 13.2.5 → 13.3.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.
@@ -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 createPreserveHttpStatusPlugin;
17
18
  private wrapFormatErrorFn;
18
19
  private createTransformHttpErrorFn;
19
20
  private wrapContextResolver;
@@ -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;IAsDjD,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,KAAK,EAC3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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,8BAA8B;IA4BtC,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,0BAA0B;IA0ClC,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,iBAAiB;CAgB1B"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApolloBaseDriver = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const server_1 = require("@apollo/server");
5
6
  const server_plugin_landing_page_graphql_playground_1 = require("@apollo/server-plugin-landing-page-graphql-playground");
6
7
  const errors_1 = require("@apollo/server/errors");
@@ -11,7 +12,7 @@ const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
11
12
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
12
13
  const graphql_1 = require("@nestjs/graphql");
13
14
  const graphql_2 = require("graphql");
14
- const omit = require("lodash.omit");
15
+ const lodash_omit_1 = tslib_1.__importDefault(require("lodash.omit"));
15
16
  const graphiql_playground_plugin_1 = require("../graphiql/graphiql-playground.plugin");
16
17
  const async_iterator_util_1 = require("../utils/async-iterator.util");
17
18
  const apolloPredefinedExceptions = {
@@ -73,14 +74,20 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
73
74
  plugins: [(0, disabled_1.ApolloServerPluginLandingPageDisabled)()],
74
75
  };
75
76
  }
76
- options = await super.mergeDefaultOptions(options, omit(defaults, 'plugins'));
77
+ options = await super.mergeDefaultOptions(options, (0, lodash_omit_1.default)(defaults, 'plugins'));
77
78
  options.plugins = (options.plugins || []).concat(defaults.plugins || []);
78
79
  this.wrapContextResolver(options);
79
80
  this.wrapFormatErrorFn(options);
81
+ if (options.autoTransformHttpErrors !== false) {
82
+ options.plugins = [
83
+ ...(options.plugins || []),
84
+ this.createPreserveHttpStatusPlugin(),
85
+ ];
86
+ }
80
87
  return options;
81
88
  }
82
89
  subscriptionWithFilter(instanceRef, filterFn, createSubscribeContext) {
83
- return (...args) => (0, async_iterator_util_1.createAsyncIterator)(createSubscribeContext()(...args), (payload) => filterFn.call(instanceRef, payload, ...args.slice(1)));
90
+ return (...args) => (0, async_iterator_util_1.createAsyncIterator)(createSubscribeContext()(...args), (payload) => filterFn.call(instanceRef, payload, args[1], args[2]));
84
91
  }
85
92
  async registerExpress(options, { preStartHook } = {}) {
86
93
  const { expressMiddleware } = (0, load_package_util_1.loadPackage)('@as-integrations/express5', 'GraphQLModule', () => require('@as-integrations/express5'));
@@ -141,6 +148,31 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
141
148
  });
142
149
  this.apolloServer = server;
143
150
  }
151
+ createPreserveHttpStatusPlugin() {
152
+ // When a resolver throws an error whose `extensions.http.status` is set
153
+ // (either directly via GraphQLError or transitively via NestJS HTTP
154
+ // exceptions in user code), Apollo Server uses that value as the HTTP
155
+ // response status. Some GraphQL clients/UIs then refuse to parse the
156
+ // response as a normal `{ data, errors }` payload and instead wrap it as
157
+ // a transport-level error. Reset the HTTP status to 200 once execution
158
+ // has run so the response shape stays stable. Request-level failures
159
+ // (parse, validate) are unaffected because their body has no `data` key.
160
+ // @see https://github.com/nestjs/graphql/issues/2940
161
+ return {
162
+ async requestDidStart() {
163
+ return {
164
+ async willSendResponse(requestContext) {
165
+ const body = requestContext.response?.body;
166
+ if (body?.kind === 'single' &&
167
+ 'data' in (body.singleResult ?? {}) &&
168
+ requestContext.response?.http) {
169
+ requestContext.response.http.status = 200;
170
+ }
171
+ },
172
+ };
173
+ },
174
+ };
175
+ }
144
176
  wrapFormatErrorFn(options) {
145
177
  if (options.autoTransformHttpErrors === false) {
146
178
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-gateway.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-gateway.driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,qBACa,mBAAoB,SAAQ,gBAAgB,CAAC,yBAAyB,CAAC;IAClF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyB;gBAEpD,gBAAgB,EAAE,gBAAgB;IAKjC,KAAK,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxD,mBAAmB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAOxB,cAAc,CAAC,CAAC,EAAE,yBAAyB;CAGnD"}
1
+ {"version":3,"file":"apollo-gateway.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-gateway.driver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,qBACa,mBAAoB,SAAQ,gBAAgB,CAAC,yBAAyB,CAAC;IAClF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyB;gBAEpD,gBAAgB,EAAE,gBAAgB;IAKjC,KAAK,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBxD,mBAAmB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAOxB,cAAc,CAAC,CAAC,EAAE,yBAAyB;CAGnD"}
@@ -17,6 +17,7 @@ let ApolloGatewayDriver = class ApolloGatewayDriver extends apollo_base_driver_1
17
17
  this.pluginsExplorerService = new plugins_explorer_service_1.PluginsExplorerService(modulesContainer);
18
18
  }
19
19
  async start(options) {
20
+ options.server ??= {};
20
21
  options.server.plugins = (0, graphql_1.extend)(options.server.plugins || [], this.pluginsExplorerService.explore(options));
21
22
  const { ApolloGateway } = (0, load_package_util_1.loadPackage)('@apollo/gateway', 'ApolloGateway', () => require('@apollo/gateway'));
22
23
  const { server: serverOpts = {}, gateway: gatewayOpts = {} } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/apollo",
3
- "version": "13.2.5",
3
+ "version": "13.3.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -15,8 +15,8 @@
15
15
  "url": "git+https://github.com/nestjs/graphql.git"
16
16
  },
17
17
  "scripts": {
18
- "test:e2e": "jest --config ./tests/jest-e2e.ts --runInBand",
19
- "test:e2e:dev": "jest --config ./tests/jest-e2e.ts --runInBand --watch"
18
+ "test:e2e": "vitest run",
19
+ "test:e2e:dev": "vitest watch"
20
20
  },
21
21
  "bugs": {
22
22
  "url": "https://github.com/nestjs/graphql/issues"
@@ -28,11 +28,11 @@
28
28
  "@apollo/subgraph": "2.11.2",
29
29
  "@as-integrations/express5": "^1.1.2",
30
30
  "@as-integrations/fastify": "3.1.0",
31
- "@nestjs/common": "11.1.18",
32
- "@nestjs/core": "11.1.18",
33
- "@nestjs/platform-express": "11.1.18",
34
- "@nestjs/platform-fastify": "11.1.18",
35
- "@nestjs/testing": "11.1.18",
31
+ "@nestjs/common": "11.1.19",
32
+ "@nestjs/core": "11.1.19",
33
+ "@nestjs/platform-express": "11.1.19",
34
+ "@nestjs/platform-fastify": "11.1.19",
35
+ "@nestjs/testing": "11.1.19",
36
36
  "apollo-cache-inmemory": "1.6.6",
37
37
  "apollo-client": "2.6.10",
38
38
  "apollo-link-ws": "1.0.20"
@@ -67,5 +67,5 @@
67
67
  "optional": true
68
68
  }
69
69
  },
70
- "gitHead": "1421cc43aa53ae61c38f8353b654be657a1dfb3b"
70
+ "gitHead": "e1e841c4e0ac5592291ed9b146170d500a8270ff"
71
71
  }