@rsdk/graphql 4.4.0-next.1 → 4.5.0-next.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.5.0-next.0](https://github.com/R-Vision/rsdk/compare/v4.4.0...v4.5.0-next.0) (2024-04-15)
7
+
8
+ ### Features
9
+
10
+ * **graphql:** added apollo sandbox for graphql playground type ([68eb22f](https://github.com/R-Vision/rsdk/commit/68eb22f2c603be51aed8088a5581d6576d2bff7b))
11
+
12
+ ## [4.4.0](https://github.com/R-Vision/rsdk/compare/v4.4.0-next.1...v4.4.0) (2024-04-08)
13
+
14
+ **Note:** Version bump only for package @rsdk/graphql
15
+
6
16
  ## [4.4.0-next.1](https://github.com/R-Vision/rsdk/compare/v4.4.0-next.0...v4.4.0-next.1) (2024-03-27)
7
17
 
8
18
  **Note:** Version bump only for package @rsdk/graphql
package/dist/config.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { Config } from '@rsdk/core';
2
+ export declare enum Playground {
3
+ Default = "default",
4
+ ApolloSandbox = "apollo-sandbox"
5
+ }
2
6
  export declare class GraphqlConfig extends Config {
3
- playground: boolean;
7
+ playgroundEnabled: boolean;
8
+ playgroundType: Playground;
4
9
  requestLogging: boolean;
5
10
  }
package/dist/config.js CHANGED
@@ -9,10 +9,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GraphqlConfig = void 0;
12
+ exports.GraphqlConfig = exports.Playground = void 0;
13
13
  const core_1 = require("@rsdk/core");
14
+ var Playground;
15
+ (function (Playground) {
16
+ Playground["Default"] = "default";
17
+ Playground["ApolloSandbox"] = "apollo-sandbox";
18
+ })(Playground || (exports.Playground = Playground = {}));
14
19
  let GraphqlConfig = class GraphqlConfig extends core_1.Config {
15
- playground;
20
+ playgroundEnabled;
21
+ playgroundType;
16
22
  requestLogging;
17
23
  };
18
24
  exports.GraphqlConfig = GraphqlConfig;
@@ -22,7 +28,14 @@ __decorate([
22
28
  description: 'Enables GraphQL playground and introspection',
23
29
  }),
24
30
  __metadata("design:type", Boolean)
25
- ], GraphqlConfig.prototype, "playground", void 0);
31
+ ], GraphqlConfig.prototype, "playgroundEnabled", void 0);
32
+ __decorate([
33
+ (0, core_1.Property)('GRAPHQL_PLAYGROUND', new core_1.EnumParser(Playground), {
34
+ defaultValue: Playground.Default,
35
+ description: 'Playground type',
36
+ }),
37
+ __metadata("design:type", String)
38
+ ], GraphqlConfig.prototype, "playgroundType", void 0);
26
39
  __decorate([
27
40
  (0, core_1.Property)('GRAPHQL_REQUEST_LOGGING', new core_1.BoolParser(), {
28
41
  defaultValue: false,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMoB;AAKb,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,aAAM;IAKvC,UAAU,CAAW;IAMrB,cAAc,CAAW;CAC1B,CAAA;AAZY,sCAAa;AAKxB;IAJC,IAAA,eAAQ,EAAC,2BAA2B,EAAE,IAAI,iBAAU,EAAE,EAAE;QACvD,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,8CAA8C;KAC5D,CAAC;;iDACmB;AAMrB;IAJC,IAAA,eAAQ,EAAC,yBAAyB,EAAE,IAAI,iBAAU,EAAE,EAAE;QACrD,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,mCAAmC;KACjD,CAAC;;qDACuB;wBAXd,aAAa;IAHzB,IAAA,oBAAa,EAAC;QACb,IAAI,EAAE,CAAC,gBAAS,CAAC,cAAc,EAAE,gBAAS,CAAC,SAAS,EAAE,gBAAS,CAAC,OAAO,CAAC;KACzE,CAAC;GACW,aAAa,CAYzB"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOoB;AAEpB,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,8CAAgC,CAAA;AAClC,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAKM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,aAAM;IAKvC,iBAAiB,CAAW;IAM5B,cAAc,CAAc;IAM5B,cAAc,CAAW;CAC1B,CAAA;AAlBY,sCAAa;AAKxB;IAJC,IAAA,eAAQ,EAAC,2BAA2B,EAAE,IAAI,iBAAU,EAAE,EAAE;QACvD,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,8CAA8C;KAC5D,CAAC;;wDAC0B;AAM5B;IAJC,IAAA,eAAQ,EAAC,oBAAoB,EAAE,IAAI,iBAAU,CAAC,UAAU,CAAC,EAAE;QAC1D,YAAY,EAAE,UAAU,CAAC,OAAO;QAChC,WAAW,EAAE,iBAAiB;KAC/B,CAAC;;qDAC0B;AAM5B;IAJC,IAAA,eAAQ,EAAC,yBAAyB,EAAE,IAAI,iBAAU,EAAE,EAAE;QACrD,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,mCAAmC;KACjD,CAAC;;qDACuB;wBAjBd,aAAa;IAHzB,IAAA,oBAAa,EAAC;QACb,IAAI,EAAE,CAAC,gBAAS,CAAC,cAAc,EAAE,gBAAS,CAAC,SAAS,EAAE,gBAAS,CAAC,OAAO,CAAC;KACzE,CAAC;GACW,aAAa,CAkBzB"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GraphQLPlugin = exports.isCodeFirst = exports.isSchemaFirst = void 0;
4
+ const inlineTrace_1 = require("@apollo/server/plugin/inlineTrace");
5
+ const default_1 = require("@apollo/server/plugin/landingPage/default");
4
6
  const apollo_1 = require("@nestjs/apollo");
5
7
  const core_1 = require("@nestjs/core");
6
8
  const graphql_1 = require("@nestjs/graphql");
@@ -59,55 +61,68 @@ class GraphQLPlugin {
59
61
  graphql_1.GraphQLModule.forRootAsync({
60
62
  inject: [config_1.GraphqlConfig],
61
63
  driver: apollo_1.ApolloDriver,
62
- useFactory: (config) => ({
63
- path: this.path,
64
- ...((0, exports.isCodeFirst)(this.options) && {
65
- autoSchemaFile: this.options.autoSchemaFile ?? 'schema.graqhql',
66
- buildSchemaOptions: {
67
- numberScalarMode: 'integer',
68
- },
69
- sortSchema: true,
70
- }),
71
- ...((0, exports.isSchemaFirst)(this.options) && {
72
- typePaths: this.options.typePaths,
73
- }),
74
- // Что это?
75
- context: ({ req, connection }) => ({
76
- /**
77
- * Иногда даже контекста может не быть, поэтому "?"
78
- */
79
- req: req ?? connection?.context,
80
- }),
81
- fieldResolverEnhancers: ['filters'],
82
- formatError: error_handling_1.GraphQLErrorsFormatter.finalFormat,
83
- logger: new apollo_logger_adapter_1.ApolloLoggerAdapter(logging_1.LoggerFactory.create('Apollo')),
84
- installSubscriptionHandlers: true,
85
- introspection: config.playground,
86
- playground: config.playground
64
+ useFactory: (config) => {
65
+ //
66
+ const playgroundEnabledValue = config.playgroundType === config_1.Playground.Default
87
67
  ? {
88
68
  endpoint: this.path,
89
69
  subscriptionEndpoint: this.path,
90
70
  }
91
- : false,
92
- subscriptions: {
93
- 'graphql-ws': {
94
- onConnect,
95
- path: this.path,
96
- },
97
- // Этот вариант нужен (пока - на 23.02.2023) только для поддержки
98
- // playground. Вероятно, при переходе на Apollo 4 надобность в
99
- // этом отпадёты
100
- ...(config.playground && {
101
- 'subscriptions-transport-ws': {
71
+ : false;
72
+ const playgroundEnabled = config.playgroundEnabled
73
+ ? playgroundEnabledValue
74
+ : false;
75
+ return {
76
+ path: this.path,
77
+ ...((0, exports.isCodeFirst)(this.options) && {
78
+ autoSchemaFile: this.options.autoSchemaFile ?? 'schema.graqhql',
79
+ buildSchemaOptions: {
80
+ numberScalarMode: 'integer',
81
+ },
82
+ sortSchema: true,
83
+ }),
84
+ ...((0, exports.isSchemaFirst)(this.options) && {
85
+ typePaths: this.options.typePaths,
86
+ }),
87
+ // Что это?
88
+ context: ({ req, connection }) => ({
89
+ /**
90
+ * Иногда даже контекста может не быть, поэтому "?"
91
+ */
92
+ req: req ?? connection?.context,
93
+ }),
94
+ fieldResolverEnhancers: ['filters'],
95
+ formatError: error_handling_1.GraphQLErrorsFormatter.finalFormat,
96
+ logger: new apollo_logger_adapter_1.ApolloLoggerAdapter(logging_1.LoggerFactory.create('Apollo')),
97
+ installSubscriptionHandlers: true,
98
+ introspection: config.playgroundEnabled,
99
+ playground: playgroundEnabled,
100
+ ...(config.playgroundType === config_1.Playground.ApolloSandbox && {
101
+ plugins: [
102
+ (0, default_1.ApolloServerPluginLandingPageLocalDefault)(),
103
+ (0, inlineTrace_1.ApolloServerPluginInlineTrace)(),
104
+ ],
105
+ }),
106
+ subscriptions: {
107
+ 'graphql-ws': {
102
108
  onConnect,
103
109
  path: this.path,
104
110
  },
105
- }),
106
- },
107
- useGlobalPrefix: true,
108
- // https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
109
- // directiveResolvers: ['interceptors'],
110
- }),
111
+ // Этот вариант нужен (пока - на 23.02.2023) только для поддержки
112
+ // playground. Вероятно, при переходе на Apollo 4 надобность в
113
+ // этом отпадёты
114
+ ...(config.playgroundEnabled && {
115
+ 'subscriptions-transport-ws': {
116
+ onConnect,
117
+ path: this.path,
118
+ },
119
+ }),
120
+ },
121
+ useGlobalPrefix: true,
122
+ // https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
123
+ // directiveResolvers: ['interceptors'],
124
+ };
125
+ },
111
126
  }),
112
127
  ];
113
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAE9C,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I;wBACjC,aAAa,EAAE,MAAM,CAAC,iBAAiB;wBACvC,UAAU,EAAE,iBAAiB;wBAC7B,GAAG,CAAC,MAAM,CAAC,cAAc,KAAK,mBAAU,CAAC,aAAa,IAAI;4BACxD,OAAO,EAAE;gCACP,IAAA,mDAAyC,GAAE;gCAC3C,IAAA,2CAA6B,GAAE;6BAChC;yBACF,CAAC;wBACF,aAAa,EAAE;4BACb,YAAY,EAAE;gCACZ,SAAS;gCACT,IAAI,EAAE,IAAI,CAAC,IAAI;6BAChB;4BAED,iEAAiE;4BACjE,8DAA8D;4BAC9D,gBAAgB;4BAChB,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI;gCAC9B,4BAA4B,EAAE;oCAC5B,SAAS;oCACT,IAAI,EAAE,IAAI,CAAC,IAAI;iCAChB;6BACF,CAAC;yBACH;wBACD,eAAe,EAAE,IAAI;wBACrB,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;AAlID,sCAkIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/graphql",
3
- "version": "4.4.0-next.1",
3
+ "version": "4.5.0-next.0",
4
4
  "description": "Plugin for graphql",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -19,15 +19,15 @@
19
19
  "@nestjs/common": "^10.0.0",
20
20
  "@nestjs/core": "^10.0.0",
21
21
  "@nestjs/graphql": "^12.0.8",
22
- "@rsdk/common": "^4.4.0-next.1",
23
- "@rsdk/core": "^4.4.0-next.1",
24
- "@rsdk/http.server": "^4.4.0-next.1",
25
- "@rsdk/http.server.express": "^4.4.0-next.1",
26
- "@rsdk/logging": "^4.4.0-next.1",
22
+ "@rsdk/common": "^4.5.0-next.0",
23
+ "@rsdk/core": "^4.5.0-next.0",
24
+ "@rsdk/http.server": "^4.5.0-next.0",
25
+ "@rsdk/http.server.express": "^4.5.0-next.0",
26
+ "@rsdk/logging": "^4.5.0-next.0",
27
27
  "graphql": "^16.6.0",
28
28
  "graphql-subscriptions": "^2.0.0",
29
29
  "reflect-metadata": "^0.1.12 || ^0.2.0",
30
30
  "rxjs": "^7.8.1"
31
31
  },
32
- "gitHead": "0c92663051001488d257bdc346ebecdb2c853e41"
32
+ "gitHead": "addd421d30c57e6cb3ac21b82f8942c1b482f97f"
33
33
  }
package/src/config.ts CHANGED
@@ -3,9 +3,15 @@ import {
3
3
  Config,
4
4
  ConfigSection,
5
5
  ConfigTag,
6
+ EnumParser,
6
7
  Property,
7
8
  } from '@rsdk/core';
8
9
 
10
+ export enum Playground {
11
+ Default = 'default',
12
+ ApolloSandbox = 'apollo-sandbox',
13
+ }
14
+
9
15
  @ConfigSection({
10
16
  tags: [ConfigTag.infrastructure, ConfigTag.transport, ConfigTag.graphql],
11
17
  })
@@ -14,7 +20,13 @@ export class GraphqlConfig extends Config {
14
20
  defaultValue: false,
15
21
  description: 'Enables GraphQL playground and introspection',
16
22
  })
17
- playground!: boolean;
23
+ playgroundEnabled!: boolean;
24
+
25
+ @Property('GRAPHQL_PLAYGROUND', new EnumParser(Playground), {
26
+ defaultValue: Playground.Default,
27
+ description: 'Playground type',
28
+ })
29
+ playgroundType!: Playground;
18
30
 
19
31
  @Property('GRAPHQL_REQUEST_LOGGING', new BoolParser(), {
20
32
  defaultValue: false,
@@ -1,3 +1,5 @@
1
+ import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
2
+ import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
1
3
  import type { ApolloDriverConfig } from '@nestjs/apollo';
2
4
  import { ApolloDriver } from '@nestjs/apollo';
3
5
  import type { MiddlewareConsumer } from '@nestjs/common';
@@ -13,7 +15,7 @@ import type {
13
15
  import { LoggerFactory } from '@rsdk/logging';
14
16
 
15
17
  import { ApolloLoggerAdapter } from './apollo-logger.adapter';
16
- import { GraphqlConfig } from './config';
18
+ import { GraphqlConfig, Playground } from './config';
17
19
  import { GraphQLErrorsFormatter, GraphQLErrorsSender } from './error-handling';
18
20
  import { GqlTracingExtractor } from './gql.tracing-extractor';
19
21
  import { GraphqlLoggerInterceptor } from './graphql-logger.interceptor';
@@ -109,60 +111,74 @@ export class GraphQLPlugin implements PlatformAppPlugin {
109
111
  inject: [GraphqlConfig],
110
112
  driver: ApolloDriver,
111
113
 
112
- useFactory: (config: GraphqlConfig) => ({
113
- path: this.path,
114
- ...(isCodeFirst(this.options) && {
115
- autoSchemaFile: this.options.autoSchemaFile ?? 'schema.graqhql',
116
- buildSchemaOptions: {
117
- numberScalarMode: 'integer',
118
- },
119
- sortSchema: true,
120
- }),
121
-
122
- ...(isSchemaFirst(this.options) && {
123
- typePaths: this.options.typePaths,
124
- }),
125
-
126
- // Что это?
127
- context: ({ req, connection }: any) => ({
128
- /**
129
- * Иногда даже контекста может не быть, поэтому "?"
130
- */
131
- req: req ?? connection?.context,
132
- }),
133
- fieldResolverEnhancers: ['filters'],
134
- formatError: GraphQLErrorsFormatter.finalFormat,
135
-
136
- logger: new ApolloLoggerAdapter(LoggerFactory.create('Apollo')),
137
-
138
- installSubscriptionHandlers: true,
139
- introspection: config.playground,
140
- playground: config.playground
141
- ? {
142
- endpoint: this.path,
143
- subscriptionEndpoint: this.path,
144
- }
145
- : false,
146
- subscriptions: {
147
- 'graphql-ws': {
148
- onConnect,
149
- path: this.path,
150
- },
114
+ useFactory: (config: GraphqlConfig) => {
115
+ //
116
+ const playgroundEnabledValue =
117
+ config.playgroundType === Playground.Default
118
+ ? {
119
+ endpoint: this.path,
120
+ subscriptionEndpoint: this.path,
121
+ }
122
+ : false;
123
+ const playgroundEnabled = config.playgroundEnabled
124
+ ? playgroundEnabledValue
125
+ : false;
126
+
127
+ return {
128
+ path: this.path,
129
+ ...(isCodeFirst(this.options) && {
130
+ autoSchemaFile: this.options.autoSchemaFile ?? 'schema.graqhql',
131
+ buildSchemaOptions: {
132
+ numberScalarMode: 'integer',
133
+ },
134
+ sortSchema: true,
135
+ }),
136
+ ...(isSchemaFirst(this.options) && {
137
+ typePaths: this.options.typePaths,
138
+ }),
151
139
 
152
- // Этот вариант нужен (пока - на 23.02.2023) только для поддержки
153
- // playground. Вероятно, при переходе на Apollo 4 надобность в
154
- // этом отпадёты
155
- ...(config.playground && {
156
- 'subscriptions-transport-ws': {
140
+ // Что это?
141
+ context: ({ req, connection }: any) => ({
142
+ /**
143
+ * Иногда даже контекста может не быть, поэтому "?"
144
+ */
145
+ req: req ?? connection?.context,
146
+ }),
147
+ fieldResolverEnhancers: ['filters'],
148
+ formatError: GraphQLErrorsFormatter.finalFormat,
149
+
150
+ logger: new ApolloLoggerAdapter(LoggerFactory.create('Apollo')),
151
+
152
+ installSubscriptionHandlers: true,
153
+ introspection: config.playgroundEnabled,
154
+ playground: playgroundEnabled,
155
+ ...(config.playgroundType === Playground.ApolloSandbox && {
156
+ plugins: [
157
+ ApolloServerPluginLandingPageLocalDefault(),
158
+ ApolloServerPluginInlineTrace(),
159
+ ],
160
+ }),
161
+ subscriptions: {
162
+ 'graphql-ws': {
157
163
  onConnect,
158
164
  path: this.path,
159
165
  },
160
- }),
161
- },
162
- useGlobalPrefix: true,
163
- // https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
164
- // directiveResolvers: ['interceptors'],
165
- }),
166
+
167
+ // Этот вариант нужен (пока - на 23.02.2023) только для поддержки
168
+ // playground. Вероятно, при переходе на Apollo 4 надобность в
169
+ // этом отпадёты
170
+ ...(config.playgroundEnabled && {
171
+ 'subscriptions-transport-ws': {
172
+ onConnect,
173
+ path: this.path,
174
+ },
175
+ }),
176
+ },
177
+ useGlobalPrefix: true,
178
+ // https://github.com/nestjs/graphql/issues/295#issuecomment-511191060
179
+ // directiveResolvers: ['interceptors'],
180
+ };
181
+ },
166
182
  }),
167
183
  ];
168
184
  }