@nestjs/apollo 11.0.6 → 12.0.1
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/dist/drivers/apollo-base.driver.js +10 -15
- package/dist/drivers/apollo-federation.driver.js +2 -3
- package/dist/drivers/apollo-gateway.driver.js +3 -5
- package/dist/drivers/apollo.driver.js +4 -7
- package/dist/errors/authentication.error.js +1 -1
- package/dist/errors/forbidden.error.js +1 -1
- package/dist/errors/user-input.error.js +1 -1
- package/dist/errors/validation.error.js +1 -1
- package/dist/utils/get-apollo-server.js +1 -2
- package/package.json +11 -11
|
@@ -37,8 +37,7 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
stop() {
|
|
40
|
-
|
|
41
|
-
return (_a = this.apolloServer) === null || _a === void 0 ? void 0 : _a.stop();
|
|
40
|
+
return this.apolloServer?.stop();
|
|
42
41
|
}
|
|
43
42
|
async mergeDefaultOptions(options) {
|
|
44
43
|
let defaults = {
|
|
@@ -81,7 +80,7 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
81
80
|
const drainHttpServerPlugin = (0, drainHttpServer_1.ApolloServerPluginDrainHttpServer)({
|
|
82
81
|
httpServer: httpAdapter.getHttpServer(),
|
|
83
82
|
});
|
|
84
|
-
preStartHook
|
|
83
|
+
preStartHook?.();
|
|
85
84
|
const server = new server_1.ApolloServer({
|
|
86
85
|
typeDefs,
|
|
87
86
|
resolvers,
|
|
@@ -103,7 +102,7 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
103
102
|
const app = httpAdapter.getInstance();
|
|
104
103
|
const { path, typeDefs, resolvers, schema } = options;
|
|
105
104
|
const apolloDrainPlugin = fastifyApolloDrainPlugin(app);
|
|
106
|
-
preStartHook
|
|
105
|
+
preStartHook?.();
|
|
107
106
|
const server = new server_1.ApolloServer({
|
|
108
107
|
typeDefs,
|
|
109
108
|
resolvers,
|
|
@@ -142,16 +141,15 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
142
141
|
}
|
|
143
142
|
createTransformHttpErrorFn() {
|
|
144
143
|
return (formattedError, originalError) => {
|
|
145
|
-
var _a;
|
|
146
144
|
const exceptionRef = (0, errors_1.unwrapResolverError)(originalError);
|
|
147
|
-
const isHttpException =
|
|
145
|
+
const isHttpException = exceptionRef?.response?.statusCode && exceptionRef?.status;
|
|
148
146
|
if (!isHttpException) {
|
|
149
147
|
return formattedError;
|
|
150
148
|
}
|
|
151
149
|
let error;
|
|
152
|
-
const httpStatus = exceptionRef
|
|
150
|
+
const httpStatus = exceptionRef?.status;
|
|
153
151
|
if (httpStatus in apolloPredefinedExceptions) {
|
|
154
|
-
error = new graphql_2.GraphQLError(exceptionRef
|
|
152
|
+
error = new graphql_2.GraphQLError(exceptionRef?.message, {
|
|
155
153
|
path: formattedError.path,
|
|
156
154
|
extensions: {
|
|
157
155
|
...formattedError.extensions,
|
|
@@ -169,7 +167,7 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
169
167
|
},
|
|
170
168
|
});
|
|
171
169
|
}
|
|
172
|
-
if (exceptionRef
|
|
170
|
+
if (exceptionRef?.response) {
|
|
173
171
|
error.extensions['originalError'] = exceptionRef.response;
|
|
174
172
|
}
|
|
175
173
|
error.locations = formattedError.locations;
|
|
@@ -179,25 +177,22 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
|
|
|
179
177
|
wrapContextResolver(targetOptions, originalOptions = { ...targetOptions }) {
|
|
180
178
|
if (!targetOptions.context) {
|
|
181
179
|
targetOptions.context = async (contextOrRequest) => {
|
|
182
|
-
var _a;
|
|
183
180
|
return {
|
|
184
181
|
// New ApolloServer fastify integration has Request as first parameter to the Context function
|
|
185
|
-
req:
|
|
182
|
+
req: contextOrRequest.req ?? contextOrRequest,
|
|
186
183
|
};
|
|
187
184
|
};
|
|
188
185
|
}
|
|
189
186
|
else if ((0, shared_utils_1.isFunction)(targetOptions.context)) {
|
|
190
187
|
targetOptions.context = async (...args) => {
|
|
191
|
-
var _a;
|
|
192
188
|
const ctx = await originalOptions.context(...args);
|
|
193
189
|
const contextOrRequest = args[0];
|
|
194
|
-
return this.assignReqProperty(ctx,
|
|
190
|
+
return this.assignReqProperty(ctx, contextOrRequest.req ?? contextOrRequest);
|
|
195
191
|
};
|
|
196
192
|
}
|
|
197
193
|
else {
|
|
198
194
|
targetOptions.context = async (contextOrRequest) => {
|
|
199
|
-
|
|
200
|
-
return this.assignReqProperty(originalOptions.context, (_a = contextOrRequest.req) !== null && _a !== void 0 ? _a : contextOrRequest);
|
|
195
|
+
return this.assignReqProperty(originalOptions.context, contextOrRequest.req ?? contextOrRequest);
|
|
201
196
|
};
|
|
202
197
|
}
|
|
203
198
|
}
|
|
@@ -8,7 +8,7 @@ const core_1 = require("@nestjs/core");
|
|
|
8
8
|
const graphql_1 = require("@nestjs/graphql");
|
|
9
9
|
const plugins_explorer_service_1 = require("../services/plugins-explorer.service");
|
|
10
10
|
const apollo_base_driver_1 = require("./apollo-base.driver");
|
|
11
|
-
let ApolloFederationDriver = class ApolloFederationDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
11
|
+
let ApolloFederationDriver = exports.ApolloFederationDriver = class ApolloFederationDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
12
12
|
constructor(graphqlFederationFactory, modulesContainer) {
|
|
13
13
|
super();
|
|
14
14
|
this.graphqlFederationFactory = graphqlFederationFactory;
|
|
@@ -30,9 +30,8 @@ let ApolloFederationDriver = class ApolloFederationDriver extends apollo_base_dr
|
|
|
30
30
|
return this.graphqlFederationFactory.generateSchema(options);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
ApolloFederationDriver = tslib_1.__decorate([
|
|
33
|
+
exports.ApolloFederationDriver = ApolloFederationDriver = tslib_1.__decorate([
|
|
34
34
|
(0, common_1.Injectable)(),
|
|
35
35
|
tslib_1.__metadata("design:paramtypes", [graphql_1.GraphQLFederationFactory,
|
|
36
36
|
core_1.ModulesContainer])
|
|
37
37
|
], ApolloFederationDriver);
|
|
38
|
-
exports.ApolloFederationDriver = ApolloFederationDriver;
|
|
@@ -8,7 +8,7 @@ const core_1 = require("@nestjs/core");
|
|
|
8
8
|
const graphql_1 = require("@nestjs/graphql");
|
|
9
9
|
const plugins_explorer_service_1 = require("../services/plugins-explorer.service");
|
|
10
10
|
const apollo_base_driver_1 = require("./apollo-base.driver");
|
|
11
|
-
let ApolloGatewayDriver = class ApolloGatewayDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
11
|
+
let ApolloGatewayDriver = exports.ApolloGatewayDriver = class ApolloGatewayDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
12
12
|
constructor(modulesContainer) {
|
|
13
13
|
super();
|
|
14
14
|
this.pluginsExplorerService = new plugins_explorer_service_1.PluginsExplorerService(modulesContainer);
|
|
@@ -24,18 +24,16 @@ let ApolloGatewayDriver = class ApolloGatewayDriver extends apollo_base_driver_1
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
async mergeDefaultOptions(options) {
|
|
27
|
-
var _a;
|
|
28
27
|
return {
|
|
29
28
|
...options,
|
|
30
|
-
server: await super.mergeDefaultOptions(
|
|
29
|
+
server: await super.mergeDefaultOptions(options?.server ?? {}),
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
32
|
generateSchema(_) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
|
-
ApolloGatewayDriver = tslib_1.__decorate([
|
|
36
|
+
exports.ApolloGatewayDriver = ApolloGatewayDriver = tslib_1.__decorate([
|
|
38
37
|
(0, common_1.Injectable)(),
|
|
39
38
|
tslib_1.__metadata("design:paramtypes", [core_1.ModulesContainer])
|
|
40
39
|
], ApolloGatewayDriver);
|
|
41
|
-
exports.ApolloGatewayDriver = ApolloGatewayDriver;
|
|
@@ -8,13 +8,12 @@ const graphql_1 = require("@nestjs/graphql");
|
|
|
8
8
|
const graphql_2 = require("graphql");
|
|
9
9
|
const plugins_explorer_service_1 = require("../services/plugins-explorer.service");
|
|
10
10
|
const apollo_base_driver_1 = require("./apollo-base.driver");
|
|
11
|
-
let ApolloDriver = class ApolloDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
11
|
+
let ApolloDriver = exports.ApolloDriver = class ApolloDriver extends apollo_base_driver_1.ApolloBaseDriver {
|
|
12
12
|
constructor(modulesContainer) {
|
|
13
13
|
super();
|
|
14
14
|
this.pluginsExplorerService = new plugins_explorer_service_1.PluginsExplorerService(modulesContainer);
|
|
15
15
|
}
|
|
16
16
|
async start(options) {
|
|
17
|
-
var _a;
|
|
18
17
|
options.plugins = (0, graphql_1.extend)(options.plugins || [], this.pluginsExplorerService.explore(options));
|
|
19
18
|
if (options.definitions && options.definitions.path) {
|
|
20
19
|
await this.graphQlFactory.generateDefinitions((0, graphql_2.printSchema)(options.schema), options);
|
|
@@ -27,7 +26,7 @@ let ApolloDriver = class ApolloDriver extends apollo_base_driver_1.ApolloBaseDri
|
|
|
27
26
|
path: options.path,
|
|
28
27
|
context: options.context,
|
|
29
28
|
...subscriptionsOptions,
|
|
30
|
-
},
|
|
29
|
+
}, this.httpAdapterHost.httpAdapter?.getHttpServer());
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
async registerServer(apolloOptions) {
|
|
@@ -44,13 +43,11 @@ let ApolloDriver = class ApolloDriver extends apollo_base_driver_1.ApolloBaseDri
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
async stop() {
|
|
47
|
-
|
|
48
|
-
await ((_a = this._subscriptionService) === null || _a === void 0 ? void 0 : _a.stop());
|
|
46
|
+
await this._subscriptionService?.stop();
|
|
49
47
|
await super.stop();
|
|
50
48
|
}
|
|
51
49
|
};
|
|
52
|
-
ApolloDriver = tslib_1.__decorate([
|
|
50
|
+
exports.ApolloDriver = ApolloDriver = tslib_1.__decorate([
|
|
53
51
|
(0, common_1.Injectable)(),
|
|
54
52
|
tslib_1.__metadata("design:paramtypes", [core_1.ModulesContainer])
|
|
55
53
|
], ApolloDriver);
|
|
56
|
-
exports.ApolloDriver = ApolloDriver;
|
|
@@ -15,7 +15,7 @@ class UserInputError extends graphql_1.GraphQLError {
|
|
|
15
15
|
...options,
|
|
16
16
|
extensions: {
|
|
17
17
|
code: errors_1.ApolloServerErrorCode.BAD_USER_INPUT,
|
|
18
|
-
...options
|
|
18
|
+
...options?.extensions,
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -15,7 +15,7 @@ class ValidationError extends graphql_1.GraphQLError {
|
|
|
15
15
|
...options,
|
|
16
16
|
extensions: {
|
|
17
17
|
code: errors_1.ApolloServerErrorCode.GRAPHQL_VALIDATION_FAILED,
|
|
18
|
-
...options
|
|
18
|
+
...options?.extensions,
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -8,10 +8,9 @@ const graphql_1 = require("@nestjs/graphql");
|
|
|
8
8
|
* @returns Apollo Server instance used by the host application
|
|
9
9
|
*/
|
|
10
10
|
const getApolloServer = (app) => {
|
|
11
|
-
var _a;
|
|
12
11
|
try {
|
|
13
12
|
const graphqlModule = app.get(graphql_1.GraphQLModule);
|
|
14
|
-
return
|
|
13
|
+
return graphqlModule.graphQlAdapter?.instance;
|
|
15
14
|
}
|
|
16
15
|
catch (error) { }
|
|
17
16
|
throw new Error(`Nest could not find the "GraphQLModule" in your application's container. Please, double-check if it's registered in the given application.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/apollo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"@apollo/server-plugin-response-cache": "4.1.0",
|
|
28
28
|
"@apollo/subgraph": "2.2.3",
|
|
29
29
|
"@as-integrations/fastify": "2.0.0",
|
|
30
|
-
"@nestjs/common": "
|
|
31
|
-
"@nestjs/core": "
|
|
32
|
-
"@nestjs/platform-express": "
|
|
33
|
-
"@nestjs/platform-fastify": "
|
|
34
|
-
"@nestjs/testing": "
|
|
30
|
+
"@nestjs/common": "10.0.0",
|
|
31
|
+
"@nestjs/core": "10.0.0",
|
|
32
|
+
"@nestjs/platform-express": "10.0.0",
|
|
33
|
+
"@nestjs/platform-fastify": "10.0.0",
|
|
34
|
+
"@nestjs/testing": "10.0.0",
|
|
35
35
|
"apollo-cache-inmemory": "1.6.6",
|
|
36
36
|
"apollo-client": "2.6.10",
|
|
37
37
|
"apollo-link-ws": "1.0.20"
|
|
@@ -40,16 +40,16 @@
|
|
|
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",
|
|
43
|
-
"tslib": "2.5.
|
|
43
|
+
"tslib": "2.5.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@apollo/gateway": "^2.0.0",
|
|
47
47
|
"@apollo/server": "^4.3.2",
|
|
48
48
|
"@apollo/subgraph": "^2.0.0",
|
|
49
49
|
"@as-integrations/fastify": "^1.3.0 || ^2.0.0",
|
|
50
|
-
"@nestjs/common": "^9.0.0",
|
|
51
|
-
"@nestjs/core": "^9.3.8",
|
|
52
|
-
"@nestjs/graphql": "^
|
|
50
|
+
"@nestjs/common": "^9.3.8 || ^10.0.0",
|
|
51
|
+
"@nestjs/core": "^9.3.8 || ^10.0.0",
|
|
52
|
+
"@nestjs/graphql": "^12.0.0",
|
|
53
53
|
"graphql": "^16.6.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"optional": true
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "a1ae79e244e78846db59183c63df06977b369245"
|
|
67
67
|
}
|