@gqloom/core 0.10.1 → 0.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/chunk-Cl8Af3a2.js +11 -0
- package/dist/context-3UlS1xGQ.cjs +417 -0
- package/dist/context-CpbCknos.js +305 -0
- package/dist/context.cjs +236 -437
- package/dist/context.d.cts +114 -111
- package/dist/context.d.ts +114 -111
- package/dist/context.js +224 -219
- package/dist/index-DUqXX1Tm.d.cts +1255 -0
- package/dist/index-GSWAHvDy.d.ts +1253 -0
- package/dist/index.cjs +1694 -2019
- package/dist/index.d.cts +2 -484
- package/dist/index.d.ts +2 -484
- package/dist/index.js +1618 -1780
- package/package.json +11 -11
- package/dist/chunk-JWAIAFGL.js +0 -220
- package/dist/context-ljWuL8VA.d.cts +0 -772
- package/dist/context-ljWuL8VA.d.ts +0 -772
package/dist/index.js
CHANGED
|
@@ -1,1915 +1,1753 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
FIELD_HIDDEN,
|
|
4
|
-
GET_GRAPHQL_TYPE,
|
|
5
|
-
IS_RESOLVER,
|
|
6
|
-
WEAVER_CONFIG,
|
|
7
|
-
assignContextMap,
|
|
8
|
-
getMemoizationMap,
|
|
9
|
-
getResolvingFields,
|
|
10
|
-
isOnlyMemoryPayload,
|
|
11
|
-
onlyMemoization,
|
|
12
|
-
parseResolvingFields,
|
|
13
|
-
symbols_exports
|
|
14
|
-
} from "./chunk-JWAIAFGL.js";
|
|
1
|
+
import { DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports } from "./context-CpbCknos.js";
|
|
2
|
+
import { GraphQLError, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLUnionType, assertName, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, resolveObjMapThunk } from "graphql";
|
|
15
3
|
|
|
16
|
-
|
|
4
|
+
//#region src/utils/args.ts
|
|
17
5
|
function getOperationOptions(resolveOrOptions) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return resolveOrOptions;
|
|
6
|
+
if (typeof resolveOrOptions === "function") return { resolve: resolveOrOptions };
|
|
7
|
+
return resolveOrOptions;
|
|
22
8
|
}
|
|
23
9
|
function getSubscriptionOptions(subscribeOrOptions) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return subscribeOrOptions;
|
|
10
|
+
if (typeof subscribeOrOptions === "function") return { subscribe: subscribeOrOptions };
|
|
11
|
+
return subscribeOrOptions;
|
|
28
12
|
}
|
|
29
13
|
function getFieldOptions({ description, deprecationReason, extensions }, extraExtensions) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
return {
|
|
15
|
+
description,
|
|
16
|
+
deprecationReason,
|
|
17
|
+
extensions: extraExtensions ? {
|
|
18
|
+
...extensions,
|
|
19
|
+
...extraExtensions
|
|
20
|
+
} : extensions
|
|
21
|
+
};
|
|
35
22
|
}
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/utils/middleware.ts
|
|
26
|
+
const defaultOperations = [
|
|
27
|
+
"field",
|
|
28
|
+
"mutation",
|
|
29
|
+
"query",
|
|
30
|
+
"subscription.subscribe"
|
|
43
31
|
];
|
|
44
32
|
function applyMiddlewares(options, resolveFunction, middlewares) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
return next(0);
|
|
33
|
+
const next = (index) => {
|
|
34
|
+
if (index >= middlewares.length) return resolveFunction();
|
|
35
|
+
const middleware = middlewares[index];
|
|
36
|
+
const callableOptions = Object.assign(() => next(index + 1), {
|
|
37
|
+
...options,
|
|
38
|
+
next: () => next(index + 1)
|
|
39
|
+
});
|
|
40
|
+
return middleware(callableOptions);
|
|
41
|
+
};
|
|
42
|
+
return next(0);
|
|
57
43
|
}
|
|
58
44
|
function filterMiddlewares(operation, ...middlewareList) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return acc;
|
|
68
|
-
}, []);
|
|
45
|
+
return middlewareList.reduce((acc, m) => {
|
|
46
|
+
if (!m) return acc;
|
|
47
|
+
acc.push(...ensureArray(m).filter((m$1) => {
|
|
48
|
+
const ops = m$1.operations ?? defaultOperations;
|
|
49
|
+
return ops.includes(operation);
|
|
50
|
+
}));
|
|
51
|
+
return acc;
|
|
52
|
+
}, []);
|
|
69
53
|
}
|
|
70
54
|
function ensureArray(value) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return [value];
|
|
55
|
+
if (value != null && typeof value === "object" && Symbol.iterator in value) return Array.from(value);
|
|
56
|
+
return [value];
|
|
75
57
|
}
|
|
76
58
|
|
|
77
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/utils/object.ts
|
|
61
|
+
/**
|
|
62
|
+
* Creates an object map with the same keys as `map` and values generated by
|
|
63
|
+
* running each value of `record` thru `fn`.
|
|
64
|
+
*/
|
|
78
65
|
function mapValue(record, fn) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
const result = Object.create(null);
|
|
67
|
+
for (const key of Object.keys(record)) {
|
|
68
|
+
const value = fn(record[key], key);
|
|
69
|
+
if (value === SKIP) continue;
|
|
70
|
+
result[key] = value;
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
86
73
|
}
|
|
87
|
-
|
|
74
|
+
const SKIP = Symbol.for("mapValue.skip");
|
|
88
75
|
mapValue.SKIP = SKIP;
|
|
89
76
|
function toObjMap(obj) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const map = /* @__PURE__ */ Object.create(null);
|
|
97
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
98
|
-
map[key] = value;
|
|
99
|
-
}
|
|
100
|
-
return map;
|
|
77
|
+
if (obj == null) return Object.create(null);
|
|
78
|
+
if (Object.getPrototypeOf(obj) === null) return obj;
|
|
79
|
+
const map = Object.create(null);
|
|
80
|
+
for (const [key, value] of Object.entries(obj)) map[key] = value;
|
|
81
|
+
return map;
|
|
101
82
|
}
|
|
102
83
|
function notNullish(x) {
|
|
103
|
-
|
|
84
|
+
return x != null;
|
|
104
85
|
}
|
|
105
86
|
function deepMerge(...objects) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} else {
|
|
117
|
-
result[key] = deepMerge(result[key], value);
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
result[key] = value;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return result;
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const obj of objects) {
|
|
89
|
+
if (obj == null) continue;
|
|
90
|
+
for (const [key, value] of Object.entries(obj)) if (value !== null && typeof value === "object") if (Array.isArray(value)) {
|
|
91
|
+
if (!Array.isArray(result[key])) result[key] = [];
|
|
92
|
+
result[key] = [...result[key], ...value];
|
|
93
|
+
} else result[key] = deepMerge(result[key], value);
|
|
94
|
+
else result[key] = value;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
125
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Wraps the provided data in an object with a single key `"~meta"`.
|
|
100
|
+
*
|
|
101
|
+
* @template T - The type of the data to be wrapped.
|
|
102
|
+
* @param {T} data - The data to be wrapped.
|
|
103
|
+
* @returns {{ "~meta": T }} - An object with a single key `"~meta"` containing the provided data.
|
|
104
|
+
* @example
|
|
105
|
+
* const originalData = { key: "value" };
|
|
106
|
+
* const metaData = meta(originalData);
|
|
107
|
+
* console.log(metaData); // Output: { "~meta": { key: "value" } }
|
|
108
|
+
*/
|
|
126
109
|
function meta(data) {
|
|
127
|
-
|
|
110
|
+
return { "~meta": data };
|
|
128
111
|
}
|
|
129
112
|
|
|
130
|
-
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/utils/string.ts
|
|
131
115
|
function pascalCase(str) {
|
|
132
|
-
|
|
133
|
-
(word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
|
|
134
|
-
).join("");
|
|
116
|
+
return str.split(/[\s-_]+/).map((word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
135
117
|
}
|
|
136
118
|
function capitalize(str) {
|
|
137
|
-
|
|
119
|
+
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
138
120
|
}
|
|
139
121
|
function screamingSnakeCase(str) {
|
|
140
|
-
|
|
122
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").split(/[\s-_]+/).map((word) => word.toUpperCase()).join("_");
|
|
141
123
|
}
|
|
142
124
|
|
|
143
|
-
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/utils/error.ts
|
|
144
127
|
function markErrorLocation(error, ...locations) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
return error;
|
|
128
|
+
if (error instanceof Error) error.message = markLocation(error.message, ...locations);
|
|
129
|
+
return error;
|
|
149
130
|
}
|
|
150
131
|
function tryIn(func, ...locations) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
132
|
+
try {
|
|
133
|
+
return func();
|
|
134
|
+
} catch (error) {
|
|
135
|
+
throw markErrorLocation(error, ...locations);
|
|
136
|
+
}
|
|
156
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* mark message with location
|
|
140
|
+
* @param message origin message
|
|
141
|
+
* @param locations where error happened
|
|
142
|
+
* @returns message with location
|
|
143
|
+
* @example markLocation("error", "banana") // "[banana] hello"
|
|
144
|
+
* @example markLocation("error", fruit, banana) // "[fruit.banana] error"
|
|
145
|
+
* @example markLocation("[banana] error", "fruit") // "[fruit.banana] error"
|
|
146
|
+
* @example markLocation("[fruit.banana] error", "favorite") // "[favorite.fruit.banana] error"
|
|
147
|
+
*/
|
|
157
148
|
function markLocation(message, ...locations) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
|
|
168
|
-
return `[${combinedLocation}] ${newMessage}`;
|
|
149
|
+
if (locations.length === 0) return message;
|
|
150
|
+
const [existingPrefix, newMessage] = (() => {
|
|
151
|
+
const existingPrefixPattern = /^\[(.*?)\]/;
|
|
152
|
+
const match = existingPrefixPattern.exec(message);
|
|
153
|
+
if (match) return [match[1], message.slice(match[0].length).trim()];
|
|
154
|
+
return [void 0, message];
|
|
155
|
+
})();
|
|
156
|
+
const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
|
|
157
|
+
return `[${combinedLocation}] ${newMessage}`;
|
|
169
158
|
}
|
|
170
159
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/utils/loader.ts
|
|
162
|
+
/**
|
|
163
|
+
* GraphQL Loom built-in data loader.
|
|
164
|
+
*/
|
|
165
|
+
var LoomDataLoader = class LoomDataLoader {
|
|
166
|
+
results;
|
|
167
|
+
resolvers;
|
|
168
|
+
constructor() {
|
|
169
|
+
this.results = /* @__PURE__ */ new Map();
|
|
170
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Load data for a given key.
|
|
174
|
+
* @param key - The key to load data for.
|
|
175
|
+
* @returns A promise that resolves to the loaded data.
|
|
176
|
+
*/
|
|
177
|
+
load(key) {
|
|
178
|
+
const existing = this.results.get(key);
|
|
179
|
+
if (existing) return existing;
|
|
180
|
+
const promise = new Promise((resolve, reject) => {
|
|
181
|
+
this.resolvers.set(key, [resolve, reject]);
|
|
182
|
+
this.nextTickBatchLoad();
|
|
183
|
+
});
|
|
184
|
+
this.results.set(key, promise);
|
|
185
|
+
return promise;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Clear the cache and reset the loader.
|
|
189
|
+
*/
|
|
190
|
+
clear() {
|
|
191
|
+
this.results = /* @__PURE__ */ new Map();
|
|
192
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
193
|
+
}
|
|
194
|
+
async executeBatchLoad() {
|
|
195
|
+
if (this.resolvers.size === 0) return;
|
|
196
|
+
const resolvers = this.resolvers;
|
|
197
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
198
|
+
const keys = Array.from(resolvers.keys());
|
|
199
|
+
try {
|
|
200
|
+
const list = await this.batchLoad(keys);
|
|
201
|
+
for (let i = 0; i < list.length; i++) {
|
|
202
|
+
const data = list[i];
|
|
203
|
+
const [resolve, reject] = resolvers.get(keys[i]) ?? [];
|
|
204
|
+
if (data instanceof Error) reject?.(data);
|
|
205
|
+
else resolve?.(data);
|
|
206
|
+
}
|
|
207
|
+
} catch (error) {
|
|
208
|
+
for (const key of keys) {
|
|
209
|
+
const reject = resolvers.get(key)?.[1];
|
|
210
|
+
reject?.(error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
nextTickPromise;
|
|
215
|
+
nextTickBatchLoad() {
|
|
216
|
+
const load = async () => {
|
|
217
|
+
try {
|
|
218
|
+
while (this.resolvers.size > 0) {
|
|
219
|
+
await LoomDataLoader.nextTick();
|
|
220
|
+
await this.executeBatchLoad();
|
|
221
|
+
}
|
|
222
|
+
} finally {
|
|
223
|
+
this.nextTickPromise = void 0;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
this.nextTickPromise ??= load();
|
|
227
|
+
return this.nextTickPromise;
|
|
228
|
+
}
|
|
229
|
+
static nextTick() {
|
|
230
|
+
return new Promise((resolve) => setTimeout(resolve));
|
|
231
|
+
}
|
|
242
232
|
};
|
|
243
233
|
var EasyDataLoader = class extends LoomDataLoader {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
234
|
+
batchLoad(keys) {
|
|
235
|
+
return this.batchLoadFn(keys);
|
|
236
|
+
}
|
|
237
|
+
constructor(batchLoadFn) {
|
|
238
|
+
super();
|
|
239
|
+
this.batchLoadFn = batchLoadFn;
|
|
240
|
+
}
|
|
251
241
|
};
|
|
252
242
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
} from "graphql";
|
|
258
|
-
|
|
259
|
-
// src/schema/weaver-context.ts
|
|
260
|
-
import {
|
|
261
|
-
isEnumType,
|
|
262
|
-
isObjectType,
|
|
263
|
-
isScalarType,
|
|
264
|
-
isUnionType
|
|
265
|
-
} from "graphql";
|
|
266
|
-
var ref;
|
|
267
|
-
var names = /* @__PURE__ */ new WeakMap();
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/schema/weaver-context.ts
|
|
245
|
+
let ref;
|
|
246
|
+
const names = /* @__PURE__ */ new WeakMap();
|
|
268
247
|
function initWeaverContext() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
vendorWeavers: /* @__PURE__ */ new Map()
|
|
299
|
-
};
|
|
248
|
+
return {
|
|
249
|
+
id: initWeaverContext.increasingID++,
|
|
250
|
+
loomObjectMap: /* @__PURE__ */ new Map(),
|
|
251
|
+
loomUnionMap: /* @__PURE__ */ new Map(),
|
|
252
|
+
inputMap: /* @__PURE__ */ new Map(),
|
|
253
|
+
interfaceMap: /* @__PURE__ */ new Map(),
|
|
254
|
+
configs: /* @__PURE__ */ new Map(),
|
|
255
|
+
getConfig(key) {
|
|
256
|
+
return this.configs.get(key);
|
|
257
|
+
},
|
|
258
|
+
setConfig(config) {
|
|
259
|
+
const key = config[WEAVER_CONFIG];
|
|
260
|
+
this.configs.set(key, config);
|
|
261
|
+
},
|
|
262
|
+
deleteConfig(key) {
|
|
263
|
+
this.configs.delete(key);
|
|
264
|
+
},
|
|
265
|
+
names,
|
|
266
|
+
namedTypes: /* @__PURE__ */ new Map(),
|
|
267
|
+
memoNamedType(gqlTypeValue) {
|
|
268
|
+
const gqlType = gqlTypeValue;
|
|
269
|
+
if (isObjectType(gqlType) || isUnionType(gqlType) || isEnumType(gqlType) || isScalarType(gqlType)) this.namedTypes.set(gqlType.name, gqlType);
|
|
270
|
+
return gqlTypeValue;
|
|
271
|
+
},
|
|
272
|
+
getNamedType(name) {
|
|
273
|
+
return this.namedTypes.get(name);
|
|
274
|
+
},
|
|
275
|
+
vendorWeavers: /* @__PURE__ */ new Map()
|
|
276
|
+
};
|
|
300
277
|
}
|
|
301
278
|
initWeaverContext.increasingID = 1;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
279
|
+
const weaverContext = {
|
|
280
|
+
get id() {
|
|
281
|
+
return ref?.id;
|
|
282
|
+
},
|
|
283
|
+
get loomObjectMap() {
|
|
284
|
+
return ref?.loomObjectMap;
|
|
285
|
+
},
|
|
286
|
+
get loomUnionMap() {
|
|
287
|
+
return ref?.loomUnionMap;
|
|
288
|
+
},
|
|
289
|
+
get inputMap() {
|
|
290
|
+
return ref?.inputMap;
|
|
291
|
+
},
|
|
292
|
+
get interfaceMap() {
|
|
293
|
+
return ref?.interfaceMap;
|
|
294
|
+
},
|
|
295
|
+
get configs() {
|
|
296
|
+
return ref?.configs;
|
|
297
|
+
},
|
|
298
|
+
get vendorWeavers() {
|
|
299
|
+
return ref?.vendorWeavers;
|
|
300
|
+
},
|
|
301
|
+
getConfig(key) {
|
|
302
|
+
return ref?.getConfig(key);
|
|
303
|
+
},
|
|
304
|
+
setConfig(config) {
|
|
305
|
+
ref?.setConfig(config);
|
|
306
|
+
},
|
|
307
|
+
deleteConfig(key) {
|
|
308
|
+
ref?.deleteConfig(key);
|
|
309
|
+
},
|
|
310
|
+
get value() {
|
|
311
|
+
return ref;
|
|
312
|
+
},
|
|
313
|
+
useConfig(config, callback) {
|
|
314
|
+
const context = weaverContext.value ?? initWeaverContext();
|
|
315
|
+
context.setConfig(config);
|
|
316
|
+
const result = provideWeaverContext(callback, context);
|
|
317
|
+
context.deleteConfig(config[WEAVER_CONFIG]);
|
|
318
|
+
return result;
|
|
319
|
+
},
|
|
320
|
+
names,
|
|
321
|
+
getNamedType(name) {
|
|
322
|
+
return ref?.getNamedType(name);
|
|
323
|
+
},
|
|
324
|
+
memoNamedType(gqlType) {
|
|
325
|
+
return ref?.memoNamedType(gqlType) ?? gqlType;
|
|
326
|
+
},
|
|
327
|
+
GraphQLTypes: /* @__PURE__ */ new WeakMap(),
|
|
328
|
+
getGraphQLType(origin) {
|
|
329
|
+
return this.GraphQLTypes.get(origin);
|
|
330
|
+
},
|
|
331
|
+
memoGraphQLType(origin, gqlType) {
|
|
332
|
+
this.GraphQLTypes.set(origin, gqlType);
|
|
333
|
+
return gqlType;
|
|
334
|
+
}
|
|
358
335
|
};
|
|
359
336
|
function provideWeaverContext(func, value) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
337
|
+
const lastRef = ref;
|
|
338
|
+
ref = value;
|
|
339
|
+
try {
|
|
340
|
+
return func();
|
|
341
|
+
} finally {
|
|
342
|
+
ref = lastRef;
|
|
343
|
+
}
|
|
367
344
|
}
|
|
368
345
|
provideWeaverContext.inherit = (func) => {
|
|
369
|
-
|
|
370
|
-
|
|
346
|
+
const weaverContextRef = weaverContext.value;
|
|
347
|
+
return () => provideWeaverContext(func, weaverContextRef);
|
|
371
348
|
};
|
|
349
|
+
/**
|
|
350
|
+
* collect names for schemas
|
|
351
|
+
* @param namesList - names to collect
|
|
352
|
+
* @returns namesRecord
|
|
353
|
+
*/
|
|
372
354
|
function collectNames(...namesList) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
return namesRecord;
|
|
355
|
+
const namesRecord = {};
|
|
356
|
+
for (const namesItem of namesList) for (const [name, schema] of Object.entries(namesItem)) {
|
|
357
|
+
names.set(schema, name);
|
|
358
|
+
namesRecord[name] = schema;
|
|
359
|
+
}
|
|
360
|
+
return namesRecord;
|
|
381
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* collect name for schema
|
|
364
|
+
* @param name - name for
|
|
365
|
+
* @param schema - schema to be named
|
|
366
|
+
* @returns schema
|
|
367
|
+
*/
|
|
382
368
|
function collectName(name, schema) {
|
|
383
|
-
|
|
384
|
-
|
|
369
|
+
names.set(schema, name);
|
|
370
|
+
return schema;
|
|
385
371
|
}
|
|
386
372
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
};
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/resolver/silk.ts
|
|
375
|
+
function silk(type, validate = (value) => ({ value: value ?? void 0 })) {
|
|
376
|
+
return {
|
|
377
|
+
[GET_GRAPHQL_TYPE]: typeof type === "function" ? type : () => type,
|
|
378
|
+
"~standard": {
|
|
379
|
+
version: 1,
|
|
380
|
+
vendor: "gqloom.silk",
|
|
381
|
+
validate
|
|
382
|
+
}
|
|
383
|
+
};
|
|
399
384
|
}
|
|
400
385
|
silk.parse = parseSilk;
|
|
401
386
|
silk.getType = getGraphQLType;
|
|
402
387
|
silk.nonNull = nonNullSilk;
|
|
403
388
|
silk.list = listSilk;
|
|
404
389
|
silk.nullable = nullableSilk;
|
|
390
|
+
/**
|
|
391
|
+
* Non-nullable Silk.
|
|
392
|
+
*/
|
|
405
393
|
function nonNullSilk(origin) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
};
|
|
394
|
+
return {
|
|
395
|
+
...origin,
|
|
396
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
397
|
+
const originType = getGraphQLType(origin);
|
|
398
|
+
if (originType instanceof GraphQLNonNull) return originType;
|
|
399
|
+
else return new GraphQLNonNull(originType);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
417
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* List Silk.
|
|
405
|
+
*/
|
|
418
406
|
function listSilk(origin) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
return new GraphQLNonNull(new GraphQLList(originType));
|
|
430
|
-
}
|
|
431
|
-
};
|
|
407
|
+
return {
|
|
408
|
+
...origin,
|
|
409
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
410
|
+
let originType = getGraphQLType(origin);
|
|
411
|
+
if (originType instanceof GraphQLNonNull && originType.ofType instanceof GraphQLList) originType = originType.ofType.ofType;
|
|
412
|
+
if (originType instanceof GraphQLList) originType = originType.ofType;
|
|
413
|
+
return new GraphQLNonNull(new GraphQLList(originType));
|
|
414
|
+
}
|
|
415
|
+
};
|
|
432
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Nullable Silk.
|
|
419
|
+
*/
|
|
433
420
|
function nullableSilk(origin) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
421
|
+
return {
|
|
422
|
+
...origin,
|
|
423
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
424
|
+
const originType = getGraphQLType(origin);
|
|
425
|
+
if (originType instanceof GraphQLNonNull) return originType.ofType;
|
|
426
|
+
else return originType;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
445
429
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Get GraphQL Output Type from Silk.
|
|
432
|
+
* @param silk GraphQL Silk
|
|
433
|
+
* @returns GraphQL Output Type
|
|
434
|
+
*/
|
|
435
|
+
function getGraphQLType(silk$1) {
|
|
436
|
+
if (GET_GRAPHQL_TYPE in silk$1 && silk$1[GET_GRAPHQL_TYPE] != null) return silk$1[GET_GRAPHQL_TYPE]();
|
|
437
|
+
const vendorWeavers = weaverContext.vendorWeavers;
|
|
438
|
+
if (vendorWeavers == null) throw new Error("Schema Weaver is not initialized");
|
|
439
|
+
const weaver = vendorWeavers.get(silk$1["~standard"].vendor);
|
|
440
|
+
if (weaver == null) throw new Error(`Schema Weaver for ${silk$1["~standard"].vendor} is not found`);
|
|
441
|
+
return weaver.getGraphQLType(silk$1);
|
|
457
442
|
}
|
|
458
|
-
|
|
459
|
-
|
|
443
|
+
/**
|
|
444
|
+
* Validate and transform input to output
|
|
445
|
+
* @param silk silk GraphQL Silk
|
|
446
|
+
* @param input
|
|
447
|
+
* @returns output
|
|
448
|
+
*/
|
|
449
|
+
function parseSilk(silk$1, input) {
|
|
450
|
+
return silk$1["~standard"].validate(input);
|
|
460
451
|
}
|
|
461
452
|
function isSilk(target) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
453
|
+
if (typeof target !== "object") return false;
|
|
454
|
+
if (target == null) return false;
|
|
455
|
+
if (GET_GRAPHQL_TYPE in target) return true;
|
|
456
|
+
if (!("~standard" in target)) return false;
|
|
457
|
+
return "vendor" in target["~standard"] && typeof target["~standard"].vendor === "string" && "version" in target["~standard"] && typeof target["~standard"].version === "number";
|
|
467
458
|
}
|
|
468
459
|
|
|
469
|
-
|
|
470
|
-
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/resolver/input.ts
|
|
471
462
|
function createInputParser(schema, value) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
value: () => result = void 0
|
|
491
|
-
});
|
|
492
|
-
return parse;
|
|
463
|
+
let result;
|
|
464
|
+
const parse = async () => {
|
|
465
|
+
if (result !== void 0) return result;
|
|
466
|
+
result = await parseInputValue(schema, value);
|
|
467
|
+
return result;
|
|
468
|
+
};
|
|
469
|
+
Object.assign(parse, {
|
|
470
|
+
schema,
|
|
471
|
+
value
|
|
472
|
+
});
|
|
473
|
+
Object.defineProperty(parse, "result", {
|
|
474
|
+
get: () => result,
|
|
475
|
+
set: (value$1) => result = value$1
|
|
476
|
+
});
|
|
477
|
+
Object.defineProperty(parse, "getResult", { value: async () => getStandardValue(await parse()) });
|
|
478
|
+
Object.defineProperty(parse, "setResult", { value: (value$1) => result = { value: value$1 } });
|
|
479
|
+
Object.defineProperty(parse, "clearResult", { value: () => result = void 0 });
|
|
480
|
+
return parse;
|
|
493
481
|
}
|
|
494
482
|
function parseInputValue(inputSchema, input) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (isSilk(inputSchema)) {
|
|
499
|
-
return inputSchema["~standard"].validate(input);
|
|
500
|
-
}
|
|
501
|
-
return parseInputEntries(inputSchema, input);
|
|
483
|
+
if (inputSchema === void 0) return { value: input };
|
|
484
|
+
if (isSilk(inputSchema)) return inputSchema["~standard"].validate(input);
|
|
485
|
+
return parseInputEntries(inputSchema, input);
|
|
502
486
|
}
|
|
503
487
|
async function parseInputEntries(inputSchema, input = {}) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
})
|
|
516
|
-
);
|
|
517
|
-
return { value: result, ...issues.length > 0 ? { issues } : null };
|
|
488
|
+
const result = {};
|
|
489
|
+
const issues = [];
|
|
490
|
+
await Promise.all(Object.entries(inputSchema).map(async ([key, value]) => {
|
|
491
|
+
const res = await value["~standard"].validate(input[key]);
|
|
492
|
+
if ("value" in res) result[key] = res.value;
|
|
493
|
+
if (res.issues) issues.push(...res.issues.slice());
|
|
494
|
+
}));
|
|
495
|
+
return {
|
|
496
|
+
value: result,
|
|
497
|
+
...issues.length > 0 ? { issues } : null
|
|
498
|
+
};
|
|
518
499
|
}
|
|
519
500
|
function getStandardValue(result) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
if ("value" in result) return result.value;
|
|
528
|
-
else throw new GraphQLError("Invalid input");
|
|
501
|
+
if (result == null) return result;
|
|
502
|
+
const { issues } = result;
|
|
503
|
+
if (issues?.length) throw new GraphQLError(issues?.[0]?.message ?? "Invalid input", { extensions: { issues } });
|
|
504
|
+
if ("value" in result) return result.value;
|
|
505
|
+
else throw new GraphQLError("Invalid input");
|
|
529
506
|
}
|
|
530
507
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/resolver/resolver-chain-factory.ts
|
|
510
|
+
/**
|
|
511
|
+
* Base class for all chain factories
|
|
512
|
+
* @template TField - The type of field being created
|
|
513
|
+
*/
|
|
514
|
+
var BaseChainFactory = class BaseChainFactory {
|
|
515
|
+
/**
|
|
516
|
+
* Returns the available methods for the chain factory
|
|
517
|
+
*/
|
|
518
|
+
static methods() {
|
|
519
|
+
return {
|
|
520
|
+
description: BaseChainFactory.prototype.description,
|
|
521
|
+
deprecationReason: BaseChainFactory.prototype.deprecationReason,
|
|
522
|
+
extensions: BaseChainFactory.prototype.extensions
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Creates a new instance of the chain factory
|
|
527
|
+
* @param options - Configuration options for the factory
|
|
528
|
+
*/
|
|
529
|
+
constructor(options) {
|
|
530
|
+
this.options = options;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Sets the description for the field
|
|
534
|
+
* @param description - The description text
|
|
535
|
+
*/
|
|
536
|
+
description(description) {
|
|
537
|
+
return this.clone({ description });
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Sets the deprecation reason for the field
|
|
541
|
+
* @param deprecationReason - The reason for deprecation
|
|
542
|
+
*/
|
|
543
|
+
deprecationReason(deprecationReason) {
|
|
544
|
+
return this.clone({ deprecationReason });
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Sets custom extensions for the field
|
|
548
|
+
* @param extensions - Custom extensions to add
|
|
549
|
+
*/
|
|
550
|
+
extensions(extensions) {
|
|
551
|
+
return this.clone({ extensions });
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Adds middleware functions to the field
|
|
555
|
+
* @param middlewares - Middleware functions to add
|
|
556
|
+
*/
|
|
557
|
+
use(...middlewares) {
|
|
558
|
+
return this.clone({ middlewares: [...this.options?.middlewares ?? [], ...middlewares] });
|
|
559
|
+
}
|
|
580
560
|
};
|
|
581
|
-
var FieldLoader = class
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
561
|
+
var FieldLoader = class FieldLoader extends LoomDataLoader {
|
|
562
|
+
static getByPath(payload, resolve, getByPath = true) {
|
|
563
|
+
if (!payload) return new FieldLoader(resolve);
|
|
564
|
+
const memoMap = getMemoizationMap(payload);
|
|
565
|
+
if (!getByPath) {
|
|
566
|
+
const loader = memoMap.get(resolve) ?? new FieldLoader(resolve);
|
|
567
|
+
memoMap.set(resolve, loader);
|
|
568
|
+
return loader;
|
|
569
|
+
}
|
|
570
|
+
const fullPath = [];
|
|
571
|
+
let path = payload.info.path;
|
|
572
|
+
while (path) {
|
|
573
|
+
fullPath.push(path);
|
|
574
|
+
path = path.prev;
|
|
575
|
+
}
|
|
576
|
+
const pathKey = fullPath.reverse().map((p) => typeof p.key === "number" ? "[n]" : p.key).join(".");
|
|
577
|
+
const fieldLoaders = memoMap.get(resolve) ?? /* @__PURE__ */ new Map();
|
|
578
|
+
memoMap.set(resolve, fieldLoaders);
|
|
579
|
+
const fieldLoader = fieldLoaders.get(pathKey) ?? new FieldLoader(resolve);
|
|
580
|
+
fieldLoaders.set(pathKey, fieldLoader);
|
|
581
|
+
return fieldLoader;
|
|
582
|
+
}
|
|
583
|
+
constructor(resolve) {
|
|
584
|
+
super();
|
|
585
|
+
this.resolve = resolve;
|
|
586
|
+
}
|
|
587
|
+
batchLoad(args) {
|
|
588
|
+
const parents = args.map(([parent]) => parent);
|
|
589
|
+
const payloads = args.map(([, , payload]) => payload);
|
|
590
|
+
return this.resolve(parents, args[0]?.[1], payloads);
|
|
591
|
+
}
|
|
612
592
|
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Factory for creating field resolvers with chainable configuration
|
|
595
|
+
* @template TOutput - The output type of the field
|
|
596
|
+
* @template TInput - The input type of the field
|
|
597
|
+
* @template TDependencies - The dependencies of the field
|
|
598
|
+
*/
|
|
599
|
+
var FieldChainFactory = class FieldChainFactory extends BaseChainFactory {
|
|
600
|
+
/**
|
|
601
|
+
* Returns the available methods for the field chain factory
|
|
602
|
+
*/
|
|
603
|
+
static methods() {
|
|
604
|
+
return {
|
|
605
|
+
...BaseChainFactory.methods(),
|
|
606
|
+
output: FieldChainFactory.prototype.output,
|
|
607
|
+
input: FieldChainFactory.prototype.input,
|
|
608
|
+
resolve: FieldChainFactory.prototype.resolve,
|
|
609
|
+
clone: FieldChainFactory.prototype.clone
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Creates a clone of the current factory with new options
|
|
614
|
+
* @param options - New options to apply to the clone
|
|
615
|
+
*/
|
|
616
|
+
clone(options) {
|
|
617
|
+
return new FieldChainFactory({
|
|
618
|
+
...this.options,
|
|
619
|
+
...options
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Sets the output type for the field
|
|
624
|
+
* @template TOutputNew - The new output type
|
|
625
|
+
* @param output - The output type definition
|
|
626
|
+
*/
|
|
627
|
+
output(output) {
|
|
628
|
+
return new FieldChainFactory({
|
|
629
|
+
...this.options,
|
|
630
|
+
output
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Sets the input type for the field
|
|
635
|
+
* @template TInputNew - The new input type
|
|
636
|
+
* @param input - The input type definition
|
|
637
|
+
*/
|
|
638
|
+
input(input) {
|
|
639
|
+
return new FieldChainFactory({
|
|
640
|
+
...this.options,
|
|
641
|
+
input
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Specifies the dependencies for the field
|
|
646
|
+
* @template TDependencies - The dependencies type
|
|
647
|
+
* @param dependencies - The dependencies to add
|
|
648
|
+
*/
|
|
649
|
+
derivedFrom(...dependencies) {
|
|
650
|
+
return this.clone({ dependencies });
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Sets the resolve function for the field
|
|
654
|
+
* @template TParent - The parent type
|
|
655
|
+
* @param resolve - The resolve function
|
|
656
|
+
*/
|
|
657
|
+
resolve(resolve) {
|
|
658
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
659
|
+
return createField(this.options.output, {
|
|
660
|
+
...this.options,
|
|
661
|
+
resolve
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Creates a field resolver that uses DataLoader for batch loading data.
|
|
666
|
+
* This method is particularly useful for optimizing performance when dealing with multiple data requests
|
|
667
|
+
* by batching them together and handling caching automatically.
|
|
668
|
+
*
|
|
669
|
+
* @template TParent - The parent type that extends GraphQLSilk
|
|
670
|
+
* @param resolve - A function that handles batch loading of data.
|
|
671
|
+
* @returns A GraphQL field resolver that implements batch loading
|
|
672
|
+
*/
|
|
673
|
+
load(resolve) {
|
|
674
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
675
|
+
return createField(this.options.output, {
|
|
676
|
+
...this.options,
|
|
677
|
+
resolve: (parent, input, payload) => {
|
|
678
|
+
const loader = FieldLoader.getByPath(payload, resolve, this.options?.input != null);
|
|
679
|
+
return loader.load([
|
|
680
|
+
parent,
|
|
681
|
+
input,
|
|
682
|
+
payload
|
|
683
|
+
]);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
692
687
|
};
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
688
|
+
/**
|
|
689
|
+
* Factory for creating query resolvers with chainable configuration
|
|
690
|
+
* @template TOutput - The output type of the query
|
|
691
|
+
* @template TInput - The input type of the query
|
|
692
|
+
*/
|
|
693
|
+
var QueryChainFactory = class QueryChainFactory extends BaseChainFactory {
|
|
694
|
+
/**
|
|
695
|
+
* Returns the available methods for the query chain factory
|
|
696
|
+
* @returns An object containing all available methods
|
|
697
|
+
*/
|
|
698
|
+
static methods() {
|
|
699
|
+
return {
|
|
700
|
+
...BaseChainFactory.methods(),
|
|
701
|
+
output: QueryChainFactory.prototype.output,
|
|
702
|
+
input: QueryChainFactory.prototype.input,
|
|
703
|
+
resolve: QueryChainFactory.prototype.resolve,
|
|
704
|
+
clone: QueryChainFactory.prototype.clone
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Creates a clone of the current factory with new options
|
|
709
|
+
* @param options - New options to apply to the clone
|
|
710
|
+
* @returns A new instance of QueryChainFactory with the updated options
|
|
711
|
+
*/
|
|
712
|
+
clone(options) {
|
|
713
|
+
return new QueryChainFactory({
|
|
714
|
+
...this.options,
|
|
715
|
+
...options
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Sets the output type for the query
|
|
720
|
+
* @template TOutputNew - The new output type
|
|
721
|
+
* @param output - The output type definition
|
|
722
|
+
* @returns A new QueryChainFactory instance with the updated output type
|
|
723
|
+
*/
|
|
724
|
+
output(output) {
|
|
725
|
+
return new QueryChainFactory({
|
|
726
|
+
...this.options,
|
|
727
|
+
output
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Sets the input type for the query
|
|
732
|
+
* @template TInputNew - The new input type
|
|
733
|
+
* @param input - The input type definition
|
|
734
|
+
* @returns A new QueryChainFactory instance with the updated input type
|
|
735
|
+
*/
|
|
736
|
+
input(input) {
|
|
737
|
+
return new QueryChainFactory({
|
|
738
|
+
...this.options,
|
|
739
|
+
input
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Sets the resolve function for the query
|
|
744
|
+
* @param resolve - The resolve function that processes the input and returns the output
|
|
745
|
+
* @returns A GraphQL query resolver
|
|
746
|
+
* @throws {Error} If output type is not set
|
|
747
|
+
*/
|
|
748
|
+
resolve(resolve) {
|
|
749
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
750
|
+
return createQuery(this.options.output, {
|
|
751
|
+
...this.options,
|
|
752
|
+
resolve
|
|
753
|
+
});
|
|
754
|
+
}
|
|
746
755
|
};
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
756
|
+
/**
|
|
757
|
+
* Factory for creating mutation resolvers with chainable configuration
|
|
758
|
+
* @template TOutput - The output type of the mutation
|
|
759
|
+
* @template TInput - The input type of the mutation
|
|
760
|
+
*/
|
|
761
|
+
var MutationChainFactory = class MutationChainFactory extends BaseChainFactory {
|
|
762
|
+
/**
|
|
763
|
+
* Returns the available methods for the mutation chain factory
|
|
764
|
+
* @returns An object containing all available methods
|
|
765
|
+
*/
|
|
766
|
+
static methods() {
|
|
767
|
+
return {
|
|
768
|
+
...BaseChainFactory.methods(),
|
|
769
|
+
output: MutationChainFactory.prototype.output,
|
|
770
|
+
input: MutationChainFactory.prototype.input,
|
|
771
|
+
resolve: MutationChainFactory.prototype.resolve,
|
|
772
|
+
clone: MutationChainFactory.prototype.clone
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Creates a clone of the current factory with new options
|
|
777
|
+
* @param options - New options to apply to the clone
|
|
778
|
+
* @returns A new instance of MutationChainFactory with the updated options
|
|
779
|
+
*/
|
|
780
|
+
clone(options) {
|
|
781
|
+
return new MutationChainFactory({
|
|
782
|
+
...this.options,
|
|
783
|
+
...options
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Sets the output type for the mutation
|
|
788
|
+
* @template TOutputNew - The new output type
|
|
789
|
+
* @param output - The output type definition
|
|
790
|
+
* @returns A new MutationChainFactory instance with the updated output type
|
|
791
|
+
*/
|
|
792
|
+
output(output) {
|
|
793
|
+
return new MutationChainFactory({
|
|
794
|
+
...this.options,
|
|
795
|
+
output
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Sets the input type for the mutation
|
|
800
|
+
* @template TInputNew - The new input type
|
|
801
|
+
* @param input - The input type definition
|
|
802
|
+
* @returns A new MutationChainFactory instance with the updated input type
|
|
803
|
+
*/
|
|
804
|
+
input(input) {
|
|
805
|
+
return new MutationChainFactory({
|
|
806
|
+
...this.options,
|
|
807
|
+
input
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Sets the resolve function for the mutation
|
|
812
|
+
* @param resolve - The resolve function that processes the input and returns the output
|
|
813
|
+
* @returns A GraphQL mutation resolver
|
|
814
|
+
* @throws {Error} If output type is not set
|
|
815
|
+
*/
|
|
816
|
+
resolve(resolve) {
|
|
817
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
818
|
+
return createMutation(this.options.output, {
|
|
819
|
+
...this.options,
|
|
820
|
+
resolve
|
|
821
|
+
});
|
|
822
|
+
}
|
|
800
823
|
};
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
824
|
+
/**
|
|
825
|
+
* Factory for creating subscription resolvers with chainable configuration
|
|
826
|
+
* @template TOutput - The output type of the subscription
|
|
827
|
+
* @template TInput - The input type of the subscription
|
|
828
|
+
*/
|
|
829
|
+
var SubscriptionChainFactory = class SubscriptionChainFactory extends BaseChainFactory {
|
|
830
|
+
/**
|
|
831
|
+
* Returns the available methods for the subscription chain factory
|
|
832
|
+
* @returns An object containing all available methods
|
|
833
|
+
*/
|
|
834
|
+
static methods() {
|
|
835
|
+
return {
|
|
836
|
+
...BaseChainFactory.methods(),
|
|
837
|
+
output: SubscriptionChainFactory.prototype.output,
|
|
838
|
+
input: SubscriptionChainFactory.prototype.input,
|
|
839
|
+
subscribe: SubscriptionChainFactory.prototype.subscribe,
|
|
840
|
+
clone: SubscriptionChainFactory.prototype.clone
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Creates a clone of the current factory with new options
|
|
845
|
+
* @param options - New options to apply to the clone
|
|
846
|
+
* @returns A new instance of SubscriptionChainFactory with the updated options
|
|
847
|
+
*/
|
|
848
|
+
clone(options) {
|
|
849
|
+
return new SubscriptionChainFactory({
|
|
850
|
+
...this.options,
|
|
851
|
+
...options
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Sets the output type for the subscription
|
|
856
|
+
* @template TOutputNew - The new output type
|
|
857
|
+
* @param output - The output type definition
|
|
858
|
+
* @returns A new SubscriptionChainFactory instance with the updated output type
|
|
859
|
+
*/
|
|
860
|
+
output(output) {
|
|
861
|
+
return new SubscriptionChainFactory({
|
|
862
|
+
...this.options,
|
|
863
|
+
output
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Sets the input type for the subscription
|
|
868
|
+
* @template TInputNew - The new input type
|
|
869
|
+
* @param input - The input type definition
|
|
870
|
+
* @returns A new SubscriptionChainFactory instance with the updated input type
|
|
871
|
+
*/
|
|
872
|
+
input(input) {
|
|
873
|
+
return new SubscriptionChainFactory({
|
|
874
|
+
...this.options,
|
|
875
|
+
input
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Sets the subscribe function for the subscription
|
|
880
|
+
* @template TValue - The value type of the subscription
|
|
881
|
+
* @param subscribe - The subscribe function that returns an AsyncIterator
|
|
882
|
+
* @returns A subscription resolver that can be further configured with a resolve function
|
|
883
|
+
* @throws {Error} If output type is not set
|
|
884
|
+
*/
|
|
885
|
+
subscribe(subscribe) {
|
|
886
|
+
const options = this.options;
|
|
887
|
+
const output = this.options?.output;
|
|
888
|
+
if (!output) throw new Error("Output is required");
|
|
889
|
+
const subscription$1 = createSubscription(output, {
|
|
890
|
+
...options,
|
|
891
|
+
subscribe
|
|
892
|
+
});
|
|
893
|
+
const subscriptionResolve = subscription$1["~meta"].resolve;
|
|
894
|
+
const resolve = (...args) => {
|
|
895
|
+
if (args.length === 1 && typeof args[0] === "function") return createSubscription(output, {
|
|
896
|
+
...options,
|
|
897
|
+
resolve: args[0],
|
|
898
|
+
subscribe
|
|
899
|
+
});
|
|
900
|
+
return subscriptionResolve(...args);
|
|
901
|
+
};
|
|
902
|
+
return Object.assign(subscription$1, { resolve });
|
|
903
|
+
}
|
|
869
904
|
};
|
|
870
|
-
var QueryFactoryWithResolve = class
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
]
|
|
898
|
-
});
|
|
899
|
-
}
|
|
905
|
+
var QueryFactoryWithResolve = class QueryFactoryWithResolve extends BaseChainFactory {
|
|
906
|
+
get "~meta"() {
|
|
907
|
+
return loom.query(this.outputSilk, this.options)["~meta"];
|
|
908
|
+
}
|
|
909
|
+
constructor(outputSilk, options) {
|
|
910
|
+
super(options);
|
|
911
|
+
this.outputSilk = outputSilk;
|
|
912
|
+
this.options = options;
|
|
913
|
+
}
|
|
914
|
+
clone(options) {
|
|
915
|
+
return new QueryFactoryWithResolve(this.outputSilk, {
|
|
916
|
+
...this.options,
|
|
917
|
+
...options
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
input(input) {
|
|
921
|
+
return new QueryFactoryWithResolve(this.outputSilk, {
|
|
922
|
+
...this.options,
|
|
923
|
+
input
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
output(output, transform) {
|
|
927
|
+
return new QueryFactoryWithResolve(output, {
|
|
928
|
+
...this.options,
|
|
929
|
+
middlewares: [...this.options.middlewares ?? [], async (next) => transform(await next())]
|
|
930
|
+
});
|
|
931
|
+
}
|
|
900
932
|
};
|
|
901
|
-
var MutationFactoryWithResolve = class
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
]
|
|
929
|
-
});
|
|
930
|
-
}
|
|
933
|
+
var MutationFactoryWithResolve = class MutationFactoryWithResolve extends BaseChainFactory {
|
|
934
|
+
get "~meta"() {
|
|
935
|
+
return loom.mutation(this.outputSilk, this.options)["~meta"];
|
|
936
|
+
}
|
|
937
|
+
constructor(outputSilk, options) {
|
|
938
|
+
super(options);
|
|
939
|
+
this.outputSilk = outputSilk;
|
|
940
|
+
this.options = options;
|
|
941
|
+
}
|
|
942
|
+
clone(options) {
|
|
943
|
+
return new MutationFactoryWithResolve(this.outputSilk, {
|
|
944
|
+
...this.options,
|
|
945
|
+
...options
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
input(input) {
|
|
949
|
+
return new MutationFactoryWithResolve(this.outputSilk, {
|
|
950
|
+
...this.options,
|
|
951
|
+
input
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
output(output, transform) {
|
|
955
|
+
return new MutationFactoryWithResolve(output, {
|
|
956
|
+
...this.options,
|
|
957
|
+
middlewares: [...this.options.middlewares ?? [], async (next) => transform(await next())]
|
|
958
|
+
});
|
|
959
|
+
}
|
|
931
960
|
};
|
|
932
|
-
var FieldFactoryWithResolve = class
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
middlewares: [
|
|
960
|
-
...this.options.middlewares ?? [],
|
|
961
|
-
async (next) => transform(await next())
|
|
962
|
-
]
|
|
963
|
-
});
|
|
964
|
-
}
|
|
961
|
+
var FieldFactoryWithResolve = class FieldFactoryWithResolve extends BaseChainFactory {
|
|
962
|
+
get "~meta"() {
|
|
963
|
+
return loom.field(this.outputSilk, this.options)["~meta"];
|
|
964
|
+
}
|
|
965
|
+
constructor(outputSilk, options) {
|
|
966
|
+
super(options);
|
|
967
|
+
this.outputSilk = outputSilk;
|
|
968
|
+
this.options = options;
|
|
969
|
+
}
|
|
970
|
+
clone(options) {
|
|
971
|
+
return new FieldFactoryWithResolve(this.outputSilk, {
|
|
972
|
+
...this.options,
|
|
973
|
+
...options
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
input(input) {
|
|
977
|
+
return new FieldFactoryWithResolve(this.outputSilk, {
|
|
978
|
+
...this.options,
|
|
979
|
+
input
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
output(output, transform) {
|
|
983
|
+
return new FieldFactoryWithResolve(output, {
|
|
984
|
+
...this.options,
|
|
985
|
+
middlewares: [...this.options.middlewares ?? [], async (next) => transform(await next())]
|
|
986
|
+
});
|
|
987
|
+
}
|
|
965
988
|
};
|
|
966
989
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/resolver/resolver.ts
|
|
992
|
+
/**
|
|
993
|
+
* Creates a GraphQL query resolver
|
|
994
|
+
* @param output - The output type definition for the query
|
|
995
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
996
|
+
* @returns A GraphQL query resolver
|
|
997
|
+
*/
|
|
998
|
+
const createQuery = (output, resolveOrOptions) => {
|
|
999
|
+
if (resolveOrOptions == null) return new QueryChainFactory({ output });
|
|
1000
|
+
const options = getOperationOptions(resolveOrOptions);
|
|
1001
|
+
return meta({
|
|
1002
|
+
...getFieldOptions(options),
|
|
1003
|
+
input: options.input,
|
|
1004
|
+
output,
|
|
1005
|
+
resolve: options.resolve,
|
|
1006
|
+
middlewares: options.middlewares,
|
|
1007
|
+
operation: "query"
|
|
1008
|
+
});
|
|
981
1009
|
};
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
);
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1010
|
+
/**
|
|
1011
|
+
* Factory function for creating GraphQL queries with chainable configuration
|
|
1012
|
+
*/
|
|
1013
|
+
const query = Object.assign(createQuery, QueryChainFactory.methods());
|
|
1014
|
+
/**
|
|
1015
|
+
* Creates a GraphQL mutation resolver
|
|
1016
|
+
* @param output - The output type definition for the mutation
|
|
1017
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
1018
|
+
* @returns A GraphQL mutation resolver
|
|
1019
|
+
*/
|
|
1020
|
+
const createMutation = (output, resolveOrOptions) => {
|
|
1021
|
+
if (resolveOrOptions == null) return new MutationChainFactory({ output });
|
|
1022
|
+
const options = getOperationOptions(resolveOrOptions);
|
|
1023
|
+
return meta({
|
|
1024
|
+
...getFieldOptions(options),
|
|
1025
|
+
input: options.input,
|
|
1026
|
+
output,
|
|
1027
|
+
resolve: options.resolve,
|
|
1028
|
+
middlewares: options.middlewares,
|
|
1029
|
+
operation: "mutation"
|
|
1030
|
+
});
|
|
999
1031
|
};
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
);
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1032
|
+
/**
|
|
1033
|
+
* Factory function for creating GraphQL mutations with chainable configuration
|
|
1034
|
+
*/
|
|
1035
|
+
const mutation = Object.assign(createMutation, MutationChainFactory.methods());
|
|
1036
|
+
/**
|
|
1037
|
+
* Creates a GraphQL field resolver
|
|
1038
|
+
* @param output - The output type definition for the field
|
|
1039
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
1040
|
+
* @returns A GraphQL field resolver
|
|
1041
|
+
*/
|
|
1042
|
+
const createField = (output, resolveOrOptions) => {
|
|
1043
|
+
if (resolveOrOptions == null) return new FieldChainFactory({ output });
|
|
1044
|
+
const options = getOperationOptions(resolveOrOptions);
|
|
1045
|
+
return meta({
|
|
1046
|
+
...getFieldOptions(options, { [DERIVED_DEPENDENCIES]: options.dependencies }),
|
|
1047
|
+
input: options.input,
|
|
1048
|
+
dependencies: options.dependencies,
|
|
1049
|
+
output,
|
|
1050
|
+
resolve: options.resolve,
|
|
1051
|
+
middlewares: options.middlewares,
|
|
1052
|
+
operation: "field"
|
|
1053
|
+
});
|
|
1020
1054
|
};
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1055
|
+
/**
|
|
1056
|
+
* Factory function for creating GraphQL fields with chainable configuration
|
|
1057
|
+
*/
|
|
1058
|
+
const field = Object.assign(createField, { hidden: FIELD_HIDDEN }, FieldChainFactory.methods());
|
|
1059
|
+
/**
|
|
1060
|
+
* Default subscription resolver that returns the source value
|
|
1061
|
+
* @param source - The source value to resolve
|
|
1062
|
+
*/
|
|
1063
|
+
const defaultSubscriptionResolve = (source) => source;
|
|
1064
|
+
/**
|
|
1065
|
+
* Creates a GraphQL subscription resolver
|
|
1066
|
+
* @param output - The output type definition for the subscription
|
|
1067
|
+
* @param subscribeOrOptions - Optional subscribe function or options object
|
|
1068
|
+
* @returns A GraphQL subscription resolver or chain factory
|
|
1069
|
+
*/
|
|
1027
1070
|
function createSubscription(output, subscribeOrOptions) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
operation: "subscription"
|
|
1040
|
-
});
|
|
1071
|
+
if (subscribeOrOptions == null) return new SubscriptionChainFactory({ output });
|
|
1072
|
+
const options = getSubscriptionOptions(subscribeOrOptions);
|
|
1073
|
+
return meta({
|
|
1074
|
+
...getFieldOptions(options),
|
|
1075
|
+
input: options.input,
|
|
1076
|
+
output,
|
|
1077
|
+
subscribe: options.subscribe,
|
|
1078
|
+
resolve: options.resolve ?? defaultSubscriptionResolve,
|
|
1079
|
+
middlewares: options.middlewares,
|
|
1080
|
+
operation: "subscription"
|
|
1081
|
+
});
|
|
1041
1082
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
var loom = {
|
|
1057
|
-
query,
|
|
1058
|
-
resolver,
|
|
1059
|
-
field,
|
|
1060
|
-
subscription,
|
|
1061
|
-
mutation
|
|
1083
|
+
/**
|
|
1084
|
+
* Factory function for creating GraphQL subscriptions with chainable configuration
|
|
1085
|
+
*/
|
|
1086
|
+
const subscription = Object.assign(createSubscription, SubscriptionChainFactory.methods());
|
|
1087
|
+
const resolver = Object.assign(((operations, options) => new ChainResolver(operations, options)), { of: ((parent, operations, options) => new ObjectChainResolver(parent, operations, options)) });
|
|
1088
|
+
/**
|
|
1089
|
+
* Collection of factory functions for creating GraphQL operations
|
|
1090
|
+
*/
|
|
1091
|
+
const loom = {
|
|
1092
|
+
query,
|
|
1093
|
+
resolver,
|
|
1094
|
+
field,
|
|
1095
|
+
subscription,
|
|
1096
|
+
mutation
|
|
1062
1097
|
};
|
|
1098
|
+
/**
|
|
1099
|
+
* Base class for chain resolvers
|
|
1100
|
+
* @template TFields - The fields or operations to resolve
|
|
1101
|
+
*/
|
|
1063
1102
|
var ChainResolver = class {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
} else {
|
|
1128
|
-
const resolve = field2["~meta"].resolve;
|
|
1129
|
-
return (args, payload) => {
|
|
1130
|
-
const parseInput = createInputParser(field2["~meta"].input, args);
|
|
1131
|
-
return applyMiddlewares(
|
|
1132
|
-
{
|
|
1133
|
-
outputSilk: field2["~meta"].output,
|
|
1134
|
-
parent: void 0,
|
|
1135
|
-
payload,
|
|
1136
|
-
parseInput,
|
|
1137
|
-
operation
|
|
1138
|
-
},
|
|
1139
|
-
async () => resolve(await parseInput.getResult(), payload),
|
|
1140
|
-
middlewares
|
|
1141
|
-
);
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1103
|
+
meta;
|
|
1104
|
+
/**
|
|
1105
|
+
* Creates a new chain resolver
|
|
1106
|
+
* @param fields - The fields or operations to resolve
|
|
1107
|
+
* @param options - Optional resolver options
|
|
1108
|
+
*/
|
|
1109
|
+
constructor(fields, options) {
|
|
1110
|
+
this.meta = {
|
|
1111
|
+
[IS_RESOLVER]: true,
|
|
1112
|
+
fields,
|
|
1113
|
+
options
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Gets the metadata for the resolver
|
|
1118
|
+
*/
|
|
1119
|
+
get "~meta"() {
|
|
1120
|
+
return this.meta;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Adds middleware functions to the resolver
|
|
1124
|
+
* @param middlewares - The middleware functions to add
|
|
1125
|
+
*/
|
|
1126
|
+
use(...middlewares) {
|
|
1127
|
+
this.meta.options ??= {};
|
|
1128
|
+
this.meta.options.middlewares ??= [];
|
|
1129
|
+
this.meta.options.middlewares.push(...middlewares);
|
|
1130
|
+
return this;
|
|
1131
|
+
}
|
|
1132
|
+
toExecutor(...middlewares) {
|
|
1133
|
+
const executor = mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
|
|
1134
|
+
return executor;
|
|
1135
|
+
}
|
|
1136
|
+
toExecutorOperation(field$1, executorMiddlewares) {
|
|
1137
|
+
if (field$1 === FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return void 0;
|
|
1138
|
+
const operation = field$1["~meta"].operation;
|
|
1139
|
+
const middlewares = filterMiddlewares(operation, executorMiddlewares, this.meta.options?.middlewares, field$1["~meta"].middlewares);
|
|
1140
|
+
if (field$1["~meta"].operation === "field") {
|
|
1141
|
+
const resolve = field$1["~meta"].resolve;
|
|
1142
|
+
return (parent, args, payload) => {
|
|
1143
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1144
|
+
return applyMiddlewares({
|
|
1145
|
+
outputSilk: field$1["~meta"].output,
|
|
1146
|
+
parent,
|
|
1147
|
+
payload,
|
|
1148
|
+
parseInput,
|
|
1149
|
+
operation
|
|
1150
|
+
}, async () => resolve(parent, await parseInput.getResult(), payload), middlewares);
|
|
1151
|
+
};
|
|
1152
|
+
} else {
|
|
1153
|
+
const resolve = field$1["~meta"].resolve;
|
|
1154
|
+
return (args, payload) => {
|
|
1155
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1156
|
+
return applyMiddlewares({
|
|
1157
|
+
outputSilk: field$1["~meta"].output,
|
|
1158
|
+
parent: void 0,
|
|
1159
|
+
payload,
|
|
1160
|
+
parseInput,
|
|
1161
|
+
operation
|
|
1162
|
+
}, async () => resolve(await parseInput.getResult(), payload), middlewares);
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1145
1166
|
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Class for resolving object types
|
|
1169
|
+
* @template TParent - The parent type
|
|
1170
|
+
* @template TFields - The fields to resolve
|
|
1171
|
+
*/
|
|
1146
1172
|
var ObjectChainResolver = class extends ChainResolver {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1173
|
+
meta;
|
|
1174
|
+
/**
|
|
1175
|
+
* Creates a new object chain resolver
|
|
1176
|
+
* @param parent - The parent type definition
|
|
1177
|
+
* @param fields - The fields to resolve
|
|
1178
|
+
* @param options - Optional resolver options
|
|
1179
|
+
*/
|
|
1180
|
+
constructor(parent, fields, options) {
|
|
1181
|
+
super(fields, options);
|
|
1182
|
+
this.meta = {
|
|
1183
|
+
[IS_RESOLVER]: true,
|
|
1184
|
+
fields,
|
|
1185
|
+
parent,
|
|
1186
|
+
options
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Gets the metadata for the resolver
|
|
1191
|
+
*/
|
|
1192
|
+
get "~meta"() {
|
|
1193
|
+
return super["~meta"];
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Sets custom extensions for the resolver
|
|
1197
|
+
* @param extensions - The extensions to add
|
|
1198
|
+
*/
|
|
1199
|
+
extensions(extensions) {
|
|
1200
|
+
this.meta.options ??= {};
|
|
1201
|
+
this.meta.options.extensions ??= {};
|
|
1202
|
+
this.meta.options.extensions = {
|
|
1203
|
+
...this.meta.options.extensions,
|
|
1204
|
+
...extensions
|
|
1205
|
+
};
|
|
1206
|
+
return this;
|
|
1207
|
+
}
|
|
1182
1208
|
};
|
|
1183
1209
|
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
GraphQLList as GraphQLList3,
|
|
1187
|
-
GraphQLNonNull as GraphQLNonNull3,
|
|
1188
|
-
GraphQLObjectType,
|
|
1189
|
-
GraphQLUnionType,
|
|
1190
|
-
assertName,
|
|
1191
|
-
isListType as isListType2,
|
|
1192
|
-
isNonNullType as isNonNullType2,
|
|
1193
|
-
isObjectType as isObjectType3,
|
|
1194
|
-
isUnionType as isUnionType3,
|
|
1195
|
-
resolveObjMapThunk
|
|
1196
|
-
} from "graphql";
|
|
1197
|
-
|
|
1198
|
-
// src/schema/input.ts
|
|
1199
|
-
import {
|
|
1200
|
-
GraphQLInputObjectType,
|
|
1201
|
-
GraphQLList as GraphQLList2,
|
|
1202
|
-
GraphQLNonNull as GraphQLNonNull2,
|
|
1203
|
-
isInputObjectType,
|
|
1204
|
-
isInterfaceType,
|
|
1205
|
-
isListType,
|
|
1206
|
-
isNonNullType,
|
|
1207
|
-
isObjectType as isObjectType2,
|
|
1208
|
-
isUnionType as isUnionType2
|
|
1209
|
-
} from "graphql";
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/schema/input.ts
|
|
1210
1212
|
function inputToArgs(input, options) {
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
...field2,
|
|
1235
|
-
type: ensureInputType(field2, { fieldName })
|
|
1236
|
-
};
|
|
1237
|
-
}, name);
|
|
1238
|
-
});
|
|
1239
|
-
return args;
|
|
1213
|
+
if (input === void 0) return void 0;
|
|
1214
|
+
if (isSilk(input)) {
|
|
1215
|
+
let inputType = getGraphQLType(input);
|
|
1216
|
+
if (isNonNullType(inputType)) inputType = inputType.ofType;
|
|
1217
|
+
if (isObjectType(inputType)) return mapValue(inputType.toConfig().fields, (it, key) => {
|
|
1218
|
+
let fieldName;
|
|
1219
|
+
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1220
|
+
return toInputFieldConfig(it, { fieldName });
|
|
1221
|
+
});
|
|
1222
|
+
throw new Error(`Cannot convert ${inputType.toString()} to input type`);
|
|
1223
|
+
}
|
|
1224
|
+
const args = {};
|
|
1225
|
+
Object.entries(input).forEach(([name, field$1]) => {
|
|
1226
|
+
tryIn(() => {
|
|
1227
|
+
let fieldName;
|
|
1228
|
+
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1229
|
+
args[name] = {
|
|
1230
|
+
...field$1,
|
|
1231
|
+
type: ensureInputType(field$1, { fieldName })
|
|
1232
|
+
};
|
|
1233
|
+
}, name);
|
|
1234
|
+
});
|
|
1235
|
+
return args;
|
|
1240
1236
|
}
|
|
1241
1237
|
function ensureInputType(silkOrType, options) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return new GraphQLNonNull2(ensureInputType(gqlType.ofType, options));
|
|
1252
|
-
}
|
|
1253
|
-
if (isListType(gqlType)) {
|
|
1254
|
-
return new GraphQLList2(ensureInputType(gqlType.ofType, options));
|
|
1255
|
-
}
|
|
1256
|
-
if (isObjectType2(gqlType) || isInterfaceType(gqlType))
|
|
1257
|
-
return ensureInputObjectType(gqlType, options);
|
|
1258
|
-
return gqlType;
|
|
1238
|
+
const gqlType = (() => {
|
|
1239
|
+
if (isSilk(silkOrType)) return getGraphQLType(silkOrType);
|
|
1240
|
+
return silkOrType;
|
|
1241
|
+
})();
|
|
1242
|
+
if (isUnionType(gqlType)) throw new Error(`Cannot convert union type ${gqlType.name} to input type`);
|
|
1243
|
+
if (isNonNullType(gqlType)) return new GraphQLNonNull(ensureInputType(gqlType.ofType, options));
|
|
1244
|
+
if (isListType(gqlType)) return new GraphQLList(ensureInputType(gqlType.ofType, options));
|
|
1245
|
+
if (isObjectType(gqlType) || isInterfaceType(gqlType)) return ensureInputObjectType(gqlType, options);
|
|
1246
|
+
return gqlType;
|
|
1259
1247
|
}
|
|
1260
1248
|
function ensureInputObjectType(object, options) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
fields,
|
|
1277
|
-
(it, key) => toInputFieldConfig(it, {
|
|
1278
|
-
fieldName: inputFieldName(name) + pascalCase(key)
|
|
1279
|
-
})
|
|
1280
|
-
)
|
|
1281
|
-
)
|
|
1282
|
-
});
|
|
1283
|
-
weaverContext.inputMap?.set(object, input);
|
|
1284
|
-
return input;
|
|
1249
|
+
if (isInputObjectType(object)) return object;
|
|
1250
|
+
const existing = weaverContext.inputMap?.get(object);
|
|
1251
|
+
if (existing != null) return existing;
|
|
1252
|
+
const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
|
|
1253
|
+
let name = object.name;
|
|
1254
|
+
if (name === LoomObjectType.AUTO_ALIASING) name = `${pascalCase(options?.fieldName ?? "")}Input`;
|
|
1255
|
+
const getInputObjectName = weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n);
|
|
1256
|
+
name = getInputObjectName(name);
|
|
1257
|
+
const input = new GraphQLInputObjectType({
|
|
1258
|
+
...config,
|
|
1259
|
+
name,
|
|
1260
|
+
fields: provideWeaverContext.inherit(() => mapValue(fields, (it, key) => toInputFieldConfig(it, { fieldName: inputFieldName(name) + pascalCase(key) })))
|
|
1261
|
+
});
|
|
1262
|
+
weaverContext.inputMap?.set(object, input);
|
|
1263
|
+
return input;
|
|
1285
1264
|
}
|
|
1286
|
-
function toInputFieldConfig({ astNode, resolve
|
|
1287
|
-
|
|
1265
|
+
function toInputFieldConfig({ astNode, resolve,...config }, options) {
|
|
1266
|
+
return {
|
|
1267
|
+
...config,
|
|
1268
|
+
type: ensureInputType(config.type, options)
|
|
1269
|
+
};
|
|
1288
1270
|
}
|
|
1289
1271
|
function inputFieldName(name) {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
return name;
|
|
1272
|
+
while (name.endsWith("Input")) name = name.slice(0, -5);
|
|
1273
|
+
return name;
|
|
1294
1274
|
}
|
|
1295
1275
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
);
|
|
1485
|
-
};
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
provideForSubscribe(field2, fieldName) {
|
|
1490
|
-
if (field2?.["~meta"]?.subscribe == null)
|
|
1491
|
-
return;
|
|
1492
|
-
const resolverMiddlewares = this.resolvers.get(fieldName)?.["~meta"].options?.middlewares;
|
|
1493
|
-
const middlewares = filterMiddlewares(
|
|
1494
|
-
"subscription.subscribe",
|
|
1495
|
-
this.globalOptions?.middlewares,
|
|
1496
|
-
resolverMiddlewares,
|
|
1497
|
-
field2["~meta"].middlewares
|
|
1498
|
-
);
|
|
1499
|
-
return (source, args, context, info) => {
|
|
1500
|
-
const payload = { root: source, args, context, info, field: field2 };
|
|
1501
|
-
const parseInput = createInputParser(field2["~meta"].input, args);
|
|
1502
|
-
return applyMiddlewares(
|
|
1503
|
-
{
|
|
1504
|
-
operation: "subscription.subscribe",
|
|
1505
|
-
outputSilk: field2["~meta"].output,
|
|
1506
|
-
parent: void 0,
|
|
1507
|
-
parseInput,
|
|
1508
|
-
payload
|
|
1509
|
-
},
|
|
1510
|
-
async () => field2["~meta"].subscribe(
|
|
1511
|
-
await parseInput.getResult(),
|
|
1512
|
-
payload
|
|
1513
|
-
),
|
|
1514
|
-
middlewares
|
|
1515
|
-
);
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
getCacheType(gqlType, fieldName) {
|
|
1519
|
-
return getCacheType(gqlType, { ...this.options, fieldName, parent: this });
|
|
1520
|
-
}
|
|
1521
|
-
get options() {
|
|
1522
|
-
const { globalOptions: resolverOptions, weaverContext: weaverContext2 } = this;
|
|
1523
|
-
return { resolverOptions, weaverContext: weaverContext2 };
|
|
1524
|
-
}
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region src/schema/object.ts
|
|
1278
|
+
var LoomObjectType = class LoomObjectType extends GraphQLObjectType {
|
|
1279
|
+
extraFields = /* @__PURE__ */ new Map();
|
|
1280
|
+
hiddenFields = /* @__PURE__ */ new Set();
|
|
1281
|
+
static AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1282
|
+
weaverContext;
|
|
1283
|
+
globalOptions;
|
|
1284
|
+
/**
|
|
1285
|
+
* field name -> resolver
|
|
1286
|
+
*/
|
|
1287
|
+
resolvers;
|
|
1288
|
+
constructor(objectOrGetter, options = {}) {
|
|
1289
|
+
const origin = typeof objectOrGetter === "function" ? objectOrGetter() : objectOrGetter;
|
|
1290
|
+
const config = (() => {
|
|
1291
|
+
if (isObjectType(origin)) return origin.toConfig();
|
|
1292
|
+
else if (typeof origin === "string") return {
|
|
1293
|
+
name: origin,
|
|
1294
|
+
fields: {}
|
|
1295
|
+
};
|
|
1296
|
+
else return origin;
|
|
1297
|
+
})();
|
|
1298
|
+
super(config);
|
|
1299
|
+
this.globalOptions = options.globalOptions;
|
|
1300
|
+
this.weaverContext = options.weaverContext ?? initWeaverContext();
|
|
1301
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
1302
|
+
if (this.name !== LoomObjectType.AUTO_ALIASING) this.hasExplicitName = true;
|
|
1303
|
+
}
|
|
1304
|
+
hasExplicitName;
|
|
1305
|
+
_aliases = [];
|
|
1306
|
+
get aliases() {
|
|
1307
|
+
return this._aliases;
|
|
1308
|
+
}
|
|
1309
|
+
addAlias(name) {
|
|
1310
|
+
if (this.hasExplicitName) return;
|
|
1311
|
+
this._aliases.push(name);
|
|
1312
|
+
this.renameByAliases();
|
|
1313
|
+
}
|
|
1314
|
+
renameByAliases() {
|
|
1315
|
+
let name;
|
|
1316
|
+
for (const alias of this.aliases) if (name === void 0 || alias.length < name.length) name = alias;
|
|
1317
|
+
if (name) this.name = name;
|
|
1318
|
+
}
|
|
1319
|
+
hideField(name) {
|
|
1320
|
+
this.hiddenFields.add(name);
|
|
1321
|
+
}
|
|
1322
|
+
addField(name, field$1, resolver$1) {
|
|
1323
|
+
const existing = this.extraFields.get(name);
|
|
1324
|
+
if (existing && existing !== field$1) throw new Error(`Field ${name} already exists in ${this.name}`);
|
|
1325
|
+
this.extraFields.set(name, field$1);
|
|
1326
|
+
if (resolver$1) this.resolvers.set(name, resolver$1);
|
|
1327
|
+
}
|
|
1328
|
+
mergeExtensions(extensions) {
|
|
1329
|
+
this.extensions = deepMerge(this.extensions, extensions);
|
|
1330
|
+
}
|
|
1331
|
+
extraFieldMap;
|
|
1332
|
+
getFields() {
|
|
1333
|
+
const fieldsBySuper = super.getFields();
|
|
1334
|
+
Object.entries(fieldsBySuper).forEach(([fieldName, field$1]) => field$1.type = this.getCacheType(field$1.type, fieldName));
|
|
1335
|
+
const extraFields = provideWeaverContext(() => defineFieldMap(this.mapToFieldConfig(this.extraFields)), this.weaverContext);
|
|
1336
|
+
if (Object.keys(this.extraFieldMap ?? {}).join() !== Object.keys(extraFields).join()) this.extraFieldMap = extraFields;
|
|
1337
|
+
const answer = {
|
|
1338
|
+
...fieldsBySuper,
|
|
1339
|
+
...this.extraFieldMap
|
|
1340
|
+
};
|
|
1341
|
+
for (const fieldName of this.hiddenFields) delete answer[fieldName];
|
|
1342
|
+
return answer;
|
|
1343
|
+
}
|
|
1344
|
+
mapToFieldConfig(map) {
|
|
1345
|
+
const record = {};
|
|
1346
|
+
for (const [name, field$1] of map.entries()) record[name] = this.toFieldConfig(field$1, name);
|
|
1347
|
+
return record;
|
|
1348
|
+
}
|
|
1349
|
+
toFieldConfig(field$1, fieldName) {
|
|
1350
|
+
const outputType = this.getCacheType(getGraphQLType(field$1["~meta"].output), fieldName);
|
|
1351
|
+
const resolve = this.provideForResolve(field$1, fieldName);
|
|
1352
|
+
const subscribe = this.provideForSubscribe(field$1, fieldName);
|
|
1353
|
+
return {
|
|
1354
|
+
...extract(field$1),
|
|
1355
|
+
type: outputType,
|
|
1356
|
+
args: inputToArgs(field$1["~meta"].input, { fieldName: fieldName ? parentName(this.name) + fieldName : void 0 }),
|
|
1357
|
+
resolve,
|
|
1358
|
+
...subscribe ? { subscribe } : {}
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
provideForResolve(field$1, fieldName) {
|
|
1362
|
+
const resolverMiddlewares = this.resolvers.get(fieldName)?.["~meta"].options?.middlewares;
|
|
1363
|
+
switch (field$1["~meta"].operation) {
|
|
1364
|
+
case "query":
|
|
1365
|
+
case "mutation": {
|
|
1366
|
+
const operation = field$1["~meta"].operation;
|
|
1367
|
+
const middlewares = filterMiddlewares(operation, this.globalOptions?.middlewares, resolverMiddlewares, field$1["~meta"].middlewares);
|
|
1368
|
+
return (root, args, context, info) => {
|
|
1369
|
+
const payload = {
|
|
1370
|
+
root,
|
|
1371
|
+
args,
|
|
1372
|
+
context,
|
|
1373
|
+
info,
|
|
1374
|
+
field: field$1
|
|
1375
|
+
};
|
|
1376
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1377
|
+
return applyMiddlewares({
|
|
1378
|
+
operation,
|
|
1379
|
+
outputSilk: field$1["~meta"].output,
|
|
1380
|
+
parent: void 0,
|
|
1381
|
+
parseInput,
|
|
1382
|
+
payload
|
|
1383
|
+
}, async () => field$1["~meta"].resolve(await parseInput.getResult(), payload), middlewares);
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
case "field": {
|
|
1387
|
+
const middlewares = filterMiddlewares("field", this.globalOptions?.middlewares, resolverMiddlewares, field$1["~meta"].middlewares);
|
|
1388
|
+
return (root, args, context, info) => {
|
|
1389
|
+
const payload = {
|
|
1390
|
+
root,
|
|
1391
|
+
args,
|
|
1392
|
+
context,
|
|
1393
|
+
info,
|
|
1394
|
+
field: field$1
|
|
1395
|
+
};
|
|
1396
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1397
|
+
return applyMiddlewares({
|
|
1398
|
+
operation: "field",
|
|
1399
|
+
outputSilk: field$1["~meta"].output,
|
|
1400
|
+
parent: root,
|
|
1401
|
+
parseInput,
|
|
1402
|
+
payload
|
|
1403
|
+
}, async () => field$1["~meta"].resolve(root, await parseInput.getResult(), payload), middlewares);
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
case "subscription": {
|
|
1407
|
+
const middlewares = filterMiddlewares("subscription.resolve", this.globalOptions?.middlewares, resolverMiddlewares, field$1["~meta"].middlewares);
|
|
1408
|
+
return (root, args, context, info) => {
|
|
1409
|
+
const payload = {
|
|
1410
|
+
root,
|
|
1411
|
+
args,
|
|
1412
|
+
context,
|
|
1413
|
+
info,
|
|
1414
|
+
field: field$1
|
|
1415
|
+
};
|
|
1416
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1417
|
+
return applyMiddlewares({
|
|
1418
|
+
operation: "subscription.resolve",
|
|
1419
|
+
outputSilk: field$1["~meta"].output,
|
|
1420
|
+
parent: root,
|
|
1421
|
+
parseInput,
|
|
1422
|
+
payload
|
|
1423
|
+
}, async () => field$1["~meta"].resolve(root, await parseInput.getResult(), payload), middlewares);
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
provideForSubscribe(field$1, fieldName) {
|
|
1429
|
+
if (field$1?.["~meta"]?.subscribe == null) return;
|
|
1430
|
+
const resolverMiddlewares = this.resolvers.get(fieldName)?.["~meta"].options?.middlewares;
|
|
1431
|
+
const middlewares = filterMiddlewares("subscription.subscribe", this.globalOptions?.middlewares, resolverMiddlewares, field$1["~meta"].middlewares);
|
|
1432
|
+
return (source, args, context, info) => {
|
|
1433
|
+
const payload = {
|
|
1434
|
+
root: source,
|
|
1435
|
+
args,
|
|
1436
|
+
context,
|
|
1437
|
+
info,
|
|
1438
|
+
field: field$1
|
|
1439
|
+
};
|
|
1440
|
+
const parseInput = createInputParser(field$1["~meta"].input, args);
|
|
1441
|
+
return applyMiddlewares({
|
|
1442
|
+
operation: "subscription.subscribe",
|
|
1443
|
+
outputSilk: field$1["~meta"].output,
|
|
1444
|
+
parent: void 0,
|
|
1445
|
+
parseInput,
|
|
1446
|
+
payload
|
|
1447
|
+
}, async () => field$1["~meta"].subscribe(await parseInput.getResult(), payload), middlewares);
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
getCacheType(gqlType, fieldName) {
|
|
1451
|
+
return getCacheType(gqlType, {
|
|
1452
|
+
...this.options,
|
|
1453
|
+
fieldName,
|
|
1454
|
+
parent: this
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
get options() {
|
|
1458
|
+
const { globalOptions: resolverOptions, weaverContext: weaverContext$1 } = this;
|
|
1459
|
+
return {
|
|
1460
|
+
resolverOptions,
|
|
1461
|
+
weaverContext: weaverContext$1
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1525
1464
|
};
|
|
1526
|
-
function extract(
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1465
|
+
function extract(field$1) {
|
|
1466
|
+
const { deprecationReason, description, extensions } = field$1["~meta"];
|
|
1467
|
+
return {
|
|
1468
|
+
description,
|
|
1469
|
+
deprecationReason,
|
|
1470
|
+
extensions
|
|
1471
|
+
};
|
|
1533
1472
|
}
|
|
1534
1473
|
function defineFieldMap(fields) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1474
|
+
const fieldMap = resolveObjMapThunk(fields);
|
|
1475
|
+
return mapValue(fieldMap, (fieldConfig, fieldName) => {
|
|
1476
|
+
const argsConfig = fieldConfig.args ?? {};
|
|
1477
|
+
return {
|
|
1478
|
+
name: assertName(fieldName),
|
|
1479
|
+
description: fieldConfig.description,
|
|
1480
|
+
type: fieldConfig.type,
|
|
1481
|
+
args: defineArguments(argsConfig),
|
|
1482
|
+
resolve: fieldConfig.resolve,
|
|
1483
|
+
subscribe: fieldConfig.subscribe,
|
|
1484
|
+
deprecationReason: fieldConfig.deprecationReason,
|
|
1485
|
+
extensions: toObjMap(fieldConfig.extensions),
|
|
1486
|
+
astNode: fieldConfig.astNode
|
|
1487
|
+
};
|
|
1488
|
+
});
|
|
1550
1489
|
}
|
|
1551
1490
|
function defineArguments(args) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1491
|
+
return Object.entries(args).map(([argName, argConfig]) => ({
|
|
1492
|
+
name: assertName(argName),
|
|
1493
|
+
description: argConfig.description,
|
|
1494
|
+
type: argConfig.type,
|
|
1495
|
+
defaultValue: argConfig.defaultValue,
|
|
1496
|
+
deprecationReason: argConfig.deprecationReason,
|
|
1497
|
+
extensions: toObjMap(argConfig.extensions),
|
|
1498
|
+
astNode: argConfig.astNode
|
|
1499
|
+
}));
|
|
1561
1500
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1501
|
+
const OPERATION_OBJECT_NAMES = new Set([
|
|
1502
|
+
"Query",
|
|
1503
|
+
"Mutation",
|
|
1504
|
+
"Subscription"
|
|
1566
1505
|
]);
|
|
1567
1506
|
function getCacheType(gqlType, options = {}) {
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
types: config.types.map(
|
|
1592
|
-
(type) => getCacheType(type, options)
|
|
1593
|
-
)
|
|
1594
|
-
});
|
|
1595
|
-
context.loomUnionMap?.set(gqlType, unionType);
|
|
1596
|
-
return unionType;
|
|
1597
|
-
}
|
|
1598
|
-
return gqlType;
|
|
1507
|
+
const context = options.weaverContext ?? weaverContext;
|
|
1508
|
+
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1509
|
+
if (isObjectType(gqlType)) {
|
|
1510
|
+
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1511
|
+
if (gqlObject != null) return gqlObject;
|
|
1512
|
+
const loomObject = new LoomObjectType(gqlType, options);
|
|
1513
|
+
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1514
|
+
if (options.fieldName && options.parent) loomObject.addAlias(parentName(options.parent.name) + pascalCase(options.fieldName));
|
|
1515
|
+
return loomObject;
|
|
1516
|
+
} else if (isListType(gqlType)) return new GraphQLList(getCacheType(gqlType.ofType, options));
|
|
1517
|
+
else if (isNonNullType(gqlType)) return new GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
1518
|
+
else if (isUnionType(gqlType)) {
|
|
1519
|
+
const existing = context.loomUnionMap?.get(gqlType);
|
|
1520
|
+
if (existing != null) return existing;
|
|
1521
|
+
const config = gqlType.toConfig();
|
|
1522
|
+
const unionType = new GraphQLUnionType({
|
|
1523
|
+
...config,
|
|
1524
|
+
types: config.types.map((type) => getCacheType(type, options))
|
|
1525
|
+
});
|
|
1526
|
+
context.loomUnionMap?.set(gqlType, unionType);
|
|
1527
|
+
return unionType;
|
|
1528
|
+
}
|
|
1529
|
+
return gqlType;
|
|
1599
1530
|
}
|
|
1600
1531
|
function parentName(name) {
|
|
1601
|
-
|
|
1602
|
-
|
|
1532
|
+
if (OPERATION_OBJECT_NAMES.has(name)) name = "";
|
|
1533
|
+
return name;
|
|
1603
1534
|
}
|
|
1604
1535
|
|
|
1605
|
-
|
|
1536
|
+
//#endregion
|
|
1537
|
+
//#region src/schema/schema-weaver.ts
|
|
1606
1538
|
function isSchemaVendorWeaver(some) {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
return true;
|
|
1539
|
+
if (some == null) return false;
|
|
1540
|
+
if (typeof some !== "object" && typeof some !== "function") return false;
|
|
1541
|
+
if (!("getGraphQLType" in some) || typeof some.getGraphQLType !== "function") return false;
|
|
1542
|
+
if (!("vendor" in some) || typeof some.vendor !== "string") return false;
|
|
1543
|
+
return true;
|
|
1613
1544
|
}
|
|
1614
1545
|
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
} else if (item["~meta"][IS_RESOLVER]) {
|
|
1791
|
-
resolvers.add(item);
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
return { context, configs, middlewares, resolvers, silks, weavers };
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* Weave a GraphQL Schema from resolvers
|
|
1798
|
-
* @param inputs Resolvers, Global Middlewares, WeaverConfigs Or SchemaWeaver
|
|
1799
|
-
* @returns GraphQL Schema
|
|
1800
|
-
*/
|
|
1801
|
-
static weave(...inputs) {
|
|
1802
|
-
const { context, configs, middlewares, resolvers, silks, weavers } = _GraphQLSchemaLoom.optionsFrom(...inputs);
|
|
1803
|
-
const weaver = new _GraphQLSchemaLoom({}, context);
|
|
1804
|
-
configs.forEach((it) => weaver.setConfig(it));
|
|
1805
|
-
weavers.forEach((it) => weaver.addVendor(it));
|
|
1806
|
-
middlewares.forEach((it) => weaver.use(it));
|
|
1807
|
-
resolvers.forEach((it) => weaver.add(it));
|
|
1808
|
-
silks.forEach((it) => weaver.addType(it));
|
|
1809
|
-
return weaver.weaveGraphQLSchema();
|
|
1810
|
-
}
|
|
1546
|
+
//#endregion
|
|
1547
|
+
//#region src/schema/schema-loom.ts
|
|
1548
|
+
var GraphQLSchemaLoom = class GraphQLSchemaLoom {
|
|
1549
|
+
query;
|
|
1550
|
+
mutation;
|
|
1551
|
+
subscription;
|
|
1552
|
+
types;
|
|
1553
|
+
context;
|
|
1554
|
+
resolverOptions;
|
|
1555
|
+
/**
|
|
1556
|
+
* Create a Schema Weaver config object
|
|
1557
|
+
* @param config Schema Weaver config options
|
|
1558
|
+
* @returns a Schema Weaver config object
|
|
1559
|
+
*/
|
|
1560
|
+
static config(config) {
|
|
1561
|
+
return {
|
|
1562
|
+
...config,
|
|
1563
|
+
[WEAVER_CONFIG]: "gqloom.core.schema"
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
constructor({ query: query$1, mutation: mutation$1, subscription: subscription$1, types } = {}, context) {
|
|
1567
|
+
if (query$1 != null) this.query = query$1;
|
|
1568
|
+
if (mutation$1 != null) this.mutation = mutation$1;
|
|
1569
|
+
if (subscription$1 != null) this.subscription = subscription$1;
|
|
1570
|
+
this.types = new Set(types ?? []);
|
|
1571
|
+
this.context = context ?? initWeaverContext();
|
|
1572
|
+
}
|
|
1573
|
+
use(...middlewares) {
|
|
1574
|
+
this.resolverOptions ??= {};
|
|
1575
|
+
this.resolverOptions.middlewares ??= [];
|
|
1576
|
+
this.resolverOptions.middlewares.push(...middlewares);
|
|
1577
|
+
return this;
|
|
1578
|
+
}
|
|
1579
|
+
add(resolver$1, modifyParent) {
|
|
1580
|
+
provideWeaverContext(() => this.addResolver(resolver$1, modifyParent), this.context);
|
|
1581
|
+
return this;
|
|
1582
|
+
}
|
|
1583
|
+
addVendor(weaver) {
|
|
1584
|
+
this.context.vendorWeavers.set(weaver.vendor, weaver);
|
|
1585
|
+
return this;
|
|
1586
|
+
}
|
|
1587
|
+
addType(silk$1) {
|
|
1588
|
+
const gqlType = provideWeaverContext(() => {
|
|
1589
|
+
let gqlType$1 = getGraphQLType(silk$1);
|
|
1590
|
+
if (isNonNullType(gqlType$1)) gqlType$1 = gqlType$1.ofType;
|
|
1591
|
+
if (isObjectType(gqlType$1)) {
|
|
1592
|
+
const existing = this.context.loomObjectMap.get(gqlType$1);
|
|
1593
|
+
if (existing != null) return existing;
|
|
1594
|
+
const extraObject = new LoomObjectType(gqlType$1, this.fieldOptions);
|
|
1595
|
+
this.context.loomObjectMap.set(gqlType$1, extraObject);
|
|
1596
|
+
return extraObject;
|
|
1597
|
+
} else if (isUnionType(gqlType$1) || isEnumType(gqlType$1)) return gqlType$1;
|
|
1598
|
+
throw new Error(`${gqlType$1?.name ?? gqlType$1.toString()} is not a named type`);
|
|
1599
|
+
}, this.context);
|
|
1600
|
+
this.types.add(gqlType);
|
|
1601
|
+
return this;
|
|
1602
|
+
}
|
|
1603
|
+
setConfig(config) {
|
|
1604
|
+
this.context.setConfig(config);
|
|
1605
|
+
return this;
|
|
1606
|
+
}
|
|
1607
|
+
weaveGraphQLSchema() {
|
|
1608
|
+
const { query: query$1, mutation: mutation$1, subscription: subscription$1, types } = this;
|
|
1609
|
+
const config = this.context.getConfig("gqloom.core.schema");
|
|
1610
|
+
const schema = new GraphQLSchema({
|
|
1611
|
+
query: query$1,
|
|
1612
|
+
mutation: mutation$1,
|
|
1613
|
+
subscription: subscription$1,
|
|
1614
|
+
types: [...types ?? [], ...config?.types ?? []],
|
|
1615
|
+
...config
|
|
1616
|
+
});
|
|
1617
|
+
return schema;
|
|
1618
|
+
}
|
|
1619
|
+
addResolver(resolver$1, modifyParent) {
|
|
1620
|
+
const resolverOptions = resolver$1["~meta"].options;
|
|
1621
|
+
const parent = resolver$1["~meta"].parent;
|
|
1622
|
+
let parentObject = (() => {
|
|
1623
|
+
if (parent == null) return void 0;
|
|
1624
|
+
let gqlType = getGraphQLType(parent);
|
|
1625
|
+
if (isNonNullType(gqlType)) gqlType = gqlType.ofType;
|
|
1626
|
+
if (!isObjectType(gqlType)) throw new Error(`${gqlType?.name ?? gqlType.toString()} is not an object type`);
|
|
1627
|
+
const existing = this.context.loomObjectMap.get(gqlType);
|
|
1628
|
+
if (existing != null) return existing;
|
|
1629
|
+
const extraObject = new LoomObjectType(gqlType, this.fieldOptions);
|
|
1630
|
+
this.context.loomObjectMap.set(gqlType, extraObject);
|
|
1631
|
+
this.types.add(extraObject);
|
|
1632
|
+
return extraObject;
|
|
1633
|
+
})();
|
|
1634
|
+
if (resolverOptions?.extensions && parentObject) parentObject.mergeExtensions(resolverOptions.extensions);
|
|
1635
|
+
if (modifyParent != null && parentObject) parentObject = modifyParent(parentObject);
|
|
1636
|
+
Object.entries(resolver$1["~meta"].fields).forEach(([name, field$1]) => {
|
|
1637
|
+
if (field$1 === FIELD_HIDDEN) {
|
|
1638
|
+
if (parentObject == null) return;
|
|
1639
|
+
parentObject.hideField(name);
|
|
1640
|
+
} else if (field$1["~meta"].operation === "field") {
|
|
1641
|
+
if (parentObject == null) return;
|
|
1642
|
+
parentObject.addField(name, field$1, resolver$1);
|
|
1643
|
+
} else {
|
|
1644
|
+
const operationObject = this.getOperationObject(field$1["~meta"].operation);
|
|
1645
|
+
operationObject.addField(name, field$1, resolver$1);
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
return this;
|
|
1649
|
+
}
|
|
1650
|
+
getOperationObject(type) {
|
|
1651
|
+
switch (type) {
|
|
1652
|
+
case "query":
|
|
1653
|
+
this.query ??= new LoomObjectType({
|
|
1654
|
+
name: "Query",
|
|
1655
|
+
fields: {}
|
|
1656
|
+
}, this.fieldOptions);
|
|
1657
|
+
return this.query;
|
|
1658
|
+
case "mutation":
|
|
1659
|
+
this.mutation ??= new LoomObjectType({
|
|
1660
|
+
name: "Mutation",
|
|
1661
|
+
fields: {}
|
|
1662
|
+
}, this.fieldOptions);
|
|
1663
|
+
return this.mutation;
|
|
1664
|
+
case "subscription":
|
|
1665
|
+
this.subscription ??= new LoomObjectType({
|
|
1666
|
+
name: "Subscription",
|
|
1667
|
+
fields: {}
|
|
1668
|
+
}, this.fieldOptions);
|
|
1669
|
+
return this.subscription;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
get fieldOptions() {
|
|
1673
|
+
const { resolverOptions, context } = this;
|
|
1674
|
+
return {
|
|
1675
|
+
globalOptions: resolverOptions,
|
|
1676
|
+
weaverContext: context
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
static optionsFrom(...inputs) {
|
|
1680
|
+
const configs = /* @__PURE__ */ new Set();
|
|
1681
|
+
const middlewares = /* @__PURE__ */ new Set();
|
|
1682
|
+
const resolvers = /* @__PURE__ */ new Set();
|
|
1683
|
+
const silks = /* @__PURE__ */ new Set();
|
|
1684
|
+
const weavers = /* @__PURE__ */ new Set();
|
|
1685
|
+
let context;
|
|
1686
|
+
for (const item of inputs) {
|
|
1687
|
+
if (item == null) continue;
|
|
1688
|
+
if (isSchemaVendorWeaver(item)) weavers.add(item);
|
|
1689
|
+
else if (typeof item === "function") middlewares.add(item);
|
|
1690
|
+
else if (WEAVER_CONFIG in item) {
|
|
1691
|
+
configs.add(item);
|
|
1692
|
+
if (item.vendorWeaver) weavers.add(item.vendorWeaver);
|
|
1693
|
+
if (item[WEAVER_CONFIG] === "gqloom.core.schema") context = item.weaverContext;
|
|
1694
|
+
} else if (isSilk(item)) silks.add(item);
|
|
1695
|
+
else if (item["~meta"][IS_RESOLVER]) resolvers.add(item);
|
|
1696
|
+
}
|
|
1697
|
+
return {
|
|
1698
|
+
context,
|
|
1699
|
+
configs,
|
|
1700
|
+
middlewares,
|
|
1701
|
+
resolvers,
|
|
1702
|
+
silks,
|
|
1703
|
+
weavers
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Weave a GraphQL Schema from resolvers
|
|
1708
|
+
* @param inputs Resolvers, Global Middlewares, WeaverConfigs Or SchemaWeaver
|
|
1709
|
+
* @returns GraphQL Schema
|
|
1710
|
+
*/
|
|
1711
|
+
static weave(...inputs) {
|
|
1712
|
+
const { context, configs, middlewares, resolvers, silks, weavers } = GraphQLSchemaLoom.optionsFrom(...inputs);
|
|
1713
|
+
const weaver = new GraphQLSchemaLoom({}, context);
|
|
1714
|
+
configs.forEach((it) => weaver.setConfig(it));
|
|
1715
|
+
weavers.forEach((it) => weaver.addVendor(it));
|
|
1716
|
+
middlewares.forEach((it) => weaver.use(it));
|
|
1717
|
+
resolvers.forEach((it) => weaver.add(it));
|
|
1718
|
+
silks.forEach((it) => weaver.addType(it));
|
|
1719
|
+
return weaver.weaveGraphQLSchema();
|
|
1720
|
+
}
|
|
1811
1721
|
};
|
|
1812
|
-
|
|
1722
|
+
/**
|
|
1723
|
+
* Weave a GraphQL Schema from resolvers
|
|
1724
|
+
* @param inputs Resolvers, Global Middlewares or WeaverConfigs
|
|
1725
|
+
* @returns GraphQL Schema
|
|
1726
|
+
*/
|
|
1727
|
+
const weave = GraphQLSchemaLoom.weave;
|
|
1813
1728
|
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
GraphQLInterfaceType,
|
|
1817
|
-
isInterfaceType as isInterfaceType2,
|
|
1818
|
-
isObjectType as isObjectType5
|
|
1819
|
-
} from "graphql";
|
|
1729
|
+
//#endregion
|
|
1730
|
+
//#region src/schema/interface.ts
|
|
1820
1731
|
function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
});
|
|
1840
|
-
weaverContext.interfaceMap?.set(key, interfaceType);
|
|
1841
|
-
return interfaceType;
|
|
1732
|
+
if (isInterfaceType(gqlType)) return gqlType;
|
|
1733
|
+
if (!isObjectType(gqlType)) throw new Error(`${gqlType.toString()} is not an object`);
|
|
1734
|
+
const key = gqlType;
|
|
1735
|
+
const existing = weaverContext.interfaceMap?.get(key);
|
|
1736
|
+
if (existing != null) return existing;
|
|
1737
|
+
const { astNode: _, extensionASTNodes: _1, fields,...config } = gqlType.toConfig();
|
|
1738
|
+
const interfaceType = new GraphQLInterfaceType({
|
|
1739
|
+
...config,
|
|
1740
|
+
...interfaceConfig,
|
|
1741
|
+
fields: mapValue(fields, (field$1) => {
|
|
1742
|
+
return {
|
|
1743
|
+
...field$1,
|
|
1744
|
+
type: getCacheType(field$1.type)
|
|
1745
|
+
};
|
|
1746
|
+
})
|
|
1747
|
+
});
|
|
1748
|
+
weaverContext.interfaceMap?.set(key, interfaceType);
|
|
1749
|
+
return interfaceType;
|
|
1842
1750
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
EasyDataLoader,
|
|
1847
|
-
FieldChainFactory,
|
|
1848
|
-
FieldFactoryWithResolve,
|
|
1849
|
-
GraphQLSchemaLoom,
|
|
1850
|
-
LoomDataLoader,
|
|
1851
|
-
LoomObjectType,
|
|
1852
|
-
MutationChainFactory,
|
|
1853
|
-
MutationFactoryWithResolve,
|
|
1854
|
-
OPERATION_OBJECT_NAMES,
|
|
1855
|
-
ObjectChainResolver,
|
|
1856
|
-
QueryChainFactory,
|
|
1857
|
-
QueryFactoryWithResolve,
|
|
1858
|
-
symbols_exports as SYMBOLS,
|
|
1859
|
-
SubscriptionChainFactory,
|
|
1860
|
-
applyMiddlewares,
|
|
1861
|
-
assignContextMap,
|
|
1862
|
-
capitalize,
|
|
1863
|
-
collectName,
|
|
1864
|
-
collectNames,
|
|
1865
|
-
createField,
|
|
1866
|
-
createInputParser,
|
|
1867
|
-
createMutation,
|
|
1868
|
-
createQuery,
|
|
1869
|
-
createSubscription,
|
|
1870
|
-
deepMerge,
|
|
1871
|
-
defaultSubscriptionResolve,
|
|
1872
|
-
ensureInputObjectType,
|
|
1873
|
-
ensureInputType,
|
|
1874
|
-
ensureInterfaceType,
|
|
1875
|
-
field,
|
|
1876
|
-
filterMiddlewares,
|
|
1877
|
-
getCacheType,
|
|
1878
|
-
getFieldOptions,
|
|
1879
|
-
getGraphQLType,
|
|
1880
|
-
getMemoizationMap,
|
|
1881
|
-
getOperationOptions,
|
|
1882
|
-
getResolvingFields,
|
|
1883
|
-
getStandardValue,
|
|
1884
|
-
getSubscriptionOptions,
|
|
1885
|
-
initWeaverContext,
|
|
1886
|
-
inputToArgs,
|
|
1887
|
-
isOnlyMemoryPayload,
|
|
1888
|
-
isSchemaVendorWeaver,
|
|
1889
|
-
isSilk,
|
|
1890
|
-
listSilk,
|
|
1891
|
-
loom,
|
|
1892
|
-
mapValue,
|
|
1893
|
-
markErrorLocation,
|
|
1894
|
-
markLocation,
|
|
1895
|
-
meta,
|
|
1896
|
-
mutation,
|
|
1897
|
-
nonNullSilk,
|
|
1898
|
-
notNullish,
|
|
1899
|
-
nullableSilk,
|
|
1900
|
-
onlyMemoization,
|
|
1901
|
-
parseInputValue,
|
|
1902
|
-
parseResolvingFields,
|
|
1903
|
-
parseSilk,
|
|
1904
|
-
pascalCase,
|
|
1905
|
-
provideWeaverContext,
|
|
1906
|
-
query,
|
|
1907
|
-
resolver,
|
|
1908
|
-
screamingSnakeCase,
|
|
1909
|
-
silk,
|
|
1910
|
-
subscription,
|
|
1911
|
-
toObjMap,
|
|
1912
|
-
tryIn,
|
|
1913
|
-
weave,
|
|
1914
|
-
weaverContext
|
|
1915
|
-
};
|
|
1751
|
+
|
|
1752
|
+
//#endregion
|
|
1753
|
+
export { BaseChainFactory, ChainResolver, EasyDataLoader, FieldChainFactory, FieldFactoryWithResolve, GraphQLSchemaLoom, LoomDataLoader, LoomObjectType, MutationChainFactory, MutationFactoryWithResolve, OPERATION_OBJECT_NAMES, ObjectChainResolver, QueryChainFactory, QueryFactoryWithResolve, symbols_exports as SYMBOLS, SubscriptionChainFactory, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|