@nest-boot/graphql 5.12.0 → 5.13.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/graphql.module.js
CHANGED
|
@@ -22,6 +22,7 @@ const graphiql_middleware_1 = require("./graphiql.middleware");
|
|
|
22
22
|
const graphql_exception_filter_1 = require("./graphql.exception-filter");
|
|
23
23
|
const graphql_module_definition_1 = require("./graphql.module-definition");
|
|
24
24
|
const plugins_1 = require("./plugins");
|
|
25
|
+
const logging_plugin_1 = require("./plugins/logging.plugin");
|
|
25
26
|
let GraphQLModule = class GraphQLModule extends graphql_module_definition_1.ConfigurableModuleClass {
|
|
26
27
|
static forRoot(options) {
|
|
27
28
|
return this.withBaseGraphQLModule(super.forRoot(options));
|
|
@@ -73,6 +74,7 @@ exports.GraphQLModule = GraphQLModule = __decorate([
|
|
|
73
74
|
providers: [
|
|
74
75
|
connection_service_1.ConnectionService,
|
|
75
76
|
plugins_1.ComplexityPlugin,
|
|
77
|
+
logging_plugin_1.LoggingPlugin,
|
|
76
78
|
{
|
|
77
79
|
provide: core_1.APP_FILTER,
|
|
78
80
|
useClass: graphql_exception_filter_1.GraphQLExceptionFilter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.module.js","sourceRoot":"","sources":["../src/graphql.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8C;AAC9C,2CAQwB;AACxB,uCAA0C;AAC1C,6CAAqE;AAErE,6DAAyD;AACzD,+DAA2D;AAC3D,yEAAoE;AACpE,2EAKqC;AAErC,uCAA6C;
|
|
1
|
+
{"version":3,"file":"graphql.module.js","sourceRoot":"","sources":["../src/graphql.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8C;AAC9C,2CAQwB;AACxB,uCAA0C;AAC1C,6CAAqE;AAErE,6DAAyD;AACzD,+DAA2D;AAC3D,yEAAoE;AACpE,2EAKqC;AAErC,uCAA6C;A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AAG;gBACzB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,UAAU;aACtC,CAAC,CAAC;SACJ;IACH,CAAC;CACF,CAAA;AAxDY,sCAAa;wBAAb,aAAa;IAbzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,sCAAiB;YACjB,0BAAgB;YAChB,8BAAa;YACb;gBACE,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,iDAAsB;aACjC;SACF;QACD,OAAO,EAAE,CAAC,gDAAoB,EAAE,sCAAiB,CAAC;KACnD,CAAC;IA2CG,WAAA,IAAA,eAAM,EAAC,gDAAoB,CAAC,CAAA;;GA1CpB,aAAa,CAwDzB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ApolloServerPlugin, type BaseContext, type GraphQLRequestListener } from "@apollo/server";
|
|
2
|
+
import { Logger } from "@nest-boot/logger";
|
|
3
|
+
export declare class LoggingPlugin implements ApolloServerPlugin {
|
|
4
|
+
private readonly logger?;
|
|
5
|
+
constructor(logger?: Logger | undefined);
|
|
6
|
+
requestDidStart(): Promise<GraphQLRequestListener<BaseContext>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
3
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
};
|
|
9
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
+
};
|
|
12
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
13
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.LoggingPlugin = void 0;
|
|
17
|
+
const logger_1 = require("@nest-boot/logger");
|
|
18
|
+
const apollo_1 = require("@nestjs/apollo");
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
function durationHrTimeToNanos(hrtime) {
|
|
21
|
+
return hrtime[0] * 1e9 + hrtime[1];
|
|
22
|
+
}
|
|
23
|
+
let LoggingPlugin = class LoggingPlugin {
|
|
24
|
+
constructor(logger) {
|
|
25
|
+
this.logger = logger;
|
|
26
|
+
}
|
|
27
|
+
async requestDidStart() {
|
|
28
|
+
const logger = this.logger;
|
|
29
|
+
if (typeof logger !== "undefined") {
|
|
30
|
+
const startHrTime = process.hrtime();
|
|
31
|
+
return {
|
|
32
|
+
didResolveOperation: async (ctx) => {
|
|
33
|
+
logger.assign({
|
|
34
|
+
operation: {
|
|
35
|
+
id: ctx.queryHash,
|
|
36
|
+
name: ctx.operationName,
|
|
37
|
+
type: ctx.operation?.operation?.toUpperCase(),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
willSendResponse: async ({ response, errors }) => {
|
|
42
|
+
const durationNs = durationHrTimeToNanos(process.hrtime(startHrTime));
|
|
43
|
+
if (response.body.kind === "incremental") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (typeof errors !== "undefined" && errors.length > 0) {
|
|
47
|
+
logger.error("graphql request errored", {
|
|
48
|
+
durationNs,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.log("graphql request completed", {
|
|
53
|
+
durationNs,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.LoggingPlugin = LoggingPlugin;
|
|
63
|
+
exports.LoggingPlugin = LoggingPlugin = __decorate([
|
|
64
|
+
(0, apollo_1.Plugin)(),
|
|
65
|
+
__param(0, (0, common_1.Optional)()),
|
|
66
|
+
__metadata("design:paramtypes", [logger_1.Logger])
|
|
67
|
+
], LoggingPlugin);
|
|
68
|
+
//# sourceMappingURL=logging.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.plugin.js","sourceRoot":"","sources":["../../src/plugins/logging.plugin.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;AAOrD,8CAA2C;AAC3C,2CAAwC;AACxC,2CAA0C;AAE1C,SAAS,qBAAqB,CAAC,MAAwB;IACrD,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAEmB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAC/B,CAAC;IAEJ,KAAK,CAAC,eAAe;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAErC,OAAO;gBACL,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;oBACjC,MAAM,CAAC,MAAM,CAAC;wBACZ,SAAS,EAAE;4BACT,EAAE,EAAE,GAAG,CAAC,SAAS;4BACjB,IAAI,EAAE,GAAG,CAAC,aAAa;4BACvB,IAAI,EAAE,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE;yBAC9C;qBACF,CAAC,CAAC;gBAC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