@nest-boot/graphql 5.13.1 → 5.13.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.
@@ -1,6 +1,8 @@
1
- import { type ArgumentsHost, type ExceptionFilter } from "@nestjs/common";
1
+ import { type ArgumentsHost } from "@nestjs/common";
2
+ import { BaseExceptionFilter } from "@nestjs/core";
3
+ import { GqlExceptionFilter } from "@nestjs/graphql";
2
4
  import { GraphQLError } from "graphql";
3
- export declare class GraphQLExceptionFilter implements ExceptionFilter {
4
- catch(error: Error, host: ArgumentsHost): void;
5
+ export declare class GraphQLExceptionFilter extends BaseExceptionFilter implements GqlExceptionFilter {
6
+ catch(error: Error, host: ArgumentsHost): GraphQLError | undefined;
5
7
  transform(error: Error): GraphQLError;
6
8
  }
@@ -8,12 +8,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.GraphQLExceptionFilter = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
+ const core_1 = require("@nestjs/core");
11
12
  const graphql_1 = require("graphql");
12
- let GraphQLExceptionFilter = class GraphQLExceptionFilter {
13
+ let GraphQLExceptionFilter = class GraphQLExceptionFilter extends core_1.BaseExceptionFilter {
13
14
  catch(error, host) {
14
15
  if (host.getType() === "graphql") {
15
- throw this.transform(error);
16
+ return this.transform(error);
16
17
  }
18
+ super.catch(error, host);
17
19
  }
18
20
  transform(error) {
19
21
  // 如果是 GraphQL 错误,直接返回
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.exception-filter.js","sourceRoot":"","sources":["../src/graphql.exception-filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAOwB;AACxB,qCAAuC;AAGhC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,KAAK,CAAC,KAAY,EAAE,IAAmB;QACrC,IAAI,IAAI,CAAC,OAAO,EAA2B,KAAK,SAAS,EAAE;YACzD,MAAM,IAAI,C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AC,KAAK,CAAC,CAAC;SAC9B;QAED,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,KAAY;QACpB,sBAAsB;QACtB,IAAI,KAAK,YAAY,sBAAY,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;QAED,4BAA4B;QAC5B,IAAI,KAAK,YAAY,sBAAa,EAAE;YAClC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAQ,KAAK,CAAC,WAAW,EAAE,CAAC;YAC1C,MAAM,OAAO,GACX,OAAO,QAAQ,KAAK,QAAQ;gBAC1B,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,IAAI,uBAAuB,CAAC;YAErE,OAAO,IAAI,sBAAY,CAAC,OAAO,EAAE;gBAC/B,UAAU,EAAE;oBACV,IAAI,EAAE,mBAAU,CAAC,MAAM,CAAC;oBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB;aACF,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,sBAAY,CAAC,KAAK,CAAC,OAAO,EAAE;YACrC,UAAU,EAAE;gBACV,IAAI,EAAE,uBAAuB;gBAC7B,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA1CY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,cAAK,GAAE;GACK,sBAAsB,CA0ClC"}
@@ -17,9 +17,6 @@ exports.LoggingPlugin = void 0;
17
17
  const logger_1 = require("@nest-boot/logger");
18
18
  const apollo_1 = require("@nestjs/apollo");
19
19
  const common_1 = require("@nestjs/common");
20
- function durationHrTimeToNanos(hrtime) {
21
- return hrtime[0] * 1e9 + hrtime[1];
22
- }
23
20
  let LoggingPlugin = class LoggingPlugin {
24
21
  constructor(logger) {
25
22
  this.logger = logger;
@@ -27,7 +24,7 @@ let LoggingPlugin = class LoggingPlugin {
27
24
  async requestDidStart() {
28
25
  const logger = this.logger;
29
26
  if (typeof logger !== "undefined") {
30
- const startHrTime = process.hrtime();
27
+ const startTime = Date.now();
31
28
  return {
32
29
  didResolveOperation: async (ctx) => {
33
30
  logger.assign({
@@ -39,18 +36,18 @@ let LoggingPlugin = class LoggingPlugin {
39
36
  });
40
37
  },
41
38
  willSendResponse: async ({ response, errors }) => {
42
- const durationNs = durationHrTimeToNanos(process.hrtime(startHrTime));
39
+ const responseTime = Date.now() - startTime;
43
40
  if (response.body.kind === "incremental") {
44
41
  return;
45
42
  }
46
43
  if (typeof errors !== "undefined" && errors.length > 0) {
47
44
  logger.error("graphql request errored", {
48
- durationNs,
45
+ responseTime,
49
46
  });
50
47
  }
51
48
  else {
52
49
  logger.log("graphql request completed", {
53
- durationNs,
50
+ responseTime,
54
51
  });
55
52
  }
56
53
  },
@@ -1 +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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