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