@rsdk/graphql 5.10.0-next.0 → 5.10.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.
- package/dist/graphql.plugin.d.ts +4 -0
- package/dist/graphql.plugin.js +19 -14
- package/dist/graphql.plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/graphql.plugin.ts +30 -14
package/dist/graphql.plugin.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { ApolloServerPlugin } from '@apollo/server';
|
|
1
2
|
import type { MiddlewareConsumer } from '@nestjs/common';
|
|
2
3
|
import type { AutoSchemaFileValue } from '@nestjs/graphql';
|
|
3
4
|
import type { IErrorsFormatter, IErrorsSender, NestModuleDefinitions, PlatformAppPlugin, WithGenericHeaders } from '@rsdk/core';
|
|
5
|
+
import type { ValidationRule } from 'graphql';
|
|
4
6
|
export type Approach = 'schema-first' | 'code-first';
|
|
5
7
|
export interface GraphQLPluginOptions<T extends Approach> {
|
|
6
8
|
approach: T;
|
|
7
9
|
path?: string;
|
|
8
10
|
middleware?: Function[];
|
|
11
|
+
validationRules?: ValidationRule[];
|
|
12
|
+
plugins?: ApolloServerPlugin[];
|
|
9
13
|
}
|
|
10
14
|
export interface GraphQLPluginSchemaFirstOptions extends GraphQLPluginOptions<'schema-first'> {
|
|
11
15
|
typePaths: string[];
|
package/dist/graphql.plugin.js
CHANGED
|
@@ -75,6 +75,21 @@ class GraphQLPlugin {
|
|
|
75
75
|
const playgroundEnabled = config.playgroundEnabled
|
|
76
76
|
? playgroundEnabledValue
|
|
77
77
|
: false;
|
|
78
|
+
const plugins = [];
|
|
79
|
+
if (config.playgroundType === config_1.Playground.ApolloSandbox) {
|
|
80
|
+
plugins.push((0, default_1.ApolloServerPluginLandingPageLocalDefault)({
|
|
81
|
+
embed: {
|
|
82
|
+
runTelemetry: false,
|
|
83
|
+
endpointIsEditable: true,
|
|
84
|
+
initialState: {
|
|
85
|
+
pollForSchemaUpdates: true,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}), (0, inlineTrace_1.ApolloServerPluginInlineTrace)());
|
|
89
|
+
}
|
|
90
|
+
if (this.options.plugins?.length) {
|
|
91
|
+
plugins.push(...this.options.plugins);
|
|
92
|
+
}
|
|
78
93
|
return {
|
|
79
94
|
path: this.path,
|
|
80
95
|
...((0, exports.isCodeFirst)(this.options) && {
|
|
@@ -102,20 +117,6 @@ class GraphQLPlugin {
|
|
|
102
117
|
installSubscriptionHandlers: true,
|
|
103
118
|
introspection: config.playgroundEnabled,
|
|
104
119
|
playground: playgroundEnabled,
|
|
105
|
-
...(config.playgroundType === config_1.Playground.ApolloSandbox && {
|
|
106
|
-
plugins: [
|
|
107
|
-
(0, default_1.ApolloServerPluginLandingPageLocalDefault)({
|
|
108
|
-
embed: {
|
|
109
|
-
runTelemetry: false,
|
|
110
|
-
endpointIsEditable: true,
|
|
111
|
-
initialState: {
|
|
112
|
-
pollForSchemaUpdates: true,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
}),
|
|
116
|
-
(0, inlineTrace_1.ApolloServerPluginInlineTrace)(),
|
|
117
|
-
],
|
|
118
|
-
}),
|
|
119
120
|
subscriptions: {
|
|
120
121
|
'graphql-ws': {
|
|
121
122
|
onConnect,
|
|
@@ -134,6 +135,10 @@ class GraphQLPlugin {
|
|
|
134
135
|
}),
|
|
135
136
|
},
|
|
136
137
|
useGlobalPrefix: true,
|
|
138
|
+
...(this.options.validationRules && {
|
|
139
|
+
validationRules: this.options.validationRules,
|
|
140
|
+
}),
|
|
141
|
+
plugins,
|
|
137
142
|
// https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
|
|
138
143
|
// directiveResolvers: ['interceptors'],
|
|
139
144
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"graphql.pl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,CAAC,CAAC,MAAM,CAAC,+BAA+B;gCACzC,MAAM,CAAC,iBAAiB,CAAC,IAAI;gCAC7B,4BAA4B,EAAE,IAAA,sBAAa,EAAC;oCAC1C,SAAS;oCACT,IAAI,EAAE,IAAI,CAAC,IAAI;oCACf,SAAS,EAAE,MAAM,CAAC,iCAAiC;iCACpD,CAAC;6BACH,CAAC;yBACH;wBACD,eAAe,EAAE,IAAI;wBAErB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI;4BAClC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe;yBAC9C,CAAC;wBACF,OAAO;wBAEP,sEAAsE;wBACtE,wCAAwC;qBACzC,CAAC;gBACJ,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;IAED,mBAAmB,CAAC,QAA4B;QAC9C,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACvD,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,uCAAsB,EAAE,CAAC;IACtC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,oCAAmB,EAAE,CAAC;IACnC,CAAC;CACF;AA9JD,sCA8JC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/graphql",
|
|
3
|
-
"version": "5.10.0-next.
|
|
3
|
+
"version": "5.10.0-next.2",
|
|
4
4
|
"description": "Plugin for graphql",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
|
30
30
|
"rxjs": "^7.1.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "416b632b57b5b0bf1282dbcb24cfc56624b55c26"
|
|
33
33
|
}
|
package/src/graphql.plugin.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApolloServerPlugin } from '@apollo/server';
|
|
1
2
|
import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
|
|
2
3
|
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
|
|
3
4
|
import type { ApolloDriverConfig } from '@nestjs/apollo';
|
|
@@ -15,6 +16,7 @@ import type {
|
|
|
15
16
|
WithGenericHeaders,
|
|
16
17
|
} from '@rsdk/core';
|
|
17
18
|
import { LoggerFactory } from '@rsdk/logging';
|
|
19
|
+
import type { ValidationRule } from 'graphql';
|
|
18
20
|
|
|
19
21
|
import { ApolloLoggerAdapter } from './apollo-logger.adapter';
|
|
20
22
|
import { GraphqlConfig, Playground } from './config';
|
|
@@ -42,6 +44,8 @@ export interface GraphQLPluginOptions<T extends Approach> {
|
|
|
42
44
|
path?: string;
|
|
43
45
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
44
46
|
middleware?: Function[];
|
|
47
|
+
validationRules?: ValidationRule[];
|
|
48
|
+
plugins?: ApolloServerPlugin[];
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
// Schema first
|
|
@@ -128,6 +132,27 @@ export class GraphQLPlugin implements PlatformAppPlugin {
|
|
|
128
132
|
? playgroundEnabledValue
|
|
129
133
|
: false;
|
|
130
134
|
|
|
135
|
+
const plugins: ApolloServerPlugin[] = [];
|
|
136
|
+
|
|
137
|
+
if (config.playgroundType === Playground.ApolloSandbox) {
|
|
138
|
+
plugins.push(
|
|
139
|
+
ApolloServerPluginLandingPageLocalDefault({
|
|
140
|
+
embed: {
|
|
141
|
+
runTelemetry: false,
|
|
142
|
+
endpointIsEditable: true,
|
|
143
|
+
initialState: {
|
|
144
|
+
pollForSchemaUpdates: true,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
ApolloServerPluginInlineTrace(),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (this.options.plugins?.length) {
|
|
153
|
+
plugins.push(...this.options.plugins);
|
|
154
|
+
}
|
|
155
|
+
|
|
131
156
|
return {
|
|
132
157
|
path: this.path,
|
|
133
158
|
...(isCodeFirst(this.options) && {
|
|
@@ -159,20 +184,6 @@ export class GraphQLPlugin implements PlatformAppPlugin {
|
|
|
159
184
|
installSubscriptionHandlers: true,
|
|
160
185
|
introspection: config.playgroundEnabled,
|
|
161
186
|
playground: playgroundEnabled,
|
|
162
|
-
...(config.playgroundType === Playground.ApolloSandbox && {
|
|
163
|
-
plugins: [
|
|
164
|
-
ApolloServerPluginLandingPageLocalDefault({
|
|
165
|
-
embed: {
|
|
166
|
-
runTelemetry: false,
|
|
167
|
-
endpointIsEditable: true,
|
|
168
|
-
initialState: {
|
|
169
|
-
pollForSchemaUpdates: true,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
ApolloServerPluginInlineTrace(),
|
|
174
|
-
],
|
|
175
|
-
}),
|
|
176
187
|
subscriptions: {
|
|
177
188
|
'graphql-ws': {
|
|
178
189
|
onConnect,
|
|
@@ -193,6 +204,11 @@ export class GraphQLPlugin implements PlatformAppPlugin {
|
|
|
193
204
|
},
|
|
194
205
|
useGlobalPrefix: true,
|
|
195
206
|
|
|
207
|
+
...(this.options.validationRules && {
|
|
208
|
+
validationRules: this.options.validationRules,
|
|
209
|
+
}),
|
|
210
|
+
plugins,
|
|
211
|
+
|
|
196
212
|
// https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
|
|
197
213
|
// directiveResolvers: ['interceptors'],
|
|
198
214
|
};
|