@nest-boot/graphql 5.9.3 → 5.10.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.
@@ -40,7 +40,7 @@ class ConnectionBuilder {
40
40
  let Connection = class Connection {
41
41
  };
42
42
  __decorate([
43
- (0, graphql_1.Field)(() => [Edge]),
43
+ (0, graphql_1.Field)(() => [Edge], { complexity: 0 }),
44
44
  __metadata("design:type", Array)
45
45
  ], Connection.prototype, "edges", void 0);
46
46
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"connection.builder.js","sourceRoot":"","sources":["../src/connection.builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6CAOyB;AACzB,oDAAuB;AAEvB,iCAAkC;AAClC,mCAAyC;AAuBzC,MAAa,iBAAiB;IAG5B,YACmB,WAAoB,EACpB,OAAoC;QADpC,gBAAW,GAAX,WAAW,CAAS;QACpB,YAAO,GAAP,OAAO,CAA6B;QAErD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC;IACrC,CAAC;IAED,KAAK;QAEH,IAAM,IAAI,GAAV,MAAM,IAAI;SAMT,CAAA;QAJC;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;0CACrB;QAGT;YADC,IAAA,eAAK,EAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;;4CACT;QALZ,IAAI;YADT,IAAA,oBAAU,EAAC,GAAG,IAAI,CAAC,UAAU,MAAM,CAAC;WAC/B,IAAI,CAMT;QAGD,IAAM,UAAU,GAAhB,MAAM,UAAU;SASf,CAAA;QAPC;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;;iDACL;QAGf;YADC,IAAA,eAAK,EAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;sCACd,eAAQ;oDAAC;QAGpB;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,aA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ADV,IAAA,mBAAS,EAAC,GAAG,IAAI,CAAC,UAAU,OAAO,CAAC;WAC/B,KAAK,CAMV;QAGD,IAAM,cAAc,GAApB,MAAM,cAAc;SAkBnB,CAAA;QAhBC;YADC,IAAA,eAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACX;QAGf;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,aAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACtB;QAGf;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,aAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACvB;QAGd;YADC,IAAA,eAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACX;QAGf;YADC,IAAA,eAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACV;QAGhB;YADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC7B,KAAK;uDAAC;QAjBZ,cAAc;YADnB,IAAA,kBAAQ,GAAE;WACL,cAAc,CAkBnB;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,IAAI;YACJ,KAAK;YACL,UAAU;SACX,CAAC;IACJ,CAAC;CACF;AAxFD,8CAwFC"}
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export * from "./connection.builder";
3
3
  export * from "./connection.service";
4
4
  export * from "./decorators";
5
5
  export * from "./dtos";
6
- export * from "./entity.data-loader";
7
6
  export * from "./enums";
8
7
  export * from "./graphql.exception-filter";
9
8
  export * from "./graphql.module";
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ __exportStar(require("./connection.builder"), exports);
20
20
  __exportStar(require("./connection.service"), exports);
21
21
  __exportStar(require("./decorators"), exports);
22
22
  __exportStar(require("./dtos"), exports);
23
- __exportStar(require("./entity.data-loader"), exports);
24
23
  __exportStar(require("./enums"), exports);
25
24
  __exportStar(require("./graphql.exception-filter"), exports);
26
25
  __exportStar(require("./graphql.module"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,uDAAqC;AACrC,uDAAqC;AACrC,+CAA6B;AAC7B,yCAAuB;AACvB,uDAAqC;AACrC,0CAAwB;AACxB,6DAA2C;AAC3C,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AACf,2CAayB;AAZvB,+FAAA,IAAI,OAAA;AACJ,0GAAA,eAAe,OAAA;AACf,gGAAA,KAAK,OAAA;AACL,4GAAA,iBAAiB,OAAA;AACjB,6FAAA,EAAE,OAAA;AACF,oGAAA,SAAS,OAAA;AACT,mGAAA,QAAQ,OAAA;AACR,qGAAA,UAAU,OAAA;AACV,gGAAA,KAAK,OAAA;AACL,2GAAA,gBAAgB,OAAA;AAChB,uGAAA,YAAY,OAAA;AACZ,mGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,uDAAqC;AACrC,uDAAqC;AACrC,+CAA6B;AAC7B,yCAAuB;AACvB,0CAAwB;AACxB,6DAA2C;AAC3C,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AACf,2CAayB;AAZvB,+FAAA,IAAI,OAAA;AACJ,0GAAA,eAAe,OAAA;AACf,gGAAA,KAAK,OAAA;AACL,4GAAA,iBAAiB,OAAA;AACjB,6FAAA,EAAE,OAAA;AACF,oGAAA,SAAS,OAAA;AACT,mGAAA,QAAQ,OAAA;AACR,qGAAA,UAAU,OAAA;AACV,gGAAA,KAAK,OAAA;AACL,2GAAA,gBAAgB,OAAA;AAChB,uGAAA,YAAY,OAAA;AACZ,mGAAA,QAAQ,OAAA"}
@@ -0,0 +1,10 @@
1
+ export interface CostThrottleStatus {
2
+ maximumAvailable: number;
3
+ currentlyAvailable: number;
4
+ restoreRate: number;
5
+ }
6
+ export interface CostResponse {
7
+ requestedQueryCost: number;
8
+ actualQueryCost: number;
9
+ throttleStatus?: CostThrottleStatus;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cost-response.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost-response.interface.js","sourceRoot":"","sources":["../../src/interfaces/cost-response.interface.ts"],"names":[],"mappings":""}
@@ -1,24 +1,25 @@
1
- import { BaseContext, GraphQLRequestContextDidResolveOperation } from "@apollo/server";
1
+ import { BaseContext, GraphQLRequestContext } from "@apollo/server";
2
2
  import { ApolloServerPluginLandingPageGraphQLPlaygroundOptions } from "@apollo/server-plugin-landing-page-graphql-playground";
3
3
  import { type ApolloDriverConfig } from "@nestjs/apollo";
4
4
  import { type GraphQLWsSubscriptionsConfig } from "@nestjs/graphql";
5
+ import { RedisOptions } from "ioredis";
5
6
  export interface GraphQLModuleComplexityRateLimitOptions {
7
+ connection?: RedisOptions;
6
8
  keyPrefix?: string;
7
9
  restoreRate?: number;
8
10
  maximumAvailable?: number;
9
- getId?: (args: GraphQLRequestContextDidResolveOperation<BaseContext>) => string;
11
+ getId?: (args: GraphQLRequestContext<BaseContext>) => string;
10
12
  }
11
13
  export interface GraphQLModuleComplexityOptions {
12
- logging?: boolean;
13
14
  maxComplexity?: number;
14
15
  defaultComplexity?: number;
15
- rateLimit?: GraphQLModuleComplexityRateLimitOptions | boolean;
16
+ rateLimit?: GraphQLModuleComplexityRateLimitOptions;
16
17
  }
17
18
  export interface GraphQLModuleOptions extends Omit<ApolloDriverConfig, "playground" | "subscriptions"> {
18
19
  /**
19
20
  * @deprecated GraphQL Playground 项目已停止使用,推荐使用 ApolloServerPluginLandingPageLocalDefault 插件来替代。
20
21
  */
21
22
  playground?: boolean | ApolloServerPluginLandingPageGraphQLPlaygroundOptions;
22
- subscriptions?: GraphQLWsSubscriptionsConfig | boolean;
23
- complexity?: GraphQLModuleComplexityOptions | boolean;
23
+ subscriptions?: GraphQLWsSubscriptionsConfig;
24
+ complexity?: GraphQLModuleComplexityOptions;
24
25
  }
@@ -1,5 +1,6 @@
1
1
  export * from "./connection.interface";
2
2
  export * from "./connection-args.interface";
3
+ export * from "./cost-response.interface";
3
4
  export * from "./edge.interface";
4
5
  export * from "./graphql-module-options.interface";
5
6
  export * from "./order.interface";
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./connection.interface"), exports);
18
18
  __exportStar(require("./connection-args.interface"), exports);
19
+ __exportStar(require("./cost-response.interface"), exports);
19
20
  __exportStar(require("./edge.interface"), exports);
20
21
  __exportStar(require("./graphql-module-options.interface"), exports);
21
22
  __exportStar(require("./order.interface"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,8DAA4C;AAC5C,mDAAiC;AACjC,qEAAmD;AACnD,oDAAkC;AAClC,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,8DAA4C;AAC5C,4DAA0C;AAC1C,mDAAiC;AACjC,qEAAmD;AACnD,oDAAkC;AAClC,qDAAmC"}
@@ -1,20 +1,19 @@
1
- import { type ApolloServerPlugin, type BaseContext, type GraphQLRequestListener } from "@apollo/server";
2
- import { Redis } from "@nest-boot/redis";
1
+ import { type ApolloServerPlugin, type BaseContext, GraphQLRequestContext, type GraphQLRequestListener } from "@apollo/server";
3
2
  import { GraphQLSchemaHost } from "@nestjs/graphql";
4
3
  import { GraphQLModuleOptions } from "../interfaces";
5
4
  export declare class ComplexityPlugin implements ApolloServerPlugin {
6
5
  private readonly options;
7
6
  private readonly gqlSchemaHost;
8
- private readonly redis;
9
- private readonly logger;
10
- private readonly logging;
7
+ private readonly complexityEstimators;
11
8
  private readonly maxComplexity;
12
9
  private readonly defaultComplexity;
13
- private readonly rateLimitEnable;
10
+ private readonly rateLimitRedis?;
14
11
  private readonly rateLimitKeyPrefix;
15
12
  private readonly rateLimitRestoreRate;
16
13
  private readonly rateLimitMaximumAvailable;
17
14
  private readonly rateLimitGetId;
18
- constructor(options: GraphQLModuleOptions, gqlSchemaHost: GraphQLSchemaHost, redis: Redis);
15
+ constructor(options: GraphQLModuleOptions, gqlSchemaHost: GraphQLSchemaHost);
16
+ addPoint(args: GraphQLRequestContext<BaseContext>, point: number): Promise<[boolean, number]>;
17
+ subPoint(args: GraphQLRequestContext<BaseContext>, point: number): Promise<[boolean, number]>;
19
18
  requestDidStart(): Promise<GraphQLRequestListener<BaseContext>>;
20
19
  }
@@ -12,15 +12,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
12
12
  var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  return function (target, key) { decorator(target, key, paramIndex); }
14
14
  };
15
- var ComplexityPlugin_1;
16
15
  Object.defineProperty(exports, "__esModule", { value: true });
17
16
  exports.ComplexityPlugin = void 0;
18
- const redis_1 = require("@nest-boot/redis");
19
17
  const apollo_1 = require("@nestjs/apollo");
20
18
  const common_1 = require("@nestjs/common");
21
19
  const graphql_1 = require("@nestjs/graphql");
22
20
  const graphql_2 = require("graphql");
23
21
  const graphql_query_complexity_1 = require("graphql-query-complexity");
22
+ const ioredis_1 = require("ioredis");
24
23
  const graphql_module_definition_1 = require("../graphql.module-definition");
25
24
  // https://shopify.engineering/rate-limiting-graphql-apis-calculating-query-complexity
26
25
  function shopifyEstimator(args, type) {
@@ -29,17 +28,15 @@ function shopifyEstimator(args, type) {
29
28
  return shopifyEstimator(args, type.ofType);
30
29
  }
31
30
  // GraphQL 的 Connection 表示的是一对多的关系,Connection 的消耗是两点加上要返回的对象数量。
32
- if (type instanceof graphql_2.GraphQLObjectType &&
33
- type.name.endsWith("Connection") &&
34
- typeof (args.args.first ?? args.args.last) === "number") {
35
- return 2 + args.childComplexity * (args.args.first ?? args.args.last);
31
+ if (type instanceof graphql_2.GraphQLObjectType && type.name.endsWith("Connection")) {
32
+ return 2 + args.childComplexity * (args.args.first ?? args.args.last ?? 0);
36
33
  }
37
34
  // Object 是查询的基本单位,一般代码一个单次的 server 端操作,可以是一次数据库查询,也可以一次内部服务的访问。
38
35
  // Interface 和 Union 和 Object 类似,只不过是能返回不同类型的 object,所以算一点。
39
36
  if (type instanceof graphql_2.GraphQLObjectType ||
40
37
  type instanceof graphql_2.GraphQLInterfaceType ||
41
38
  type instanceof graphql_2.GraphQLUnionType) {
42
- return 1;
39
+ return 1 + args.childComplexity;
43
40
  }
44
41
  // Scalar 和 Enum 是 Object 本身的一部分,在 Object 里我们已经算过消耗了。
45
42
  // Scalar 和 Enum 其实就是 Object 上的某个字段,一个 Object 上多返回几个字段消耗是比较少的。
@@ -48,16 +45,13 @@ function shopifyEstimator(args, type) {
48
45
  }
49
46
  }
50
47
  const REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME = "GRAPHQL_COMPLEXITY.RATE_LIMIT";
51
- let ComplexityPlugin = ComplexityPlugin_1 = class ComplexityPlugin {
52
- constructor(options, gqlSchemaHost, redis) {
48
+ let ComplexityPlugin = class ComplexityPlugin {
49
+ constructor(options, gqlSchemaHost) {
53
50
  this.options = options;
54
51
  this.gqlSchemaHost = gqlSchemaHost;
55
- this.redis = redis;
56
- this.logger = new common_1.Logger(ComplexityPlugin_1.name);
57
- this.logging = false;
52
+ this.complexityEstimators = [];
58
53
  this.maxComplexity = 1000;
59
54
  this.defaultComplexity = 0;
60
- this.rateLimitEnable = true;
61
55
  this.rateLimitKeyPrefix = "graphql-complexity:rate-limit";
62
56
  this.rateLimitRestoreRate = 50;
63
57
  this.rateLimitMaximumAvailable = 1000;
@@ -65,18 +59,16 @@ let ComplexityPlugin = ComplexityPlugin_1 = class ComplexityPlugin {
65
59
  const req = args.contextValue.req;
66
60
  return req.ips.length ? req.ips[0] : req.ip;
67
61
  };
68
- if (typeof options.complexity !== "boolean" &&
69
- typeof options.complexity !== "undefined") {
70
- this.logging = options.complexity.logging ?? this.logging;
62
+ if (typeof options.complexity !== "undefined") {
71
63
  this.maxComplexity =
72
64
  options.complexity.maxComplexity ?? this.maxComplexity;
73
65
  this.defaultComplexity =
74
66
  options.complexity.defaultComplexity ?? this.defaultComplexity;
75
- if (options.complexity.rateLimit === false) {
76
- this.rateLimitEnable = false;
77
- }
78
- else if (typeof options.complexity.rateLimit !== "boolean" &&
79
- typeof options.complexity.rateLimit !== "undefined") {
67
+ if (typeof options.complexity.rateLimit !== "undefined") {
68
+ this.rateLimitRedis =
69
+ typeof options.complexity.rateLimit.connection !== "undefined"
70
+ ? new ioredis_1.Redis(options.complexity.rateLimit.connection)
71
+ : new ioredis_1.Redis();
80
72
  this.rateLimitKeyPrefix =
81
73
  options.complexity.rateLimit.keyPrefix ?? this.rateLimitKeyPrefix;
82
74
  this.rateLimitRestoreRate =
@@ -88,8 +80,8 @@ let ComplexityPlugin = ComplexityPlugin_1 = class ComplexityPlugin {
88
80
  options.complexity.rateLimit.getId ?? this.rateLimitGetId;
89
81
  }
90
82
  }
91
- if (typeof this.redis !== "undefined" && this.rateLimitEnable) {
92
- this.redis.defineCommand(REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME, {
83
+ if (typeof this.rateLimitRedis !== "undefined") {
84
+ this.rateLimitRedis.defineCommand(REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME, {
93
85
  numberOfKeys: 5,
94
86
  lua: /* lua */ `
95
87
  -- 获取当前时间戳
@@ -144,59 +136,98 @@ let ComplexityPlugin = ComplexityPlugin_1 = class ComplexityPlugin {
144
136
  `,
145
137
  });
146
138
  }
139
+ this.complexityEstimators = [
140
+ (0, graphql_query_complexity_1.directiveEstimator)(),
141
+ (0, graphql_query_complexity_1.fieldExtensionsEstimator)(),
142
+ shopifyEstimator,
143
+ (0, graphql_query_complexity_1.simpleEstimator)({ defaultComplexity: this.defaultComplexity }),
144
+ ];
145
+ }
146
+ async addPoint(args, point) {
147
+ if (typeof this.rateLimitRedis === "undefined") {
148
+ throw new Error("Redis is not defined");
149
+ }
150
+ return (await this.rateLimitRedis[REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME](this.rateLimitKeyPrefix, this.rateLimitMaximumAvailable, this.rateLimitRestoreRate, this.rateLimitGetId(args), -point));
151
+ }
152
+ async subPoint(args, point) {
153
+ if (typeof this.rateLimitRedis === "undefined") {
154
+ throw new Error("Redis is not defined");
155
+ }
156
+ return (await this.rateLimitRedis[REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME](this.rateLimitKeyPrefix, this.rateLimitMaximumAvailable, this.rateLimitRestoreRate, this.rateLimitGetId(args), point));
147
157
  }
148
158
  async requestDidStart() {
149
159
  const { schema } = this.gqlSchemaHost;
160
+ const cost = {
161
+ requestedQueryCost: 0,
162
+ actualQueryCost: 0,
163
+ };
150
164
  return {
151
165
  didResolveOperation: async (args) => {
152
166
  const { request, document } = args;
153
- const complexity = (0, graphql_query_complexity_1.getComplexity)({
167
+ cost.requestedQueryCost = (0, graphql_query_complexity_1.getComplexity)({
154
168
  schema,
155
169
  operationName: request.operationName,
156
170
  query: document,
157
171
  variables: request.variables,
158
- estimators: [
159
- (0, graphql_query_complexity_1.directiveEstimator)({ name: "complexity" }),
160
- (0, graphql_query_complexity_1.fieldExtensionsEstimator)(),
161
- shopifyEstimator,
162
- (0, graphql_query_complexity_1.simpleEstimator)({ defaultComplexity: this.defaultComplexity }),
163
- ],
172
+ estimators: this.complexityEstimators,
164
173
  });
165
- request.extensions = request.extensions ?? {};
166
- request.extensions.cost = {
167
- requestedQueryCost: complexity,
168
- };
169
- if (this.logging) {
170
- this.logger.log("query complexity", {
171
- operationName: request.operationName,
172
- complexity,
173
- });
174
+ if (cost.requestedQueryCost >= this.maxComplexity) {
175
+ throw new common_1.HttpException(`Query is too complex: ${cost.requestedQueryCost}. Maximum allowed complexity: ${this.maxComplexity}`, 429);
174
176
  }
175
- if (complexity >= this.maxComplexity) {
176
- throw new common_1.HttpException(`Query is too complex: ${complexity}. Maximum allowed complexity: ${this.maxComplexity}`, 429);
177
- }
178
- if (typeof this.redis !== "undefined" && this.rateLimitEnable) {
179
- const [blocked, currentlyAvailable] = (await this.redis[REDIS_GRAPHQL_COMPLEXITY_RATE_LIMIT_COMMAND_NAME](this.rateLimitKeyPrefix, this.rateLimitMaximumAvailable, this.rateLimitRestoreRate, this.rateLimitGetId(args), complexity));
180
- request.extensions.cost = {
181
- ...request.extensions.cost,
182
- throttleStatus: {
183
- maximumAvailable: this.rateLimitMaximumAvailable,
184
- currentlyAvailable,
185
- restoreRate: this.rateLimitRestoreRate,
186
- },
177
+ if (typeof this.rateLimitRedis !== "undefined") {
178
+ const [blocked, currentlyAvailable] = await this.subPoint(args, cost.requestedQueryCost);
179
+ cost.throttleStatus = {
180
+ maximumAvailable: this.rateLimitMaximumAvailable,
181
+ currentlyAvailable,
182
+ restoreRate: this.rateLimitRestoreRate,
187
183
  };
188
184
  if (blocked) {
189
185
  throw new common_1.HttpException(`Too Many Requests`, 429);
190
186
  }
191
187
  }
192
188
  },
193
- willSendResponse: async ({ request, response }) => {
194
- if (response.body.kind === "single" &&
195
- "data" in response.body.singleResult &&
196
- typeof request.extensions?.cost !== "undefined") {
197
- response.body.singleResult.extensions = {
198
- ...response.body.singleResult.extensions,
199
- cost: request.extensions.cost,
189
+ executionDidStart: async () => {
190
+ return {
191
+ willResolveField: ({ info }) => {
192
+ const parentTypeFields = info.parentType.getFields();
193
+ const field = parentTypeFields[info.fieldName];
194
+ const estimatorArgs = {
195
+ childComplexity: 0,
196
+ args: {},
197
+ field,
198
+ node: info.fieldNodes[0],
199
+ type: info.parentType,
200
+ };
201
+ return (error) => {
202
+ if (error === null) {
203
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
204
+ let fieldCost;
205
+ for (const complexityEstimator of this.complexityEstimators) {
206
+ fieldCost = complexityEstimator(estimatorArgs);
207
+ if (typeof fieldCost === "number" && !isNaN(fieldCost)) {
208
+ cost.actualQueryCost += fieldCost;
209
+ break;
210
+ }
211
+ }
212
+ }
213
+ };
214
+ },
215
+ };
216
+ },
217
+ willSendResponse: async (request) => {
218
+ if (request.response.body.kind === "single" &&
219
+ "data" in request.response.body.singleResult) {
220
+ if (typeof this.rateLimitRedis !== "undefined") {
221
+ const [, currentlyAvailable] = await this.addPoint(request, cost.requestedQueryCost - cost.actualQueryCost);
222
+ cost.throttleStatus = {
223
+ maximumAvailable: this.rateLimitMaximumAvailable,
224
+ currentlyAvailable,
225
+ restoreRate: this.rateLimitRestoreRate,
226
+ };
227
+ }
228
+ request.response.body.singleResult.extensions = {
229
+ ...request.response.body.singleResult.extensions,
230
+ cost,
200
231
  };
201
232
  }
202
233
  },
@@ -204,11 +235,9 @@ let ComplexityPlugin = ComplexityPlugin_1 = class ComplexityPlugin {
204
235
  }
205
236
  };
206
237
  exports.ComplexityPlugin = ComplexityPlugin;
207
- exports.ComplexityPlugin = ComplexityPlugin = ComplexityPlugin_1 = __decorate([
238
+ exports.ComplexityPlugin = ComplexityPlugin = __decorate([
208
239
  (0, apollo_1.Plugin)(),
209
240
  __param(0, (0, common_1.Inject)(graphql_module_definition_1.MODULE_OPTIONS_TOKEN)),
210
- __param(2, (0, common_1.Optional)()),
211
- __metadata("design:paramtypes", [Object, graphql_1.GraphQLSchemaHost,
212
- redis_1.Redis])
241
+ __metadata("design:paramtypes", [Object, graphql_1.GraphQLSchemaHost])
213
242
  ], ComplexityPlugin);
214
243
  //# sourceMappingURL=complexity.plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"complexity.plugin.js","sourceRoot":"","sources":["../../src/plugins/complexity.plugin.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;AAQrD,4CAAyC;AACzC,2CAAwC;AACxC,2CAAyE;AACzE,6CAAoD;AAEpD,qCASiB;AACjB,uEAMkC;AAElC,4EAAoE;AAGpE,sFAAsF;AACtF,SAAS,gBAAgB,CACvB,IAA6B,EAC7B,IAAkB;IAElB,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAE/B,IAAI,IAAI,YAAY,wBAAc,IAAI,IAAI,YAAY,qBAAW,EAAE;QACjE,OAAO,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;KAC5C;IAED,+DAA+D;IAC/D,IACE,IAAI,YAAY,2BAAiB;QACjC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,EACvD;QACA,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACvE;IAED,gEAAgE;IAChE,2DAA2D;IAC3D,IACE,IAAI,YAAY,2BAAiB;QACjC,IAAI,YAAY,8BAAoB;QACpC,IAAI,YAAY,0BAAgB,EAChC;QACA,OAAO,CAAC,CAAC;KACV;IAED,qDAAqD;IACrD,8DAA8D;IAC9D,IAAI,IAAI,YAAY,2BAAiB,IAAI,IAAI,YAAY,yBAAe,EAAE;QACxE,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAED,MAAM,gDAAgD,GACpD,+BAA+B,CAAC;AAG3B,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