@nest-boot/graphql 5.10.0 → 5.11.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.
- package/dist/connection.builder.d.ts +2 -0
- package/dist/connection.builder.js +64 -16
- package/dist/connection.builder.js.map +1 -1
- package/dist/dtos/page-info.object.js +21 -5
- package/dist/dtos/page-info.object.js.map +1 -1
- package/dist/plugins/complexity.plugin.d.ts +3 -1
- package/dist/plugins/complexity.plugin.js +3 -0
- package/dist/plugins/complexity.plugin.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -18,6 +18,8 @@ export declare class ConnectionBuilder<T extends {
|
|
|
18
18
|
private readonly entityClass;
|
|
19
19
|
private readonly options;
|
|
20
20
|
private readonly entityName;
|
|
21
|
+
private readonly searchableOptions?;
|
|
22
|
+
private readonly supportedFilterParameters;
|
|
21
23
|
constructor(entityClass: Type<T>, options: ConnectionBuilderOptions<T>);
|
|
22
24
|
build(): ConnectionBuildResult<T>;
|
|
23
25
|
}
|
|
@@ -13,7 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ConnectionBuilder = void 0;
|
|
16
|
+
const search_constants_1 = require("@nest-boot/search/dist/search.constants");
|
|
16
17
|
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
+
const inflection_1 = require("inflection");
|
|
17
19
|
const lodash_1 = __importDefault(require("lodash"));
|
|
18
20
|
const dtos_1 = require("./dtos");
|
|
19
21
|
const enums_1 = require("./enums");
|
|
@@ -21,38 +23,55 @@ class ConnectionBuilder {
|
|
|
21
23
|
constructor(entityClass, options) {
|
|
22
24
|
this.entityClass = entityClass;
|
|
23
25
|
this.options = options;
|
|
26
|
+
this.supportedFilterParameters = [];
|
|
24
27
|
this.entityName = entityClass.name;
|
|
28
|
+
this.searchableOptions = Reflect.getMetadata(search_constants_1.SEARCHABLE_OPTIONS, this.entityClass);
|
|
29
|
+
this.supportedFilterParameters.push(...Object.keys(this.searchableOptions?.aliasFields ?? {}), ...(this.searchableOptions?.filterableFields ?? []));
|
|
30
|
+
this.supportedFilterParameters = lodash_1.default.sortedUniq(this.supportedFilterParameters);
|
|
25
31
|
}
|
|
26
32
|
build() {
|
|
27
33
|
let Edge = class Edge {
|
|
28
34
|
};
|
|
29
35
|
__decorate([
|
|
30
|
-
(0, graphql_1.Field)(() => this.entityClass
|
|
36
|
+
(0, graphql_1.Field)(() => this.entityClass, {
|
|
37
|
+
description: `The item at the end of ${this.entityName}Edge.`,
|
|
38
|
+
}),
|
|
31
39
|
__metadata("design:type", Object)
|
|
32
40
|
], Edge.prototype, "node", void 0);
|
|
33
41
|
__decorate([
|
|
34
|
-
(0, graphql_1.Field)({ complexity: 0 }),
|
|
42
|
+
(0, graphql_1.Field)({ complexity: 0, description: `A cursor for use in pagination.` }),
|
|
35
43
|
__metadata("design:type", String)
|
|
36
44
|
], Edge.prototype, "cursor", void 0);
|
|
37
45
|
Edge = __decorate([
|
|
38
|
-
(0, graphql_1.ObjectType)(`${this.entityName}Edge
|
|
46
|
+
(0, graphql_1.ObjectType)(`${this.entityName}Edge`, {
|
|
47
|
+
description: `An auto-generated type which holds one ${this.entityName} and a cursor during pagination.`,
|
|
48
|
+
})
|
|
39
49
|
], Edge);
|
|
40
50
|
let Connection = class Connection {
|
|
41
51
|
};
|
|
42
52
|
__decorate([
|
|
43
|
-
(0, graphql_1.Field)(() => [Edge], { complexity: 0 }),
|
|
53
|
+
(0, graphql_1.Field)(() => [Edge], { complexity: 0, description: `A list of edges.` }),
|
|
44
54
|
__metadata("design:type", Array)
|
|
45
55
|
], Connection.prototype, "edges", void 0);
|
|
46
56
|
__decorate([
|
|
47
|
-
(0, graphql_1.Field)({
|
|
57
|
+
(0, graphql_1.Field)({
|
|
58
|
+
complexity: 0,
|
|
59
|
+
description: `Information to aid in pagination.`,
|
|
60
|
+
}),
|
|
48
61
|
__metadata("design:type", dtos_1.PageInfo)
|
|
49
62
|
], Connection.prototype, "pageInfo", void 0);
|
|
50
63
|
__decorate([
|
|
51
|
-
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
64
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
65
|
+
complexity: 0,
|
|
66
|
+
description: `Identifies the total count of items in the connection.`,
|
|
67
|
+
}),
|
|
52
68
|
__metadata("design:type", Number)
|
|
53
69
|
], Connection.prototype, "totalCount", void 0);
|
|
54
70
|
Connection = __decorate([
|
|
55
|
-
(0, graphql_1.ObjectType)(`${this.entityName}Connection`, {
|
|
71
|
+
(0, graphql_1.ObjectType)(`${this.entityName}Connection`, {
|
|
72
|
+
isAbstract: true,
|
|
73
|
+
description: `An auto-generated type for paginating through multiple ${(0, inflection_1.pluralize)(this.entityName)}.`,
|
|
74
|
+
})
|
|
56
75
|
], Connection);
|
|
57
76
|
const OrderField = this.options.orderFields.length > 0
|
|
58
77
|
? this.options.orderFields.reduce((result, field) => ({
|
|
@@ -65,45 +84,74 @@ class ConnectionBuilder {
|
|
|
65
84
|
if (typeof OrderField !== "undefined") {
|
|
66
85
|
(0, graphql_1.registerEnumType)(OrderField, {
|
|
67
86
|
name: `${this.entityName}OrderField`,
|
|
87
|
+
description: `Properties by which ${(0, inflection_1.humanize)(this.entityName, true)} connections can be ordered.`,
|
|
68
88
|
});
|
|
69
89
|
}
|
|
70
90
|
let Order = class Order {
|
|
71
91
|
};
|
|
72
92
|
__decorate([
|
|
73
|
-
(0, graphql_1.Field)(() => OrderField ?? String
|
|
93
|
+
(0, graphql_1.Field)(() => OrderField ?? String, {
|
|
94
|
+
description: `The field to order ${(0, inflection_1.pluralize)((0, inflection_1.humanize)(this.entityName, true))} by.`,
|
|
95
|
+
}),
|
|
74
96
|
__metadata("design:type", String)
|
|
75
97
|
], Order.prototype, "field", void 0);
|
|
76
98
|
__decorate([
|
|
77
|
-
(0, graphql_1.Field)(() => enums_1.OrderDirection),
|
|
99
|
+
(0, graphql_1.Field)(() => enums_1.OrderDirection, { description: `The ordering direction.` }),
|
|
78
100
|
__metadata("design:type", String)
|
|
79
101
|
], Order.prototype, "direction", void 0);
|
|
80
102
|
Order = __decorate([
|
|
81
|
-
(0, graphql_1.InputType)(`${this.entityName}Order
|
|
103
|
+
(0, graphql_1.InputType)(`${this.entityName}Order`, {
|
|
104
|
+
description: `Ordering options for ${(0, inflection_1.humanize)(this.entityName, true)} connections`,
|
|
105
|
+
})
|
|
82
106
|
], Order);
|
|
83
107
|
let ConnectionArgs = class ConnectionArgs {
|
|
84
108
|
};
|
|
85
109
|
__decorate([
|
|
86
|
-
(0, graphql_1.Field)({
|
|
110
|
+
(0, graphql_1.Field)({
|
|
111
|
+
nullable: true,
|
|
112
|
+
...(this.supportedFilterParameters.length > 0
|
|
113
|
+
? {
|
|
114
|
+
description: `Supported filter parameters:\n${this.supportedFilterParameters
|
|
115
|
+
.map((parameter) => `* \`${parameter}\``)
|
|
116
|
+
.join("\n")}`,
|
|
117
|
+
}
|
|
118
|
+
: {}),
|
|
119
|
+
}),
|
|
87
120
|
__metadata("design:type", String)
|
|
88
121
|
], ConnectionArgs.prototype, "query", void 0);
|
|
89
122
|
__decorate([
|
|
90
|
-
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
123
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
124
|
+
nullable: true,
|
|
125
|
+
description: "Returns up to the first `n` elements from the list.",
|
|
126
|
+
}),
|
|
91
127
|
__metadata("design:type", Number)
|
|
92
128
|
], ConnectionArgs.prototype, "first", void 0);
|
|
93
129
|
__decorate([
|
|
94
|
-
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
130
|
+
(0, graphql_1.Field)(() => graphql_1.Int, {
|
|
131
|
+
nullable: true,
|
|
132
|
+
description: "Returns up to the last `n` elements from the list.",
|
|
133
|
+
}),
|
|
95
134
|
__metadata("design:type", Number)
|
|
96
135
|
], ConnectionArgs.prototype, "last", void 0);
|
|
97
136
|
__decorate([
|
|
98
|
-
(0, graphql_1.Field)({
|
|
137
|
+
(0, graphql_1.Field)({
|
|
138
|
+
nullable: true,
|
|
139
|
+
description: `Returns the elements that come after the specified cursor.`,
|
|
140
|
+
}),
|
|
99
141
|
__metadata("design:type", String)
|
|
100
142
|
], ConnectionArgs.prototype, "after", void 0);
|
|
101
143
|
__decorate([
|
|
102
|
-
(0, graphql_1.Field)({
|
|
144
|
+
(0, graphql_1.Field)({
|
|
145
|
+
nullable: true,
|
|
146
|
+
description: `Returns the elements that come before the specified cursor.`,
|
|
147
|
+
}),
|
|
103
148
|
__metadata("design:type", String)
|
|
104
149
|
], ConnectionArgs.prototype, "before", void 0);
|
|
105
150
|
__decorate([
|
|
106
|
-
(0, graphql_1.Field)(() => Order, {
|
|
151
|
+
(0, graphql_1.Field)(() => Order, {
|
|
152
|
+
nullable: true,
|
|
153
|
+
description: `Ordering options for the returned topics.`,
|
|
154
|
+
}),
|
|
107
155
|
__metadata("design:type", Order)
|
|
108
156
|
], ConnectionArgs.prototype, "orderBy", void 0);
|
|
109
157
|
ConnectionArgs = __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;
|
|
1
|
+
{"version":3,"file":"connection.builder.js","sourceRoot":"","sources":["../src/connection.builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,8EAA6E;AAE7E,6CAOyB;AACzB,2CAAiD;AACjD,oDAAuB;AAEvB,iCAAkC;AAClC,mCAAyC;AAuBzC,MAAa,iBAAiB;IAK5B,YACmB,WAAoB,EACpB,OAAoC;QADpC,gBAAW,GAAX,WAAW,CAAS;QACpB,YAAO,GAAP,OAAO,CAA6B;QAJtC,8BAAyB,GAAa,EA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AAC,GAAG,EAAE,CAAC,KAAK,EAAE;gBAClB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,2CAA2C;aACzD,CAAC;sCACQ,KAAK;uDAAC;QAzCZ,cAAc;YADnB,IAAA,kBAAQ,GAAE;WACL,cAAc,CA0CnB;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,IAAI;YACJ,KAAK;YACL,UAAU;SACX,CAAC;IACJ,CAAC;CACF;AA3JD,8CA2JC"}
|
|
@@ -15,22 +15,38 @@ let PageInfo = class PageInfo {
|
|
|
15
15
|
};
|
|
16
16
|
exports.PageInfo = PageInfo;
|
|
17
17
|
__decorate([
|
|
18
|
-
(0, graphql_1.Field)({
|
|
18
|
+
(0, graphql_1.Field)({
|
|
19
|
+
complexity: 0,
|
|
20
|
+
description: `Whether there are more pages to fetch following the current page.`,
|
|
21
|
+
}),
|
|
19
22
|
__metadata("design:type", Boolean)
|
|
20
23
|
], PageInfo.prototype, "hasNextPage", void 0);
|
|
21
24
|
__decorate([
|
|
22
|
-
(0, graphql_1.Field)({
|
|
25
|
+
(0, graphql_1.Field)({
|
|
26
|
+
complexity: 0,
|
|
27
|
+
description: `Whether there are any pages prior to the current page.`,
|
|
28
|
+
}),
|
|
23
29
|
__metadata("design:type", Boolean)
|
|
24
30
|
], PageInfo.prototype, "hasPreviousPage", void 0);
|
|
25
31
|
__decorate([
|
|
26
|
-
(0, graphql_1.Field)({
|
|
32
|
+
(0, graphql_1.Field)({
|
|
33
|
+
nullable: true,
|
|
34
|
+
complexity: 0,
|
|
35
|
+
description: `The cursor corresponding to the first node in edges.`,
|
|
36
|
+
}),
|
|
27
37
|
__metadata("design:type", String)
|
|
28
38
|
], PageInfo.prototype, "startCursor", void 0);
|
|
29
39
|
__decorate([
|
|
30
|
-
(0, graphql_1.Field)({
|
|
40
|
+
(0, graphql_1.Field)({
|
|
41
|
+
nullable: true,
|
|
42
|
+
complexity: 0,
|
|
43
|
+
description: `The cursor corresponding to the last node in edges.`,
|
|
44
|
+
}),
|
|
31
45
|
__metadata("design:type", String)
|
|
32
46
|
], PageInfo.prototype, "endCursor", void 0);
|
|
33
47
|
exports.PageInfo = PageInfo = __decorate([
|
|
34
|
-
(0, graphql_1.ObjectType)(
|
|
48
|
+
(0, graphql_1.ObjectType)({
|
|
49
|
+
description: `Returns information about pagination in a connection, in accordance with the [Relay specification](https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo).`,
|
|
50
|
+
})
|
|
35
51
|
], PageInfo);
|
|
36
52
|
//# sourceMappingURL=page-info.object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-info.object.js","sourceRoot":"","sources":["../../src/dtos/page-info.object.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;
|
|
1
|
+
{"version":3,"file":"page-info.object.js","sourceRoot":"","sources":["../../src/dtos/page-info.object.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AAK7C,IAAM,QAAQ,GAAd,MAAM,QAAQ;CA0BpB,CAAA;AA1BY,4BAAQ;AAKnB;IAJC,IAAA,eAAK,EAAC;QACL,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,mEAAmE;KACjF,CAAC;;6CACoB;AAMtB;IAJC,IAAA,eAAK,EAAC;QACL,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,wDAAwD;KACtE,CAAC;;iDACwB;AAO1B;IALC,IAAA,eAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,sDAAsD;KACpE,CAAC;;6CACmB;AAOrB;IALC,IAAA,eAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,qDAAqD;KACnE,CAAC;;2CACiB;mBAzBR,QAAQ;IAHpB,IAAA,oBAAU,EAAC;QACV,WAAW,EAAE,uKAAuK;KACrL,CAAC;GACW,QAAQ,CA0BpB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ApolloServerPlugin, type BaseContext, GraphQLRequestContext, type GraphQLRequestListener } from "@apollo/server";
|
|
2
|
+
import { OnApplicationShutdown } from "@nestjs/common";
|
|
2
3
|
import { GraphQLSchemaHost } from "@nestjs/graphql";
|
|
3
4
|
import { GraphQLModuleOptions } from "../interfaces";
|
|
4
|
-
export declare class ComplexityPlugin implements ApolloServerPlugin {
|
|
5
|
+
export declare class ComplexityPlugin implements ApolloServerPlugin, OnApplicationShutdown {
|
|
5
6
|
private readonly options;
|
|
6
7
|
private readonly gqlSchemaHost;
|
|
7
8
|
private readonly complexityEstimators;
|
|
@@ -16,4 +17,5 @@ export declare class ComplexityPlugin implements ApolloServerPlugin {
|
|
|
16
17
|
addPoint(args: GraphQLRequestContext<BaseContext>, point: number): Promise<[boolean, number]>;
|
|
17
18
|
subPoint(args: GraphQLRequestContext<BaseContext>, point: number): Promise<[boolean, number]>;
|
|
18
19
|
requestDidStart(): Promise<GraphQLRequestListener<BaseContext>>;
|
|
20
|
+
onApplicationShutdown(): Promise<void>;
|
|
19
21
|
}
|
|
@@ -233,6 +233,9 @@ let ComplexityPlugin = class ComplexityPlugin {
|
|
|
233
233
|
},
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
+
async onApplicationShutdown() {
|
|
237
|
+
await this.rateLimitRedis?.quit();
|
|
238
|
+
}
|
|
236
239
|
};
|
|
237
240
|
exports.ComplexityPlugin = ComplexityPlugin;
|
|
238
241
|
exports.ComplexityPlugin = ComplexityPlugin = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complexity.plugin.js","sourceRoot":"","sources":["../../src/plugins/complexity.plugin.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;AAQrD,2CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"complexity.plugin.js","sourceRoot":"","sources":["../../src/plugins/complexity.plugin.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;AAQr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