@nestjs/apollo 11.0.0-next.1 → 11.0.0-next.2

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.
@@ -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;AAShE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AASnD,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;IA6CjD,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,qHAI7B,GAAG;cAMQ,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;cA6BtC,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;IAqCtD,OAAO,CAAC,iB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B;IAgClC,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,iBAAiB;CAgB1B"}
@@ -15,7 +15,7 @@ const graphql_2 = require("graphql");
15
15
  const omit = require("lodash.omit");
16
16
  const async_iterator_util_1 = require("../utils/async-iterator.util");
17
17
  const apolloPredefinedExceptions = {
18
- [common_1.HttpStatus.BAD_REQUEST]: errors_1.ApolloServerErrorCode.BAD_USER_INPUT,
18
+ [common_1.HttpStatus.BAD_REQUEST]: errors_1.ApolloServerErrorCode.BAD_REQUEST,
19
19
  [common_1.HttpStatus.UNAUTHORIZED]: 'UNAUTHENTICATED',
20
20
  [common_1.HttpStatus.FORBIDDEN]: 'FORBIDDEN',
21
21
  };
@@ -92,7 +92,9 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
92
92
  : [drainHttpServerPlugin],
93
93
  });
94
94
  await server.start();
95
- app.use(path, (0, express4_1.expressMiddleware)(server));
95
+ app.use(path, (0, express4_1.expressMiddleware)(server, {
96
+ context: options.context,
97
+ }));
96
98
  this.apolloServer = server;
97
99
  }
98
100
  async registerFastify(options, { preStartHook } = {}) {
@@ -115,7 +117,9 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
115
117
  app.route({
116
118
  url: path,
117
119
  method: ['GET', 'POST', 'OPTIONS'],
118
- handler: fastifyApolloHandler(server),
120
+ handler: fastifyApolloHandler(server, {
121
+ context: options.context,
122
+ }),
119
123
  });
120
124
  this.apolloServer = server;
121
125
  }
@@ -168,18 +172,26 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
168
172
  }
