@rsdk/graphql 5.0.0-next.1 → 5.0.0-next.3
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 +14 -0
- package/dist/gql.headers.d.ts +7 -0
- package/dist/gql.headers.js +23 -0
- package/dist/gql.headers.js.map +1 -0
- package/dist/graphql.plugin.d.ts +4 -4
- package/dist/graphql.plugin.js +11 -9
- package/dist/graphql.plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/gql.headers.ts +27 -0
- package/src/graphql.plugin.ts +16 -14
- package/dist/gql.tracing-extractor.d.ts +0 -6
- package/dist/gql.tracing-extractor.js +0 -24
- package/dist/gql.tracing-extractor.js.map +0 -1
- package/src/gql.tracing-extractor.ts +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
## [5.0.0-next.3](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.2...v5.0.0-next.3) (2024-07-11)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* generalize tracing headers (#247)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* generalize tracing headers ([#247](https://github.com/R-Vision/rsdk/issues/247)) ([cee2ea6](https://github.com/R-Vision/rsdk/commit/cee2ea65c964705faf133397e285c051672c7512)), closes [#2](https://github.com/R-Vision/rsdk/issues/2) [#3](https://github.com/R-Vision/rsdk/issues/3) [#4](https://github.com/R-Vision/rsdk/issues/4) [#5](https://github.com/R-Vision/rsdk/issues/5)
|
|
15
|
+
|
|
16
|
+
## [5.0.0-next.2](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.1...v5.0.0-next.2) (2024-07-10)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @rsdk/graphql
|
|
19
|
+
|
|
6
20
|
## [5.0.0-next.1](https://github.com/R-Vision/rsdk/compare/v5.0.0-next.0...v5.0.0-next.1) (2024-07-10)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @rsdk/graphql
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { GenericHeaders } from '@rsdk/core';
|
|
3
|
+
export declare class GqlHeaders implements GenericHeaders {
|
|
4
|
+
private normalizedHeaders;
|
|
5
|
+
constructor(ctx: ExecutionContext);
|
|
6
|
+
get(key: string): string | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GqlHeaders = void 0;
|
|
4
|
+
class GqlHeaders {
|
|
5
|
+
normalizedHeaders;
|
|
6
|
+
constructor(ctx) {
|
|
7
|
+
const req = ctx.getArgs()[2]?.req;
|
|
8
|
+
/**
|
|
9
|
+
* При работе с подписки через веб сокет, заголовки передаются через connectionParams
|
|
10
|
+
* и мы перегоняем эти данные в request заголовки
|
|
11
|
+
*/
|
|
12
|
+
const headers = {
|
|
13
|
+
...req?.headers,
|
|
14
|
+
...req?.connectionParams?.headers,
|
|
15
|
+
};
|
|
16
|
+
this.normalizedHeaders = Object.fromEntries(Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v]));
|
|
17
|
+
}
|
|
18
|
+
get(key) {
|
|
19
|
+
return this.normalizedHeaders[key.toLowerCase()];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.GqlHeaders = GqlHeaders;
|
|
23
|
+
//# sourceMappingURL=gql.headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gql.headers.js","sourceRoot":"","sources":["../src/gql.headers.ts"],"names":[],"mappings":";;;AAGA,MAAa,UAAU;IACb,iBAAiB,CAAyB;IAElD,YAAY,GAAqB;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAElC;;;WAGG;QACH,MAAM,OAAO,GAA2B;YACtC,GAAG,GAAG,EAAE,OAAO;YACf,GAAG,GAAG,EAAE,gBAAgB,EAAE,OAAO;SAClC,CAAC;QAEF,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,WAAW,CACzC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAC9D,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAvBD,gCAuBC"}
|
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,
|
|
2
|
+
import type { IErrorsFormatter, IErrorsSender, NestModuleDefinitions, PlatformAppPlugin, WithGenericHeaders } 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,12 +16,12 @@ 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
|
+
private readonly path;
|
|
20
|
+
constructor(options: GraphQLPluginCodeFirstOptions | GraphQLPluginSchemaFirstOptions);
|
|
19
21
|
tracingHeadersExtractors(): {
|
|
20
22
|
protocol: string;
|
|
21
|
-
extractor:
|
|
23
|
+
extractor: WithGenericHeaders;
|
|
22
24
|
}[];
|
|
23
|
-
private readonly path;
|
|
24
|
-
constructor(options: GraphQLPluginCodeFirstOptions | GraphQLPluginSchemaFirstOptions);
|
|
25
25
|
forTransports(): Readonly<string[]>;
|
|
26
26
|
modules(): NestModuleDefinitions;
|
|
27
27
|
configureMiddleware(consumer: MiddlewareConsumer): void;
|
package/dist/graphql.plugin.js
CHANGED
|
@@ -10,7 +10,7 @@ const logging_1 = require("@rsdk/logging");
|
|
|
10
10
|
const apollo_logger_adapter_1 = require("./apollo-logger.adapter");
|
|
11
11
|
const config_1 = require("./config");
|
|
12
12
|
const error_handling_1 = require("./error-handling");
|
|
13
|
-
const
|
|
13
|
+
const gql_headers_1 = require("./gql.headers");
|
|
14
14
|
const graphql_logger_interceptor_1 = require("./graphql-logger.interceptor");
|
|
15
15
|
const onConnect = (connectionParams) => {
|
|
16
16
|
const out = connectionParams ?? {};
|
|
@@ -28,14 +28,6 @@ const isCodeFirst = (options) => options.approach === 'code-first';
|
|
|
28
28
|
exports.isCodeFirst = isCodeFirst;
|
|
29
29
|
class GraphQLPlugin {
|
|
30
30
|
options;
|
|
31
|
-
tracingHeadersExtractors() {
|
|
32
|
-
return [
|
|
33
|
-
{
|
|
34
|
-
protocol: 'graphql',
|
|
35
|
-
extractor: new gql_tracing_extractor_1.GqlTracingExtractor(),
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
31
|
path;
|
|
40
32
|
constructor(options) {
|
|
41
33
|
this.options = options;
|
|
@@ -44,6 +36,16 @@ class GraphQLPlugin {
|
|
|
44
36
|
this.path = '/' + this.path;
|
|
45
37
|
}
|
|
46
38
|
}
|
|
39
|
+
tracingHeadersExtractors() {
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
protocol: 'graphql',
|
|
43
|
+
extractor: {
|
|
44
|
+
extractHeaders: (ctx) => new gql_headers_1.GqlHeaders(ctx),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
47
49
|
forTransports() {
|
|
48
50
|
return ['http'];
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;AAAA,mEAAkF;AAClF,uEAAsG;AAEtG,2CAA8C;AAE9C,uCAA+C;AAC/C,6CAAgD;AAQhD,2CAA8C;AAE9C,mEAA8D;AAC9D,qCAAqD;AACrD,qDAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"graphql.plugin.js","sourceRoot":"","sources":["../src/graphql.plugin.ts"],"names":[],"mappings":";;;AAAA,mEAAkF;AAClF,uEAAsG;AAEtG,2CAA8C;AAE9C,uCAA+C;AAC/C,6CAAgD;AAQhD,2CAA8C;AAE9C,mEAA8D;AAC9D,qCAAqD;AACrD,qDAA+E;AAC/E,+CAA2C;AAC3C,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,KAAK,cAAc,CAAC;AAHzB,QAAA,aAAa,iBAGY;AAS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C;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;AA5ID,sCA4IC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/graphql",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.3",
|
|
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.8.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "c75ce1d8983ba69a6f855ba19536d28be0a9c519"
|
|
33
33
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import type { GenericHeaders } from '@rsdk/core';
|
|
3
|
+
|
|
4
|
+
export class GqlHeaders implements GenericHeaders {
|
|
5
|
+
private normalizedHeaders: Record<string, string>;
|
|
6
|
+
|
|
7
|
+
constructor(ctx: ExecutionContext) {
|
|
8
|
+
const req = ctx.getArgs()[2]?.req;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* При работе с подписки через веб сокет, заголовки передаются через connectionParams
|
|
12
|
+
* и мы перегоняем эти данные в request заголовки
|
|
13
|
+
*/
|
|
14
|
+
const headers: Record<string, string> = {
|
|
15
|
+
...req?.headers,
|
|
16
|
+
...req?.connectionParams?.headers,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.normalizedHeaders = Object.fromEntries(
|
|
20
|
+
Object.entries(headers).map(([k, v]) => [k.toLowerCase(), v]),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get(key: string): string | undefined {
|
|
25
|
+
return this.normalizedHeaders[key.toLowerCase()];
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/graphql.plugin.ts
CHANGED
|
@@ -10,14 +10,14 @@ import type {
|
|
|
10
10
|
IErrorsSender,
|
|
11
11
|
NestModuleDefinitions,
|
|
12
12
|
PlatformAppPlugin,
|
|
13
|
-
|
|
13
|
+
WithGenericHeaders,
|
|
14
14
|
} from '@rsdk/core';
|
|
15
15
|
import { LoggerFactory } from '@rsdk/logging';
|
|
16
16
|
|
|
17
17
|
import { ApolloLoggerAdapter } from './apollo-logger.adapter';
|
|
18
18
|
import { GraphqlConfig, Playground } from './config';
|
|
19
19
|
import { GraphQLErrorsFormatter, GraphQLErrorsSender } from './error-handling';
|
|
20
|
-
import {
|
|
20
|
+
import { GqlHeaders } from './gql.headers';
|
|
21
21
|
import { GraphqlLoggerInterceptor } from './graphql-logger.interceptor';
|
|
22
22
|
|
|
23
23
|
const onConnect = (connectionParams: any): any => {
|
|
@@ -67,18 +67,6 @@ export const isCodeFirst = (
|
|
|
67
67
|
options.approach === 'code-first';
|
|
68
68
|
|
|
69
69
|
export class GraphQLPlugin implements PlatformAppPlugin {
|
|
70
|
-
tracingHeadersExtractors(): {
|
|
71
|
-
protocol: string;
|
|
72
|
-
extractor: ProtocolTracingHeadersExtractor;
|
|
73
|
-
}[] {
|
|
74
|
-
return [
|
|
75
|
-
{
|
|
76
|
-
protocol: 'graphql',
|
|
77
|
-
extractor: new GqlTracingExtractor(),
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
70
|
private readonly path: string;
|
|
83
71
|
|
|
84
72
|
constructor(
|
|
@@ -92,6 +80,20 @@ export class GraphQLPlugin implements PlatformAppPlugin {
|
|
|
92
80
|
}
|
|
93
81
|
}
|
|
94
82
|
|
|
83
|
+
tracingHeadersExtractors(): {
|
|
84
|
+
protocol: string;
|
|
85
|
+
extractor: WithGenericHeaders;
|
|
86
|
+
}[] {
|
|
87
|
+
return [
|
|
88
|
+
{
|
|
89
|
+
protocol: 'graphql',
|
|
90
|
+
extractor: {
|
|
91
|
+
extractHeaders: (ctx) => new GqlHeaders(ctx),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
|
|
95
97
|
forTransports(): Readonly<string[]> {
|
|
96
98
|
return ['http'];
|
|
97
99
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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();
|
|
18
|
-
return new types_1.TracingHeaders({
|
|
19
|
-
...tracingHeaders,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.GqlTracingExtractor = GqlTracingExtractor;
|
|
24
|
-
//# sourceMappingURL=gql.tracing-extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,CAAC;QAE7D,OAAO,IAAI,sBAAc,CAAC;YACxB,GAAG,cAAc;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,kDAmBC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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();
|
|
20
|
-
|
|
21
|
-
return new TracingHeaders({
|
|
22
|
-
...tracingHeaders,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|