@rsdk/graphql 4.2.5-next.0 → 4.3.0-next.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/CHANGELOG.md +10 -0
- package/dist/{graphql.config.d.ts → config.d.ts} +1 -1
- package/dist/{graphql.config.js → config.js} +8 -8
- package/dist/config.js.map +1 -0
- package/dist/gql.tracing-extractor.d.ts +6 -0
- package/dist/gql.tracing-extractor.js +24 -0
- package/dist/gql.tracing-extractor.js.map +1 -0
- package/dist/graphql-logger.interceptor.d.ts +2 -2
- package/dist/graphql-logger.interceptor.js +2 -2
- package/dist/graphql-logger.interceptor.js.map +1 -1
- package/dist/graphql.plugin.d.ts +5 -1
- package/dist/graphql.plugin.js +11 -2
- package/dist/graphql.plugin.js.map +1 -1
- package/package.json +8 -7
- package/src/{graphql.config.ts → config.ts} +1 -1
- package/src/gql.tracing-extractor.ts +25 -0
- package/src/graphql-logger.interceptor.ts +2 -2
- package/src/graphql.plugin.ts +17 -3
- package/dist/graphql.config.js.map +0 -1
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.3.0-next.1](https://github.com/R-Vision/rsdk/compare/v4.3.0-next.0...v4.3.0-next.1) (2024-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsdk/graphql
|
|
9
|
+
|
|
10
|
+
## [4.3.0-next.0](https://github.com/R-Vision/rsdk/compare/v4.2.5-next.0...v4.3.0-next.0) (2024-03-19)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* reworked cli system ([745ebf5](https://github.com/R-Vision/rsdk/commit/745ebf53635de135a4a9083f47ce833efe2d4411))
|
|
15
|
+
|
|
6
16
|
## [4.2.5-next.0](https://github.com/R-Vision/rsdk/compare/v4.2.4...v4.2.5-next.0) (2024-03-04)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @rsdk/graphql
|
|
@@ -9,30 +9,30 @@ 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.
|
|
12
|
+
exports.GraphqlConfig = void 0;
|
|
13
13
|
const core_1 = require("@rsdk/core");
|
|
14
|
-
let
|
|
14
|
+
let GraphqlConfig = class GraphqlConfig extends core_1.Config {
|
|
15
15
|
playground;
|
|
16
16
|
requestLogging;
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
18
|
+
exports.GraphqlConfig = GraphqlConfig;
|
|
19
19
|
__decorate([
|
|
20
20
|
(0, core_1.Property)('GRAPHQL_ENABLE_PLAYGROUND', new core_1.BoolParser(), {
|
|
21
21
|
defaultValue: false,
|
|
22
22
|
description: 'Enables GraphQL playground and introspection',
|
|
23
23
|
}),
|
|
24
24
|
__metadata("design:type", Boolean)
|
|
25
|
-
],
|
|
25
|
+
], GraphqlConfig.prototype, "playground", void 0);
|
|
26
26
|
__decorate([
|
|
27
27
|
(0, core_1.Property)('GRAPHQL_REQUEST_LOGGING', new core_1.BoolParser(), {
|
|
28
28
|
defaultValue: false,
|
|
29
29
|
description: 'Enable trace logging all requests',
|
|
30
30
|
}),
|
|
31
31
|
__metadata("design:type", Boolean)
|
|
32
|
-
],
|
|
33
|
-
exports.
|
|
32
|
+
], GraphqlConfig.prototype, "requestLogging", void 0);
|
|
33
|
+
exports.GraphqlConfig = GraphqlConfig = __decorate([
|
|
34
34
|
(0, core_1.ConfigSection)({
|
|
35
35
|
tags: [core_1.ConfigTag.infrastructure, core_1.ConfigTag.transport, core_1.ConfigTag.graphql],
|
|
36
36
|
})
|
|
37
|
-
],
|
|
38
|
-
//# sourceMappingURL=
|
|
37
|
+
], GraphqlConfig);
|
|
38
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { ProtocolTracingHeadersExtractor } from '@rsdk/core';
|
|
3
|
+
import { TracingHeaders } from '@rsdk/core/dist/tracing/types';
|
|
4
|
+
export declare class GqlTracingExtractor implements ProtocolTracingHeadersExtractor {
|
|
5
|
+
extract(executionContext: ExecutionContext): TracingHeaders;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GqlTracingExtractor = void 0;
|
|
4
|
+
const types_1 = require("@rsdk/core/dist/tracing/types");
|
|
5
|
+
const http_server_1 = require("@rsdk/http.server");
|
|
6
|
+
class GqlTracingExtractor {
|
|
7
|
+
extract(executionContext) {
|
|
8
|
+
const req = executionContext.getArgs()[2]?.req; // аналог GqlExecutionContext.create(executionContext).getContext().req
|
|
9
|
+
/**
|
|
10
|
+
* При работе с сабскрипшен через веб сокет, заголовки передаются в опции подключения к сабскрипшен в переменную connectionParams
|
|
11
|
+
* и мы перегоняем эти данные в request заголовки
|
|
12
|
+
*/
|
|
13
|
+
const headers = {
|
|
14
|
+
...req?.headers,
|
|
15
|
+
...req?.connectionParams?.headers,
|
|
16
|
+
};
|
|
17
|
+
const tracingHeaders = new http_server_1.HttpHeaders(headers).getHeaders(req);
|
|
18
|
+
return new types_1.TracingHeaders({
|
|
19
|
+
...tracingHeaders,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.GqlTracingExtractor = GqlTracingExtractor;
|
|
24
|
+
//# sourceMappingURL=gql.tracing-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql.tracing-extractor.js","sourceRoot":"","sources":["../src/gql.tracing-extractor.ts"],"names":[],"mappings":";;;AAEA,yDAA+D;AAC/D,mDAAgD;AAEhD,MAAa,mBAAmB;IAC9B,OAAO,CAAC,gBAAkC;QACxC,MAAM,GAAG,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,uEAAuE;QAEvH;;;WAGG;QACH,MAAM,OAAO,GAAG;YACd,GAAG,GAAG,EAAE,OAAO;YACf,GAAG,GAAG,EAAE,gBAAgB,EAAE,OAAO;SAClC,CAAC;QAEF,MAAM,cAAc,GAAG,IAAI,yBAAW,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEhE,OAAO,IAAI,sBAAc,CAAC;YACxB,GAAG,cAAc;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,kDAmBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
2
|
import { ILogger } from '@rsdk/logging';
|
|
3
3
|
import type { Observable } from 'rxjs/internal/Observable';
|
|
4
|
-
import {
|
|
4
|
+
import { GraphqlConfig } from './config';
|
|
5
5
|
export declare class GraphqlLoggerInterceptor implements NestInterceptor {
|
|
6
6
|
private logger;
|
|
7
7
|
private graphQLConfig;
|
|
8
|
-
constructor(logger: ILogger, graphQLConfig:
|
|
8
|
+
constructor(logger: ILogger, graphQLConfig: GraphqlConfig);
|
|
9
9
|
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
|
|
10
10
|
}
|
|
@@ -19,7 +19,7 @@ const core_1 = require("@rsdk/core");
|
|
|
19
19
|
const throwError_1 = require("rxjs/internal/observable/throwError");
|
|
20
20
|
const catchError_1 = require("rxjs/internal/operators/catchError");
|
|
21
21
|
const tap_1 = require("rxjs/internal/operators/tap");
|
|
22
|
-
const
|
|
22
|
+
const config_1 = require("./config");
|
|
23
23
|
let GraphqlLoggerInterceptor = class GraphqlLoggerInterceptor {
|
|
24
24
|
logger;
|
|
25
25
|
graphQLConfig;
|
|
@@ -75,6 +75,6 @@ exports.GraphqlLoggerInterceptor = GraphqlLoggerInterceptor;
|
|
|
75
75
|
exports.GraphqlLoggerInterceptor = GraphqlLoggerInterceptor = __decorate([
|
|
76
76
|
(0, common_1.Injectable)(),
|
|
77
77
|
__param(0, (0, core_1.InjectLogger)(GraphqlLoggerInterceptor)),
|
|
78
|
-
__metadata("design:paramtypes", [Object,
|
|
78
|
+
__metadata("design:paramtypes", [Object, config_1.GraphqlConfig])
|
|
79
79
|
], GraphqlLoggerInterceptor);
|
|
80
80
|
//# sourceMappingURL=graphql-logger.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-logger.interceptor.js","sourceRoot":"","sources":["../src/graphql-logger.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2CAA4C;AAE5C,6CAAsD;AACtD,qCAA0C;AAG1C,oEAAiE;AACjE,mEAAgE;AAChE,qDAAkD;AAElD,
|
|
1
|
+
{"version":3,"file":"graphql-logger.interceptor.js","sourceRoot":"","sources":["../src/graphql-logger.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,2CAA4C;AAE5C,6CAAsD;AACtD,qCAA0C;AAG1C,oEAAiE;AACjE,mEAAgE;AAChE,qDAAkD;AAElD,qCAAyC;AAGlC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEe;IACxC;IAFV,YACkD,MAAe,EACvD,aAA4B;QADY,WAAM,GAAN,MAAM,CAAS;QACvD,kBAAa,GAAb,aAAa,CAAe;IACnC,CAAC;IAEJ,SAAS,CACP,OAAyB,EACzB,IAAsB;QAEtB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAkB,KAAK,SAAS,CAAC;QAClE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAC;QAE1E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,aAAa,GAAG;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE;YAC5C,OAAO,EAAE,aAAa;YACtB,SAAS,EAAE,SAAS;SACrB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,uBAAU,EAAC,CAAC,KAAK,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE;gBACtD,OAAO,EAAE,aAAa;gBACtB,SAAS;gBACT,OAAO;gBACP,QAAQ,EAAE,OAAO,GAAG,SAAS;gBAC7B,KAAK;aACN,CAAC,CAAC;YACH,OAAO,IAAA,uBAAU,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC,EACF,IAAA,SAAG,EAAC,CAAC,QAAQ,EAAE,EAAE;YACf,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;gBAC3C,OAAO,EAAE,aAAa;gBACtB,SAAS;gBACT,OAAO;gBACP,QAAQ,EAAE,OAAO,GAAG,SAAS;gBAC7B,QAAQ;aACT,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AA7DY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,mBAAY,EAAC,wBAAwB,CAAC,CAAA;6CAChB,sBAAa;GAH3B,wBAAwB,CA6DpC"}
|
package/dist/graphql.plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MiddlewareConsumer } from '@nestjs/common';
|
|
2
|
-
import type { IErrorsFormatter, IErrorsSender, NestModuleDefinitions, PlatformAppPlugin } from '@rsdk/core';
|
|
2
|
+
import type { IErrorsFormatter, IErrorsSender, NestModuleDefinitions, PlatformAppPlugin, ProtocolTracingHeadersExtractor } from '@rsdk/core';
|
|
3
3
|
export type Approach = 'schema-first' | 'code-first';
|
|
4
4
|
export interface GraphQLPluginOptions<T extends Approach> {
|
|
5
5
|
approach: T;
|
|
@@ -16,6 +16,10 @@ export interface GraphQLPluginCodeFirstOptions extends GraphQLPluginOptions<'cod
|
|
|
16
16
|
export declare const isCodeFirst: (options: GraphQLPluginOptions<Approach>) => options is GraphQLPluginCodeFirstOptions;
|
|
17
17
|
export declare class GraphQLPlugin implements PlatformAppPlugin {
|
|
18
18
|
private readonly options;
|
|
19
|
+
tracingHeadersExtractors(): {
|
|
20
|
+
protocol: string;
|
|
21
|
+
extractor: ProtocolTracingHeadersExtractor;
|
|
22
|
+
}[];
|
|
19
23
|
private readonly path;
|
|
20
24
|
constructor(options: GraphQLPluginCodeFirstOptions | GraphQLPluginSchemaFirstOptions);
|
|
21
25
|
forTransports(): Readonly<string[]>;
|
package/dist/graphql.plugin.js
CHANGED
|
@@ -6,8 +6,9 @@ const core_1 = require("@nestjs/core");
|
|
|
6
6
|
const graphql_1 = require("@nestjs/graphql");
|
|
7
7
|
const logging_1 = require("@rsdk/logging");
|
|
8
8
|
const apollo_logger_adapter_1 = require("./apollo-logger.adapter");
|
|
9
|
+
const config_1 = require("./config");
|
|
9
10
|
const error_handling_1 = require("./error-handling");
|
|
10
|
-
const
|
|
11
|
+
const gql_tracing_extractor_1 = require("./gql.tracing-extractor");
|
|
11
12
|
const graphql_logger_interceptor_1 = require("./graphql-logger.interceptor");
|
|
12
13
|
const onConnect = (connectionParams) => {
|
|
13
14
|
const out = connectionParams ?? {};
|
|
@@ -25,6 +26,14 @@ const isCodeFirst = (options) => options.approach === 'code-first';
|
|
|
25
26
|
exports.isCodeFirst = isCodeFirst;
|
|
26
27
|
class GraphQLPlugin {
|
|
27
28
|
options;
|
|
29
|
+
tracingHeadersExtractors() {
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
protocol: 'graphql',
|
|
33
|
+
extractor: new gql_tracing_extractor_1.GqlTracingExtractor(),
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
28
37
|
path;
|
|
29
38
|
constructor(options) {
|
|
30
39
|
this.options = options;
|
|
@@ -48,7 +57,7 @@ class GraphQLPlugin {
|
|
|
48
57
|
],
|
|
49
58
|
},
|
|
50
59
|
graphql_1.GraphQLModule.forRootAsync({
|
|
51
|
-
inject: [
|
|
60
|
+
inject: [config_1.GraphqlConfig],
|
|
52
61
|
driver: apollo_1.ApolloDriver,
|
|
53
62
|
useFactory: (config) => ({
|
|
54
63
|
path: this.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAE9C,uCAA+C;AAC/C,6CAAgD;
|
|
1
|
+
{"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAE9C,uCAA+C;AAC/C,6CAAgD;AAQhD,2CAA8C;AAE9C,mEAA8D;AAC9D,qCAAyC;AACzC,qDAA+E;AAC/E,mEAA8D;AAC9D,6EAAwE;AAExE,MAAM,SAAS,GAAG,CAAC,gBAAqB,EAAO,EAAE;IAC/C,MAAM,GAAG,GAAG,gBAAgB,IAAI,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;IAElC,4BAA4B;IAC5B,IAAI,gBAAgB,EAAE,aAAa,IAAI,gBAAgB,EAAE,aAAa,EAAE,CAAC;QACvE,OAAO,CAAC,aAAa;YACnB,gBAAgB,EAAE,aAAa,IAAI,gBAAgB,EAAE,aAAa,CAAC;IACvE,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;AACtC,CAAC,CAAC;AAmBK,MAAM,aAAa,GAAG,CAC3B,OAAuC,EACK,EAAE,CAC9C,OAAO,CAAC,QAAQ,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K,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;AApHD,sCAoHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/graphql",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0-next.1",
|
|
4
4
|
"description": "Plugin for graphql",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,14 +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.
|
|
23
|
-
"@rsdk/core": "^4.
|
|
24
|
-
"@rsdk/http.server
|
|
25
|
-
"@rsdk/
|
|
22
|
+
"@rsdk/common": "^4.3.0-next.1",
|
|
23
|
+
"@rsdk/core": "^4.3.0-next.1",
|
|
24
|
+
"@rsdk/http.server": "^4.3.0-next.1",
|
|
25
|
+
"@rsdk/http.server.express": "^4.3.0-next.1",
|
|
26
|
+
"@rsdk/logging": "^4.3.0-next.1",
|
|
26
27
|
"graphql": "^16.6.0",
|
|
27
28
|
"graphql-subscriptions": "^2.0.0",
|
|
28
|
-
"reflect-metadata": "^0.1.
|
|
29
|
+
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
|
29
30
|
"rxjs": "^7.8.1"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "da58041323f3145aa436e02774d36d44606c1217"
|
|
32
33
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
@ConfigSection({
|
|
10
10
|
tags: [ConfigTag.infrastructure, ConfigTag.transport, ConfigTag.graphql],
|
|
11
11
|
})
|
|
12
|
-
export class
|
|
12
|
+
export class GraphqlConfig extends Config {
|
|
13
13
|
@Property('GRAPHQL_ENABLE_PLAYGROUND', new BoolParser(), {
|
|
14
14
|
defaultValue: false,
|
|
15
15
|
description: 'Enables GraphQL playground and introspection',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { ProtocolTracingHeadersExtractor } from '@rsdk/core';
|
|
3
|
+
import { TracingHeaders } from '@rsdk/core/dist/tracing/types';
|
|
4
|
+
import { HttpHeaders } from '@rsdk/http.server';
|
|
5
|
+
|
|
6
|
+
export class GqlTracingExtractor implements ProtocolTracingHeadersExtractor {
|
|
7
|
+
extract(executionContext: ExecutionContext): TracingHeaders {
|
|
8
|
+
const req = executionContext.getArgs()[2]?.req; // аналог GqlExecutionContext.create(executionContext).getContext().req
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* При работе с сабскрипшен через веб сокет, заголовки передаются в опции подключения к сабскрипшен в переменную connectionParams
|
|
12
|
+
* и мы перегоняем эти данные в request заголовки
|
|
13
|
+
*/
|
|
14
|
+
const headers = {
|
|
15
|
+
...req?.headers,
|
|
16
|
+
...req?.connectionParams?.headers,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const tracingHeaders = new HttpHeaders(headers).getHeaders(req);
|
|
20
|
+
|
|
21
|
+
return new TracingHeaders({
|
|
22
|
+
...tracingHeaders,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -13,13 +13,13 @@ import { throwError } from 'rxjs/internal/observable/throwError';
|
|
|
13
13
|
import { catchError } from 'rxjs/internal/operators/catchError';
|
|
14
14
|
import { tap } from 'rxjs/internal/operators/tap';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { GraphqlConfig } from './config';
|
|
17
17
|
|
|
18
18
|
@Injectable()
|
|
19
19
|
export class GraphqlLoggerInterceptor implements NestInterceptor {
|
|
20
20
|
constructor(
|
|
21
21
|
@InjectLogger(GraphqlLoggerInterceptor) private logger: ILogger,
|
|
22
|
-
private graphQLConfig:
|
|
22
|
+
private graphQLConfig: GraphqlConfig,
|
|
23
23
|
) {}
|
|
24
24
|
|
|
25
25
|
intercept(
|
package/src/graphql.plugin.ts
CHANGED
|
@@ -8,12 +8,14 @@ import type {
|
|
|
8
8
|
IErrorsSender,
|
|
9
9
|
NestModuleDefinitions,
|
|
10
10
|
PlatformAppPlugin,
|
|
11
|
+
ProtocolTracingHeadersExtractor,
|
|
11
12
|
} from '@rsdk/core';
|
|
12
13
|
import { LoggerFactory } from '@rsdk/logging';
|
|
13
14
|
|
|
14
15
|
import { ApolloLoggerAdapter } from './apollo-logger.adapter';
|
|
16
|
+
import { GraphqlConfig } from './config';
|
|
15
17
|
import { GraphQLErrorsFormatter, GraphQLErrorsSender } from './error-handling';
|
|
16
|
-
import {
|
|
18
|
+
import { GqlTracingExtractor } from './gql.tracing-extractor';
|
|
17
19
|
import { GraphqlLoggerInterceptor } from './graphql-logger.interceptor';
|
|
18
20
|
|
|
19
21
|
const onConnect = (connectionParams: any): any => {
|
|
@@ -63,6 +65,18 @@ export const isCodeFirst = (
|
|
|
63
65
|
options.approach === 'code-first';
|
|
64
66
|
|
|
65
67
|
export class GraphQLPlugin implements PlatformAppPlugin {
|
|
68
|
+
tracingHeadersExtractors(): {
|
|
69
|
+
protocol: string;
|
|
70
|
+
extractor: ProtocolTracingHeadersExtractor;
|
|
71
|
+
}[] {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
protocol: 'graphql',
|
|
75
|
+
extractor: new GqlTracingExtractor(),
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
private readonly path: string;
|
|
67
81
|
|
|
68
82
|
constructor(
|
|
@@ -92,10 +106,10 @@ export class GraphQLPlugin implements PlatformAppPlugin {
|
|
|
92
106
|
],
|
|
93
107
|
},
|
|
94
108
|
GraphQLModule.forRootAsync<ApolloDriverConfig>({
|
|
95
|
-
inject: [
|
|
109
|
+
inject: [GraphqlConfig],
|
|
96
110
|
driver: ApolloDriver,
|
|
97
111
|
|
|
98
|
-
useFactory: (config:
|
|
112
|
+
useFactory: (config: GraphqlConfig) => ({
|
|
99
113
|
path: this.path,
|
|
100
114
|
...(isCodeFirst(this.options) && {
|
|
101
115
|
autoSchemaFile: this.options.autoSchemaFile ?? 'schema.graqhql',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.config.js","sourceRoot":"","sources":["../src/graphql.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"}
|