169
173
  wrapContextResolver(targetOptions, originalOptions = { ...targetOptions }) {
170
174
  if (!targetOptions.context) {
171
- targetOptions.context = ({ req, request }) => ({ req: req !== null && req !== void 0 ? req : request });
175
+ targetOptions.context = async (contextOrRequest) => {
176
+ var _a;
177
+ return {
178
+ // New ApolloServer fastify integration has Request as first parameter to the Context function
179
+ req: (_a = contextOrRequest.req) !== null && _a !== void 0 ? _a : contextOrRequest,
180
+ };
181
+ };
172
182
  }
173
183
  else if ((0, shared_utils_1.isFunction)(targetOptions.context)) {
174
184
  targetOptions.context = async (...args) => {
185
+ var _a;
175
186
  const ctx = await originalOptions.context(...args);
176
- const { req, request } = args[0];
177
- return this.assignReqProperty(ctx, req !== null && req !== void 0 ? req : request);
187
+ const contextOrRequest = args[0];
188
+ return this.assignReqProperty(ctx, (_a = contextOrRequest.req) !== null && _a !== void 0 ? _a : contextOrRequest);
178
189
  };
179
190
  }
180
191
  else {
181
- targetOptions.context = ({ req, request }) => {
182
- return this.assignReqProperty(originalOptions.context, req !== null && req !== void 0 ? req : request);
192
+ targetOptions.context = async (contextOrRequest) => {
193
+ var _a;
194
+ return this.assignReqProperty(originalOptions.context, (_a = contextOrRequest.req) !== null && _a !== void 0 ? _a : contextOrRequest);
183
195
  };
184
196
  }
185
197
  }
@@ -0,0 +1,11 @@
1
+ import { GraphQLError, GraphQLErrorOptions } from 'graphql';
2
+ /**
3
+ * This error is thrown when the user is not authenticated.
4
+ *
5
+ * "AuthenticationError" class was removed in the latest version of Apollo Server (4.0.0)
6
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
7
+ */
8
+ export declare class AuthenticationError extends GraphQLError {
9
+ constructor(message: string, options?: GraphQLErrorOptions);
10
+ }
11
+ //# sourceMappingURL=authentication.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.error.d.ts","sourceRoot":"","sources":["../../lib/errors/authentication.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB;CAS3D"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthenticationError = void 0;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * This error is thrown when the user is not authenticated.
7
+ *
8
+ * "AuthenticationError" class was removed in the latest version of Apollo Server (4.0.0)
9
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
10
+ */
11
+ class AuthenticationError extends graphql_1.GraphQLError {
12
+ constructor(message, options) {
13
+ super(message, {
14
+ ...options,
15
+ extensions: {
16
+ code: 'UNAUTHENTICATED',
17
+ ...options === null || options === void 0 ? void 0 : options.extensions,
18
+ },
19
+ });
20
+ }
21
+ }
22
+ exports.AuthenticationError = AuthenticationError;
@@ -0,0 +1,11 @@
1
+ import { GraphQLError, GraphQLErrorOptions } from 'graphql';
2
+ /**
3
+ * This error is thrown when the user is not authorized to access a resource.
4
+ *
5
+ * "ForbiddenError" class was removed in the latest version of Apollo Server (4.0.0)
6
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
7
+ */
8
+ export declare class ForbiddenError extends GraphQLError {
9
+ constructor(message: string, options?: GraphQLErrorOptions);
10
+ }
11
+ //# sourceMappingURL=forbidden.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden.error.d.ts","sourceRoot":"","sources":["../../lib/errors/forbidden.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,YAAY;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB;CAS3D"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForbiddenError = void 0;
4
+ const graphql_1 = require("graphql");
5
+ /**
6
+ * This error is thrown when the user is not authorized to access a resource.
7
+ *
8
+ * "ForbiddenError" class was removed in the latest version of Apollo Server (4.0.0)
9
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
10
+ */
11
+ class ForbiddenError extends graphql_1.GraphQLError {
12
+ constructor(message, options) {
13
+ super(message, {
14
+ ...options,
15
+ extensions: {
16
+ code: 'FORBIDDEN',
17
+ ...options === null || options === void 0 ? void 0 : options.extensions,
18
+ },
19
+ });
20
+ }
21
+ }
22
+ exports.ForbiddenError = ForbiddenError;
@@ -0,0 +1,5 @@
1
+ export * from './authentication.error';
2
+ export * from './forbidden.error';
3
+ export * from './user-input.error';
4
+ export * from './validation.error';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./authentication.error"), exports);
5
+ tslib_1.__exportStar(require("./forbidden.error"), exports);
6
+ tslib_1.__exportStar(require("./user-input.error"), exports);
7
+ tslib_1.__exportStar(require("./validation.error"), exports);
@@ -0,0 +1,11 @@
1
+ import { GraphQLError, GraphQLErrorOptions } from 'graphql';
2
+ /**
3
+ * This error is thrown when the user input is invalid.
4
+ *
5
+ * "UserInputError" class was removed in the latest version of Apollo Server (4.0.0)
6
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
7
+ */
8
+ export declare class UserInputError extends GraphQLError {
9
+ constructor(message: string, options?: GraphQLErrorOptions);
10
+ }
11
+ //# sourceMappingURL=user-input.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-input.error.d.ts","sourceRoot":"","sources":["../../lib/errors/user-input.error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,YAAY;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB;CAS3D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserInputError = void 0;
4
+ const errors_1 = require("@apollo/server/errors");
5
+ const graphql_1 = require("graphql");
6
+ /**
7
+ * This error is thrown when the user input is invalid.
8
+ *
9
+ * "UserInputError" class was removed in the latest version of Apollo Server (4.0.0)
10
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
11
+ */
12
+ class UserInputError extends graphql_1.GraphQLError {
13
+ constructor(message, options) {
14
+ super(message, {
15
+ ...options,
16
+ extensions: {
17
+ code: errors_1.ApolloServerErrorCode.BAD_USER_INPUT,
18
+ ...options === null || options === void 0 ? void 0 : options.extensions,
19
+ },
20
+ });
21
+ }
22
+ }
23
+ exports.UserInputError = UserInputError;
@@ -0,0 +1,11 @@
1
+ import { GraphQLError, GraphQLErrorOptions } from 'graphql';
2
+ /**
3
+ * This error is thrown when the user input does not pass validation.
4
+ *
5
+ * "ValidationError" class was removed in the latest version of Apollo Server (4.0.0)
6
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
7
+ */
8
+ export declare class ValidationError extends GraphQLError {
9
+ constructor(message: string, options?: GraphQLErrorOptions);
10
+ }
11
+ //# sourceMappingURL=validation.error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.error.d.ts","sourceRoot":"","sources":["../../lib/errors/validation.error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB;CAS3D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationError = void 0;
4
+ const errors_1 = require("@apollo/server/errors");
5
+ const graphql_1 = require("graphql");
6
+ /**
7
+ * This error is thrown when the user input does not pass validation.
8
+ *
9
+ * "ValidationError" class was removed in the latest version of Apollo Server (4.0.0)
10
+ * It was moved to the @nestjs/apollo package to avoid regressions & make migration easier.
11
+ */
12
+ class ValidationError extends graphql_1.GraphQLError {
13
+ constructor(message, options) {
14
+ super(message, {
15
+ ...options,
16
+ extensions: {
17
+ code: errors_1.ApolloServerErrorCode.GRAPHQL_VALIDATION_FAILED,
18
+ ...options === null || options === void 0 ? void 0 : options.extensions,
19
+ },
20
+ });
21
+ }
22
+ }
23
+ exports.ValidationError = ValidationError;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './decorators';
2
2
  export * from './drivers';
3
+ export * from './errors';
3
4
  export * from './interfaces';
4
5
  export * from './utils';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./decorators"), exports);
5
5
  tslib_1.__exportStar(require("./drivers"), exports);
6
+ tslib_1.__exportStar(require("./errors"), exports);
6
7
  tslib_1.__exportStar(require("./interfaces"), exports);
7
8
  tslib_1.__exportStar(require("./utils"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/apollo",
3
- "version": "11.0.0-next.1",
3
+ "version": "11.0.0-next.2",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@apollo/gateway": "2.2.3",
26
+ "@apollo/server": "4.3.2",
26
27
  "@apollo/server-plugin-response-cache": "4.1.0",
27
28
  "@apollo/subgraph": "2.2.3",
28
29
  "@as-integrations/fastify": "1.3.0",
@@ -36,7 +37,6 @@
36
37
  "apollo-link-ws": "1.0.20"
37
38
  },
38
39
  "dependencies": {
39
- "@apollo/server": "4.3.2",
40
40
  "@apollo/server-plugin-landing-page-graphql-playground": "4.0.0",
41
41
  "iterall": "1.3.0",
42
42
  "lodash.omit": "4.5.0",
@@ -44,6 +44,7 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@apollo/gateway": "^2.0.0",
47
+ "@apollo/server": "^4.3.2",
47
48
  "@apollo/subgraph": "^2.0.0",
48
49
  "@as-integrations/fastify": "^1.3.0",
49
50
  "@nestjs/common": "^9.0.0",
@@ -59,5 +60,5 @@
59
60
  "optional": true
60
61
  }
61
62
  },
62
- "gitHead": "03fc6413706352fd739b25eef58298b1d5c32267"
63
+ "gitHead": "64494dbe4d6cac871dcbfb32f9df9568dafe0821"
63
64
  }