@nest-boot/graphql 5.13.2 → 5.14.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.
@@ -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"}
@@ -24,33 +24,16 @@ let LoggingPlugin = class LoggingPlugin {
24
24
  async requestDidStart() {
25
25
  const logger = this.logger;
26
26
  if (typeof logger !== "undefined") {
27
- const startTime = Date.now();
28
27
  return {
29
28
  didResolveOperation: async (ctx) => {
30
29
  logger.assign({
31
30
  operation: {
32
31
  id: ctx.queryHash,
33
32
  name: ctx.operationName,
34
- type: ctx.operation?.operation?.toUpperCase(),
33
+ type: ctx.operation?.operation,
35
34
  },
36
35
  });
37
36
  },
38
- willSendResponse: async ({ response, errors }) => {
39
- const responseTime = Date.now() - startTime;
40
- if (response.body.kind === "incremental") {
41
- return;
42
- }
43
- if (typeof errors !== "undefined" && errors.length > 0) {
44
- logger.error("graphql request errored", {
45
- responseTime,
46
- });
47
- }
48
- else {
49
- logger.log("graphql request completed", {
50
- responseTime,
51
- });
52
- }
53
- },
54
37
  };
55
38
  }
56
39
  return {};
@@ -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;AAGnC,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,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE7B,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;gBACL,CAAC;gBACD,gBAAgB,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;oBAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;oBAE5C,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE;wBAC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