@gqloom/core 0.10.0 → 0.11.0

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