@thangnv-dev/graphql-nest 0.0.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/connection.d.ts +43 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +193 -0
- package/dist/connection.js.map +1 -0
- package/dist/graphql.module.d.ts +3 -0
- package/dist/graphql.module.d.ts.map +1 -0
- package/dist/graphql.module.js +63 -0
- package/dist/graphql.module.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/scalars.providers.d.ts +54 -0
- package/dist/scalars.providers.d.ts.map +1 -0
- package/dist/scalars.providers.js +156 -0
- package/dist/scalars.providers.js.map +1 -0
- package/dist/udt.directive.d.ts +4 -0
- package/dist/udt.directive.d.ts.map +1 -0
- package/dist/udt.directive.js +125 -0
- package/dist/udt.directive.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Type } from '@nestjs/common';
|
|
2
|
+
import type { ConnectionArgs as GenericConnectionArgs, ConnectionLazyValue as GenericConnectionLazyValue, ConnectionNode as GenericConnectionNode, ConnectionPageInfo as GenericConnectionPageInfo, ConnectionResult as GenericConnectionResult } from '@thangnv-dev/data-nest';
|
|
3
|
+
export type ConnectionNode = GenericConnectionNode;
|
|
4
|
+
export type ConnectionPageInfo = GenericConnectionPageInfo;
|
|
5
|
+
export type ConnectionLazyValue<T> = GenericConnectionLazyValue<T>;
|
|
6
|
+
export type ConnectionResult<TNode extends ConnectionNode = ConnectionNode> = GenericConnectionResult<TNode>;
|
|
7
|
+
export type ConnectionArgsShape = GenericConnectionArgs;
|
|
8
|
+
export declare enum ConnectionPageMode {
|
|
9
|
+
CURSOR = "cursor",
|
|
10
|
+
OFFSET = "offset"
|
|
11
|
+
}
|
|
12
|
+
export declare class ConnectionArgs implements ConnectionArgsShape {
|
|
13
|
+
first?: number;
|
|
14
|
+
after?: string;
|
|
15
|
+
last?: number;
|
|
16
|
+
before?: string;
|
|
17
|
+
limit?: number;
|
|
18
|
+
offset?: number;
|
|
19
|
+
includeCount?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class PageInfo {
|
|
22
|
+
mode: ConnectionPageMode;
|
|
23
|
+
hasNextPage: boolean;
|
|
24
|
+
hasPreviousPage: boolean;
|
|
25
|
+
startCursor?: string;
|
|
26
|
+
endCursor?: string;
|
|
27
|
+
limit?: number;
|
|
28
|
+
offset?: number;
|
|
29
|
+
constructor(input: ConnectionPageInfo);
|
|
30
|
+
}
|
|
31
|
+
export declare abstract class Connection<TNode extends ConnectionNode = ConnectionNode> {
|
|
32
|
+
private readonly nodesLoader;
|
|
33
|
+
private readonly totalCountLoader?;
|
|
34
|
+
private nodesPromise?;
|
|
35
|
+
private totalCountPromise?;
|
|
36
|
+
pageInfo: PageInfo;
|
|
37
|
+
get totalCount(): Promise<number | undefined> | undefined;
|
|
38
|
+
protected constructor(input: ConnectionResult<TNode>);
|
|
39
|
+
get nodes(): ConnectionLazyValue<TNode[]>;
|
|
40
|
+
protected getNodes(): Promise<TNode[]>;
|
|
41
|
+
}
|
|
42
|
+
export declare function createConnectionType<TNode extends ConnectionNode>(nodeType: Type<TNode>): Type<Connection<TNode>>;
|
|
43
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAQ1C,OAAO,KAAK,EACV,cAAc,IAAI,qBAAqB,EACvC,mBAAmB,IAAI,0BAA0B,EACjD,cAAc,IAAI,qBAAqB,EACvC,kBAAkB,IAAI,yBAAyB,EAC/C,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,cAAc,GAAG,qBA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,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAUxD;IAED,SAAS,aAAa,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;IASpD,IAAI,KAAK,IAAI,mBAAmB,CAAC,KAAK,EAAE,CAAC,CAExC;IAED,SAAS,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAOvC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,SAAS,cAAc,EAC/D,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GACpB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAczB"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ArgsType, Field, Int, ObjectType, registerEnumType, } from '@nestjs/graphql';
|
|
11
|
+
export var ConnectionPageMode;
|
|
12
|
+
(function (ConnectionPageMode) {
|
|
13
|
+
ConnectionPageMode["CURSOR"] = "cursor";
|
|
14
|
+
ConnectionPageMode["OFFSET"] = "offset";
|
|
15
|
+
})(ConnectionPageMode || (ConnectionPageMode = {}));
|
|
16
|
+
registerEnumType(ConnectionPageMode, {
|
|
17
|
+
name: 'ConnectionPageMode',
|
|
18
|
+
});
|
|
19
|
+
let ConnectionArgs = class ConnectionArgs {
|
|
20
|
+
first;
|
|
21
|
+
after;
|
|
22
|
+
last;
|
|
23
|
+
before;
|
|
24
|
+
limit;
|
|
25
|
+
offset;
|
|
26
|
+
includeCount;
|
|
27
|
+
};
|
|
28
|
+
__decorate([
|
|
29
|
+
Field(() => Int, { name: 'first', nullable: true }),
|
|
30
|
+
__metadata("design:type", Number)
|
|
31
|
+
], ConnectionArgs.prototype, "first", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
Field(() => String, { name: 'after', nullable: true }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], ConnectionArgs.prototype, "after", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
Field(() => Int, { name: 'last', nullable: true }),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], ConnectionArgs.prototype, "last", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
Field(() => String, { name: 'before', nullable: true }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], ConnectionArgs.prototype, "before", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
Field(() => Int, { name: 'limit', nullable: true }),
|
|
46
|
+
__metadata("design:type", Number)
|
|
47
|
+
], ConnectionArgs.prototype, "limit", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
Field(() => Int, { name: 'offset', nullable: true }),
|
|
50
|
+
__metadata("design:type", Number)
|
|
51
|
+
], ConnectionArgs.prototype, "offset", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
Field(() => Boolean, { name: 'includeCount', nullable: true }),
|
|
54
|
+
__metadata("design:type", Boolean)
|
|
55
|
+
], ConnectionArgs.prototype, "includeCount", void 0);
|
|
56
|
+
ConnectionArgs = __decorate([
|
|
57
|
+
ArgsType()
|
|
58
|
+
], ConnectionArgs);
|
|
59
|
+
export { ConnectionArgs };
|
|
60
|
+
let PageInfo = class PageInfo {
|
|
61
|
+
mode;
|
|
62
|
+
hasNextPage;
|
|
63
|
+
hasPreviousPage;
|
|
64
|
+
startCursor;
|
|
65
|
+
endCursor;
|
|
66
|
+
limit;
|
|
67
|
+
offset;
|
|
68
|
+
constructor(input) {
|
|
69
|
+
this.mode =
|
|
70
|
+
input.mode === 'offset'
|
|
71
|
+
? ConnectionPageMode.OFFSET
|
|
72
|
+
: ConnectionPageMode.CURSOR;
|
|
73
|
+
this.hasNextPage = input.hasNextPage;
|
|
74
|
+
this.hasPreviousPage = input.hasPreviousPage;
|
|
75
|
+
if (input.mode === 'cursor') {
|
|
76
|
+
this.startCursor = input.startCursor;
|
|
77
|
+
this.endCursor = input.endCursor;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.limit = input.limit;
|
|
81
|
+
this.offset = input.offset;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
__decorate([
|
|
85
|
+
Field(() => ConnectionPageMode, { name: 'mode' }),
|
|
86
|
+
__metadata("design:type", String)
|
|
87
|
+
], PageInfo.prototype, "mode", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
Field(() => Boolean, { name: 'hasNextPage' }),
|
|
90
|
+
__metadata("design:type", Boolean)
|
|
91
|
+
], PageInfo.prototype, "hasNextPage", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
Field(() => Boolean, { name: 'hasPreviousPage' }),
|
|
94
|
+
__metadata("design:type", Boolean)
|
|
95
|
+
], PageInfo.prototype, "hasPreviousPage", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
Field(() => String, { name: 'startCursor', nullable: true }),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], PageInfo.prototype, "startCursor", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
Field(() => String, { name: 'endCursor', nullable: true }),
|
|
102
|
+
__metadata("design:type", String)
|
|
103
|
+
], PageInfo.prototype, "endCursor", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
Field(() => Int, { name: 'limit', nullable: true }),
|
|
106
|
+
__metadata("design:type", Number)
|
|
107
|
+
], PageInfo.prototype, "limit", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
Field(() => Int, { name: 'offset', nullable: true }),
|
|
110
|
+
__metadata("design:type", Number)
|
|
111
|
+
], PageInfo.prototype, "offset", void 0);
|
|
112
|
+
PageInfo = __decorate([
|
|
113
|
+
ObjectType('PageInfo'),
|
|
114
|
+
__metadata("design:paramtypes", [Object])
|
|
115
|
+
], PageInfo);
|
|
116
|
+
export { PageInfo };
|
|
117
|
+
let Connection = class Connection {
|
|
118
|
+
nodesLoader;
|
|
119
|
+
totalCountLoader;
|
|
120
|
+
nodesPromise;
|
|
121
|
+
totalCountPromise;
|
|
122
|
+
pageInfo;
|
|
123
|
+
get totalCount() {
|
|
124
|
+
if (!this.totalCountLoader) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
if (!this.totalCountPromise) {
|
|
128
|
+
this.totalCountPromise = this.totalCountLoader();
|
|
129
|
+
}
|
|
130
|
+
return this.totalCountPromise;
|
|
131
|
+
}
|
|
132
|
+
constructor(input) {
|
|
133
|
+
this.pageInfo = new PageInfo(input.pageInfo);
|
|
134
|
+
this.nodesLoader = createLazyLoader(() => input.nodes);
|
|
135
|
+
this.totalCountLoader =
|
|
136
|
+
input.totalCount === undefined
|
|
137
|
+
? undefined
|
|
138
|
+
: createLazyLoader(() => input.totalCount);
|
|
139
|
+
}
|
|
140
|
+
get nodes() {
|
|
141
|
+
return this.getNodes();
|
|
142
|
+
}
|
|
143
|
+
getNodes() {
|
|
144
|
+
if (!this.nodesPromise) {
|
|
145
|
+
this.nodesPromise = this.nodesLoader();
|
|
146
|
+
}
|
|
147
|
+
return this.nodesPromise;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
__decorate([
|
|
151
|
+
Field(() => PageInfo, { name: 'pageInfo' }),
|
|
152
|
+
__metadata("design:type", PageInfo)
|
|
153
|
+
], Connection.prototype, "pageInfo", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
Field(() => Int, { name: 'totalCount', nullable: true }),
|
|
156
|
+
__metadata("design:type", Object),
|
|
157
|
+
__metadata("design:paramtypes", [])
|
|
158
|
+
], Connection.prototype, "totalCount", null);
|
|
159
|
+
Connection = __decorate([
|
|
160
|
+
ObjectType('Connection', { isAbstract: true }),
|
|
161
|
+
__metadata("design:paramtypes", [Object])
|
|
162
|
+
], Connection);
|
|
163
|
+
export { Connection };
|
|
164
|
+
export function createConnectionType(nodeType) {
|
|
165
|
+
let ConnectionType = class ConnectionType extends Connection {
|
|
166
|
+
get nodes() {
|
|
167
|
+
return this.getNodes();
|
|
168
|
+
}
|
|
169
|
+
constructor(input) {
|
|
170
|
+
super(input);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
__decorate([
|
|
174
|
+
Field(() => [nodeType], { name: 'nodes' }),
|
|
175
|
+
__metadata("design:type", Promise),
|
|
176
|
+
__metadata("design:paramtypes", [])
|
|
177
|
+
], ConnectionType.prototype, "nodes", null);
|
|
178
|
+
ConnectionType = __decorate([
|
|
179
|
+
ObjectType({ isAbstract: true }),
|
|
180
|
+
__metadata("design:paramtypes", [Object])
|
|
181
|
+
], ConnectionType);
|
|
182
|
+
return ConnectionType;
|
|
183
|
+
}
|
|
184
|
+
function createLazyLoader(getValue) {
|
|
185
|
+
return async () => {
|
|
186
|
+
const value = getValue();
|
|
187
|
+
if (typeof value === 'function') {
|
|
188
|
+
return value();
|
|
189
|
+
}
|
|
190
|
+
return value;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EACL,QAAQ,EACR,KAAK,EACL,GAAG,EACH,UAAU,EACV,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AAgBxB,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,uCAAi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A8B,EAAE,CAAA;QAC1C,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.module.d.ts","sourceRoot":"","sources":["../src/graphql.module.ts"],"names":[],"mappings":"AAqCA,qBA2Ba,SAAS;CAAG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { ApolloFederationDriver, } from '@nestjs/apollo';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import { Module } from '@nestjs/common';
|
|
10
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
11
|
+
import { GraphQLModule } from '@nestjs/graphql';
|
|
12
|
+
import { GraphQLInstant, } from '@thangnv-dev/graphql-common';
|
|
13
|
+
import { applyUdtDirective, UDT_DIRECTIVE_DEFINITION, } from './udt.directive.js';
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const { DirectiveLocation, GraphQLDirective, GraphQLNonNull, GraphQLString } = require('graphql');
|
|
16
|
+
const UDT_GRAPHQL_DIRECTIVE = new GraphQLDirective({
|
|
17
|
+
name: 'udt',
|
|
18
|
+
locations: [
|
|
19
|
+
DirectiveLocation.INPUT_FIELD_DEFINITION,
|
|
20
|
+
DirectiveLocation.ARGUMENT_DEFINITION,
|
|
21
|
+
],
|
|
22
|
+
args: {
|
|
23
|
+
name: {
|
|
24
|
+
type: new GraphQLNonNull(GraphQLString),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const CUSTOM_SCALAR_RESOLVERS = {
|
|
29
|
+
Instant: GraphQLInstant,
|
|
30
|
+
};
|
|
31
|
+
let GqlModule = class GqlModule {
|
|
32
|
+
};
|
|
33
|
+
GqlModule = __decorate([
|
|
34
|
+
Module({
|
|
35
|
+
imports: [
|
|
36
|
+
GraphQLModule.forRootAsync({
|
|
37
|
+
driver: ApolloFederationDriver,
|
|
38
|
+
imports: [ConfigModule],
|
|
39
|
+
inject: [ConfigService],
|
|
40
|
+
useFactory: (configService) => ({
|
|
41
|
+
driver: ApolloFederationDriver,
|
|
42
|
+
autoSchemaFile: {
|
|
43
|
+
federation: 2,
|
|
44
|
+
},
|
|
45
|
+
resolvers: CUSTOM_SCALAR_RESOLVERS,
|
|
46
|
+
typeDefs: UDT_DIRECTIVE_DEFINITION,
|
|
47
|
+
buildSchemaOptions: {
|
|
48
|
+
directives: [UDT_GRAPHQL_DIRECTIVE],
|
|
49
|
+
},
|
|
50
|
+
sortSchema: true,
|
|
51
|
+
subscriptions: {
|
|
52
|
+
'graphql-ws': true,
|
|
53
|
+
},
|
|
54
|
+
context: ({ req }) => ({ req }),
|
|
55
|
+
playground: configService.getOrThrow('NODE_ENV') !== 'production',
|
|
56
|
+
transformSchema: (schema) => applyUdtDirective(schema),
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
})
|
|
61
|
+
], GqlModule);
|
|
62
|
+
export { GqlModule };
|
|
63
|
+
//# sourceMappingURL=graphql.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.module.js","sourceRoot":"","sources":["../src/graphql.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,sBAAsB,GAEvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,C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,kBAAkB,EAAE;wBAClB,UAAU,EAAE,CAAC,qBAAqB,CAAC;qBACpC;oBACD,UAAU,EAAE,IAAI;oBAChB,aAAa,EAAE;wBACb,YAAY,EAAE,IAAI;qBACnB;oBACD,OAAO,EAAE,CAAC,EAAE,GAAG,EAAoB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;oBACjD,UAAU,EAAE,aAAa,CAAC,UAAU,CAAS,UAAU,CAAC,KAAK,YAAY;oBACzE,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;iBACvD,CAAC;aACH,CAAC;SACH;KACF,CAAC;GACW,SAAS,CAAG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { PageInfo, Connection, createConnectionType, ConnectionArgs, ConnectionPageMode, } from './connection.js';
|
|
2
|
+
export type { ConnectionNode, ConnectionPageInfo, ConnectionLazyValue, ConnectionResult, ConnectionArgsShape, } from './connection.js';
|
|
3
|
+
export { GqlModule } from './graphql.module.js';
|
|
4
|
+
export { applyUdtDirective, UDT_DIRECTIVE_DEFINITION } from './udt.directive.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { PageInfo, Connection, createConnectionType, ConnectionArgs, ConnectionPageMode, } from './connection.js';
|
|
2
|
+
export { GqlModule } from './graphql.module.js';
|
|
3
|
+
export { applyUdtDirective, UDT_DIRECTIVE_DEFINITION } from './udt.directive.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AAQxB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CustomScalar } from '@nestjs/graphql';
|
|
2
|
+
import type { ValueNode } from 'graphql';
|
|
3
|
+
type ScalarVariables = Readonly<Record<string, unknown>> | undefined;
|
|
4
|
+
export declare class Int64Scalar implements CustomScalar<string, bigint> {
|
|
5
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
6
|
+
parseValue(value: unknown): bigint;
|
|
7
|
+
serialize(value: bigint): string;
|
|
8
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): bigint;
|
|
9
|
+
}
|
|
10
|
+
export declare class BinaryScalar implements CustomScalar<string, Uint8Array> {
|
|
11
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
12
|
+
parseValue(value: unknown): Uint8Array;
|
|
13
|
+
serialize(value: Uint8Array): string;
|
|
14
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export declare class InstantScalar implements CustomScalar<string, Temporal.Instant> {
|
|
17
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
18
|
+
parseValue(value: unknown): Temporal.Instant;
|
|
19
|
+
serialize(value: Temporal.Instant): string;
|
|
20
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.Instant;
|
|
21
|
+
}
|
|
22
|
+
export declare class PlainDateScalar implements CustomScalar<string, Temporal.PlainDate> {
|
|
23
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
24
|
+
parseValue(value: unknown): Temporal.PlainDate;
|
|
25
|
+
serialize(value: Temporal.PlainDate): string;
|
|
26
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.PlainDate;
|
|
27
|
+
}
|
|
28
|
+
export declare class PlainDateTimeScalar implements CustomScalar<string, Temporal.PlainDateTime> {
|
|
29
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
30
|
+
parseValue(value: unknown): Temporal.PlainDateTime;
|
|
31
|
+
serialize(value: Temporal.PlainDateTime): string;
|
|
32
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.PlainDateTime;
|
|
33
|
+
}
|
|
34
|
+
export declare class PlainTimeScalar implements CustomScalar<string, Temporal.PlainTime> {
|
|
35
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
36
|
+
parseValue(value: unknown): Temporal.PlainTime;
|
|
37
|
+
serialize(value: Temporal.PlainTime): string;
|
|
38
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.PlainTime;
|
|
39
|
+
}
|
|
40
|
+
export declare class ZonedDateTimeScalar implements CustomScalar<string, Temporal.ZonedDateTime> {
|
|
41
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
42
|
+
parseValue(value: unknown): Temporal.ZonedDateTime;
|
|
43
|
+
serialize(value: Temporal.ZonedDateTime): string;
|
|
44
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.ZonedDateTime;
|
|
45
|
+
}
|
|
46
|
+
export declare class DurationScalar implements CustomScalar<string, Temporal.Duration> {
|
|
47
|
+
readonly description: import("graphql/jsutils/Maybe").Maybe<string>;
|
|
48
|
+
parseValue(value: unknown): Temporal.Duration;
|
|
49
|
+
serialize(value: Temporal.Duration): string;
|
|
50
|
+
parseLiteral(ast: ValueNode, variables?: ScalarVariables): Temporal.Duration;
|
|
51
|
+
}
|
|
52
|
+
export declare const GRAPHQL_SCALAR_PROVIDERS: readonly [typeof Int64Scalar, typeof BinaryScalar, typeof InstantScalar, typeof PlainDateScalar, typeof PlainDateTimeScalar, typeof PlainTimeScalar, typeof ZonedDateTimeScalar, typeof DurationScalar];
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=scalars.providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalars.providers.d.ts","sourceRoot":"","sources":["../src/scalars.providers.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAU,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAA;AAE3D,KAAK,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAA;AAkBpE,qBACa,WAAY,YAAW,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IAC9D,QAAQ,CAAC,WAAW,gDAA2B;IAE/C,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAIlC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIhC,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,MAAM;CAGlE;AAED,qBACa,YAAa,YAAW,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC;IACnE,QAAQ,CAAC,WAAW,gDAA4B;IAEhD,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU;IAItC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;IAIpC,YAAY,CAAC,GAAG,EAAE,SAAS,EA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AC,KAAK,EAAE,QAAQ,CAAC,SAAS,GAAG,MAAM;IAI5C,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC,SAAS;CAG9E;AAED,qBACa,mBAAoB,YAAW,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC;IACtF,QAAQ,CAAC,WAAW,gDAAmC;IAEvD,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,aAAa;IAIlD,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,GAAG,MAAM;IAIhD,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC,aAAa;CAGlF;AAED,qBACa,cAAe,YAAW,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5E,QAAQ,CAAC,WAAW,gDAA8B;IAElD,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,QAAQ;IAI7C,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,GAAG,MAAM;IAI3C,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC,QAAQ;CAG7E;AAED,eAAO,MAAM,wBAAwB,yMAS3B,CAAA"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { GraphQLBinary, GraphQLDuration, GraphQLInstant, GraphQLInt64, GraphQLPlainDate, GraphQLPlainDateTime, GraphQLPlainTime, GraphQLZonedDateTime, } from '@content-forge/graphql-common';
|
|
8
|
+
import { Scalar } from '@nestjs/graphql';
|
|
9
|
+
function parseScalarValue(scalar, value) {
|
|
10
|
+
return scalar.parseValue(value);
|
|
11
|
+
}
|
|
12
|
+
function parseScalarLiteral(scalar, ast, variables) {
|
|
13
|
+
return scalar.parseLiteral(ast, variables);
|
|
14
|
+
}
|
|
15
|
+
function serializeScalarValue(scalar, value) {
|
|
16
|
+
return scalar.serialize(value);
|
|
17
|
+
}
|
|
18
|
+
let Int64Scalar = class Int64Scalar {
|
|
19
|
+
description = GraphQLInt64.description;
|
|
20
|
+
parseValue(value) {
|
|
21
|
+
return parseScalarValue(GraphQLInt64, value);
|
|
22
|
+
}
|
|
23
|
+
serialize(value) {
|
|
24
|
+
return serializeScalarValue(GraphQLInt64, value);
|
|
25
|
+
}
|
|
26
|
+
parseLiteral(ast, variables) {
|
|
27
|
+
return parseScalarLiteral(GraphQLInt64, ast, variables);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
Int64Scalar = __decorate([
|
|
31
|
+
Scalar('Int64', () => BigInt)
|
|
32
|
+
], Int64Scalar);
|
|
33
|
+
export { Int64Scalar };
|
|
34
|
+
let BinaryScalar = class BinaryScalar {
|
|
35
|
+
description = GraphQLBinary.description;
|
|
36
|
+
parseValue(value) {
|
|
37
|
+
return parseScalarValue(GraphQLBinary, value);
|
|
38
|
+
}
|
|
39
|
+
serialize(value) {
|
|
40
|
+
return serializeScalarValue(GraphQLBinary, value);
|
|
41
|
+
}
|
|
42
|
+
parseLiteral(ast, variables) {
|
|
43
|
+
return parseScalarLiteral(GraphQLBinary, ast, variables);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
BinaryScalar = __decorate([
|
|
47
|
+
Scalar('Binary', () => Uint8Array)
|
|
48
|
+
], BinaryScalar);
|
|
49
|
+
export { BinaryScalar };
|
|
50
|
+
let InstantScalar = class InstantScalar {
|
|
51
|
+
description = GraphQLInstant.description;
|
|
52
|
+
parseValue(value) {
|
|
53
|
+
return parseScalarValue(GraphQLInstant, value);
|
|
54
|
+
}
|
|
55
|
+
serialize(value) {
|
|
56
|
+
return serializeScalarValue(GraphQLInstant, value);
|
|
57
|
+
}
|
|
58
|
+
parseLiteral(ast, variables) {
|
|
59
|
+
return parseScalarLiteral(GraphQLInstant, ast, variables);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
InstantScalar = __decorate([
|
|
63
|
+
Scalar('Instant', () => Temporal.Instant)
|
|
64
|
+
], InstantScalar);
|
|
65
|
+
export { InstantScalar };
|
|
66
|
+
let PlainDateScalar = class PlainDateScalar {
|
|
67
|
+
description = GraphQLPlainDate.description;
|
|
68
|
+
parseValue(value) {
|
|
69
|
+
return parseScalarValue(GraphQLPlainDate, value);
|
|
70
|
+
}
|
|
71
|
+
serialize(value) {
|
|
72
|
+
return serializeScalarValue(GraphQLPlainDate, value);
|
|
73
|
+
}
|
|
74
|
+
parseLiteral(ast, variables) {
|
|
75
|
+
return parseScalarLiteral(GraphQLPlainDate, ast, variables);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
PlainDateScalar = __decorate([
|
|
79
|
+
Scalar('PlainDate', () => Temporal.PlainDate)
|
|
80
|
+
], PlainDateScalar);
|
|
81
|
+
export { PlainDateScalar };
|
|
82
|
+
let PlainDateTimeScalar = class PlainDateTimeScalar {
|
|
83
|
+
description = GraphQLPlainDateTime.description;
|
|
84
|
+
parseValue(value) {
|
|
85
|
+
return parseScalarValue(GraphQLPlainDateTime, value);
|
|
86
|
+
}
|
|
87
|
+
serialize(value) {
|
|
88
|
+
return serializeScalarValue(GraphQLPlainDateTime, value);
|
|
89
|
+
}
|
|
90
|
+
parseLiteral(ast, variables) {
|
|
91
|
+
return parseScalarLiteral(GraphQLPlainDateTime, ast, variables);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
PlainDateTimeScalar = __decorate([
|
|
95
|
+
Scalar('PlainDateTime', () => Temporal.PlainDateTime)
|
|
96
|
+
], PlainDateTimeScalar);
|
|
97
|
+
export { PlainDateTimeScalar };
|
|
98
|
+
let PlainTimeScalar = class PlainTimeScalar {
|
|
99
|
+
description = GraphQLPlainTime.description;
|
|
100
|
+
parseValue(value) {
|
|
101
|
+
return parseScalarValue(GraphQLPlainTime, value);
|
|
102
|
+
}
|
|
103
|
+
serialize(value) {
|
|
104
|
+
return serializeScalarValue(GraphQLPlainTime, value);
|
|
105
|
+
}
|
|
106
|
+
parseLiteral(ast, variables) {
|
|
107
|
+
return parseScalarLiteral(GraphQLPlainTime, ast, variables);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
PlainTimeScalar = __decorate([
|
|
111
|
+
Scalar('PlainTime', () => Temporal.PlainTime)
|
|
112
|
+
], PlainTimeScalar);
|
|
113
|
+
export { PlainTimeScalar };
|
|
114
|
+
let ZonedDateTimeScalar = class ZonedDateTimeScalar {
|
|
115
|
+
description = GraphQLZonedDateTime.description;
|
|
116
|
+
parseValue(value) {
|
|
117
|
+
return parseScalarValue(GraphQLZonedDateTime, value);
|
|
118
|
+
}
|
|
119
|
+
serialize(value) {
|
|
120
|
+
return serializeScalarValue(GraphQLZonedDateTime, value);
|
|
121
|
+
}
|
|
122
|
+
parseLiteral(ast, variables) {
|
|
123
|
+
return parseScalarLiteral(GraphQLZonedDateTime, ast, variables);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
ZonedDateTimeScalar = __decorate([
|
|
127
|
+
Scalar('ZonedDateTime', () => Temporal.ZonedDateTime)
|
|
128
|
+
], ZonedDateTimeScalar);
|
|
129
|
+
export { ZonedDateTimeScalar };
|
|
130
|
+
let DurationScalar = class DurationScalar {
|
|
131
|
+
description = GraphQLDuration.description;
|
|
132
|
+
parseValue(value) {
|
|
133
|
+
return parseScalarValue(GraphQLDuration, value);
|
|
134
|
+
}
|
|
135
|
+
serialize(value) {
|
|
136
|
+
return serializeScalarValue(GraphQLDuration, value);
|
|
137
|
+
}
|
|
138
|
+
parseLiteral(ast, variables) {
|
|
139
|
+
return parseScalarLiteral(GraphQLDuration, ast, variables);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
DurationScalar = __decorate([
|
|
143
|
+
Scalar('Duration', () => Temporal.Duration)
|
|
144
|
+
], DurationScalar);
|
|
145
|
+
export { DurationScalar };
|
|
146
|
+
export const GRAPHQL_SCALAR_PROVIDERS = [
|
|
147
|
+
Int64Scalar,
|
|
148
|
+
BinaryScalar,
|
|
149
|
+
InstantScalar,
|
|
150
|
+
PlainDateScalar,
|
|
151
|
+
PlainDateTimeScalar,
|
|
152
|
+
PlainTimeScalar,
|
|
153
|
+
ZonedDateTimeScalar,
|
|
154
|
+
DurationScalar,
|
|
155
|
+
];
|
|
156
|
+
//# sourceMappingURL=scalars.providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalars.providers.js","sourceRoot":"","sources":["../src/scalars.providers.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAgB,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAKtD,SAAS,gBAAgB,CAAY,MAAyB,EAAE,KAAc;IAC5E,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAc,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAyB,EACzB,GAAc,EACd,SAA2B;IAE3B,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAc,CAAA;AACzD,CAAC;AAED,SAAS,oBAAoB,CAAY,MAAyB,EAAE,KAAgB;IAClF,OAA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AC,KAAc;QACvB,OAAO,gBAAgB,CAAoB,eAAe,EAAE,KAAK,CAAC,CAAA;IACpE,CAAC;IAED,SAAS,CAAC,KAAwB;QAChC,OAAO,oBAAoB,CAAC,eAAe,EAAE,KAAK,CAAW,CAAA;IAC/D,CAAC;IAED,YAAY,CAAC,GAAc,EAAE,SAA2B;QACtD,OAAO,kBAAkB,CAAoB,eAAe,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;IAC/E,CAAC;CACF,CAAA;AAdY,cAAc;IAD1B,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;GAC/B,cAAc,CAc1B;;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,WAAW;IACX,YAAY;IACZ,aAAa;IACb,eAAe;IACf,mBAAmB;IACnB,eAAe;IACf,mBAAmB;IACnB,cAAc;CACN,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GraphQLSchema } from 'graphql';
|
|
2
|
+
export declare const UDT_DIRECTIVE_DEFINITION = "\n directive @udt(name: String!) on INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION\n";
|
|
3
|
+
export declare function applyUdtDirective(schema: GraphQLSchema): GraphQLSchema;
|
|
4
|
+
//# sourceMappingURL=udt.directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"udt.directive.d.ts","sourceRoot":"","sources":["../src/udt.directive.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAA;AA+B9D,eAAO,MAAM,wBAAwB,wFAEpC,CAAA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CA8DtE"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { toEmail, toIpv4, toIpv6, toUrl, toUuid, } from '@thangnv-dev/data-common';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const { GraphQLError, GraphQLInputObjectType, GraphQLList, GraphQLNonNull, defaultFieldResolver, } = require('graphql');
|
|
6
|
+
const UDT_PARSERS = {
|
|
7
|
+
email: toEmail,
|
|
8
|
+
uuid: toUuid,
|
|
9
|
+
url: toUrl,
|
|
10
|
+
ipv4: toIpv4,
|
|
11
|
+
ipv6: toIpv6,
|
|
12
|
+
};
|
|
13
|
+
export const UDT_DIRECTIVE_DEFINITION = /* GraphQL */ `
|
|
14
|
+
directive @udt(name: String!) on INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
|
|
15
|
+
`;
|
|
16
|
+
export function applyUdtDirective(schema) {
|
|
17
|
+
const schemaWithInputFieldExtensions = mapSchema(schema, {
|
|
18
|
+
[MapperKind.INPUT_OBJECT_FIELD]: (fieldConfig, fieldName, typeName, currentSchema) => {
|
|
19
|
+
const directive = getDirective(currentSchema, fieldConfig, 'udt')?.[0];
|
|
20
|
+
if (!directive) {
|
|
21
|
+
return fieldConfig;
|
|
22
|
+
}
|
|
23
|
+
const name = resolveUdtName(directive.name, `${typeName}.${fieldName}`);
|
|
24
|
+
const parser = UDT_PARSERS[name];
|
|
25
|
+
return {
|
|
26
|
+
...fieldConfig,
|
|
27
|
+
extensions: {
|
|
28
|
+
...fieldConfig.extensions,
|
|
29
|
+
udtName: name,
|
|
30
|
+
udtParser: parser,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return mapSchema(schemaWithInputFieldExtensions, {
|
|
36
|
+
[MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName, currentSchema) => {
|
|
37
|
+
const sourceResolve = fieldConfig.resolve ?? defaultFieldResolver;
|
|
38
|
+
const argumentEntries = Object.entries(fieldConfig.args ?? {});
|
|
39
|
+
if (argumentEntries.length === 0) {
|
|
40
|
+
return fieldConfig;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...fieldConfig,
|
|
44
|
+
resolve: async (source, args, context, info) => {
|
|
45
|
+
const nextArgs = { ...args };
|
|
46
|
+
for (const [argumentName, argumentConfig] of argumentEntries) {
|
|
47
|
+
const argumentPath = `${typeName}.${fieldName}.${argumentName}`;
|
|
48
|
+
let value = nextArgs[argumentName];
|
|
49
|
+
if (value === undefined) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
value = validateInputValueWithUdt(argumentConfig.type, value, argumentPath);
|
|
53
|
+
const directive = getDirective(currentSchema, argumentConfig, 'udt')?.[0];
|
|
54
|
+
if (directive && value !== null) {
|
|
55
|
+
const udtName = resolveUdtName(directive.name, argumentPath);
|
|
56
|
+
value = parseWithUdt(udtName, value, argumentPath);
|
|
57
|
+
}
|
|
58
|
+
nextArgs[argumentName] = value;
|
|
59
|
+
}
|
|
60
|
+
return sourceResolve(source, nextArgs, context, info);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function validateInputValueWithUdt(inputType, value, path) {
|
|
67
|
+
if (value == null) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
if (inputType instanceof GraphQLNonNull) {
|
|
71
|
+
return validateInputValueWithUdt(inputType.ofType, value, path);
|
|
72
|
+
}
|
|
73
|
+
if (inputType instanceof GraphQLList) {
|
|
74
|
+
if (!Array.isArray(value)) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
return value.map((item, index) => validateInputValueWithUdt(inputType.ofType, item, `${path}[${index}]`));
|
|
78
|
+
}
|
|
79
|
+
if (inputType instanceof GraphQLInputObjectType) {
|
|
80
|
+
if (!isObjectLike(value)) {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
const output = { ...value };
|
|
84
|
+
const fields = inputType.getFields();
|
|
85
|
+
for (const [fieldName, field] of Object.entries(fields)) {
|
|
86
|
+
if (!(fieldName in output)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const fieldPath = `${path}.${fieldName}`;
|
|
90
|
+
let nextValue = validateInputValueWithUdt(field.type, output[fieldName], fieldPath);
|
|
91
|
+
const extension = (field.extensions ?? {});
|
|
92
|
+
if (extension.udtName && extension.udtParser && nextValue !== null && nextValue !== undefined) {
|
|
93
|
+
nextValue = parseWithUdt(extension.udtName, nextValue, fieldPath);
|
|
94
|
+
}
|
|
95
|
+
output[fieldName] = nextValue;
|
|
96
|
+
}
|
|
97
|
+
return output;
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
function resolveUdtName(rawName, location) {
|
|
102
|
+
if (typeof rawName !== 'string') {
|
|
103
|
+
throw new Error(`@udt directive at ${location} requires a string "name" argument.`);
|
|
104
|
+
}
|
|
105
|
+
const normalizedName = rawName.trim().toLowerCase();
|
|
106
|
+
if (!(normalizedName in UDT_PARSERS)) {
|
|
107
|
+
const supported = Object.keys(UDT_PARSERS).join(', ');
|
|
108
|
+
throw new Error(`Unsupported @udt("${rawName}") at ${location}. Supported values: ${supported}.`);
|
|
109
|
+
}
|
|
110
|
+
return normalizedName;
|
|
111
|
+
}
|
|
112
|
+
function parseWithUdt(name, value, path) {
|
|
113
|
+
const parser = UDT_PARSERS[name];
|
|
114
|
+
try {
|
|
115
|
+
return parser(value);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const detail = error instanceof Error ? error.message : 'invalid value';
|
|
119
|
+
throw new GraphQLError(`Invalid input at ${path} for @udt("${name}"): ${detail}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function isObjectLike(value) {
|
|
123
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=udt.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"udt.directive.js","sourceRoot":"","sources":["../src/udt.directive.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OAAO,cAAc,CAAA;AACvB,CAAC;AAED,SAAS,YAAY,CAAC,IAAa,EAAE,KAAc,EAAE,IAAY;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;QACvE,MAAM,IAAI,YAAY,CAAC,oBAAoB,IAAI,cAAc,IAAI,OAAO,MAAM,EAAE,CAAC,CAAA;IACnF,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thangnv-dev/graphql-nest",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"test": "vitest run"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@apollo/subgraph": "^2.11.3",
|
|
28
|
+
"@graphql-tools/utils": "^11.0.0",
|
|
29
|
+
"@nestjs/apollo": "^13.2.4",
|
|
30
|
+
"@nestjs/config": "^4.0.3",
|
|
31
|
+
"@nestjs/graphql": "^13.2.4",
|
|
32
|
+
"@thangnv-dev/data-common": "workspace:^",
|
|
33
|
+
"@thangnv-dev/data-nest": "workspace:^",
|
|
34
|
+
"@thangnv-dev/graphql-common": "workspace:^",
|
|
35
|
+
"graphql": "^16.12.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@nestjs/common": "^11.1.14",
|
|
39
|
+
"@nestjs/core": "^11.1.14",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
41
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
42
|
+
"eslint": "^10.0.0",
|
|
43
|
+
"reflect-metadata": "^0.2.2",
|
|
44
|
+
"rxjs": "^7.8.2",
|
|
45
|
+
"temporal-polyfill": "^0.3.0",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "^4.0.18"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@nestjs/apollo": "^13.0.0",
|
|
51
|
+
"@nestjs/common": "^11.0.0",
|
|
52
|
+
"@nestjs/config": "^4.0.0",
|
|
53
|
+
"@nestjs/core": "^11.0.0",
|
|
54
|
+
"@nestjs/graphql": "^13.0.0",
|
|
55
|
+
"graphql": "^16.0.0",
|
|
56
|
+
"reflect-metadata": "^0.2.0",
|
|
57
|
+
"rxjs": "^7.8.0",
|
|
58
|
+
"temporal-polyfill": "*"
|
|
59
|
+
}
|
|
60
|
+
}
|