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