@gqloom/core 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,6 +4,321 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
+ // src/utils/args.ts
8
+ function getOperationOptions(resolveOrOptions) {
9
+ if (typeof resolveOrOptions === "function") {
10
+ return { resolve: resolveOrOptions };
11
+ }
12
+ return resolveOrOptions;
13
+ }
14
+ function getSubscriptionOptions(subscribeOrOptions) {
15
+ if (typeof subscribeOrOptions === "function") {
16
+ return { subscribe: subscribeOrOptions };
17
+ }
18
+ return subscribeOrOptions;
19
+ }
20
+ function getFieldOptions({
21
+ description,
22
+ deprecationReason,
23
+ extensions
24
+ }) {
25
+ return {
26
+ description,
27
+ deprecationReason,
28
+ extensions
29
+ };
30
+ }
31
+
32
+ // src/utils/middleware.ts
33
+ function applyMiddlewares(middlewares, resolveFunction, options) {
34
+ const next = (index) => {
35
+ if (index >= middlewares.length) {
36
+ return resolveFunction();
37
+ }
38
+ const middleware = middlewares[index];
39
+ const callableOptions = Object.assign(() => next(index + 1), {
40
+ ...options,
41
+ next: () => next(index + 1)
42
+ });
43
+ return middleware(callableOptions);
44
+ };
45
+ return next(0);
46
+ }
47
+ function compose(...lists) {
48
+ const list = [];
49
+ for (const item of lists) {
50
+ if (item != null) {
51
+ list.push(...item);
52
+ }
53
+ }
54
+ return list;
55
+ }
56
+
57
+ // src/utils/context.ts
58
+ import { AsyncLocalStorage } from "async_hooks";
59
+
60
+ // src/utils/symbols.ts
61
+ var symbols_exports = {};
62
+ __export(symbols_exports, {
63
+ CONTEXT_MEMORY_MAP_KEY: () => CONTEXT_MEMORY_MAP_KEY,
64
+ FIELD_HIDDEN: () => FIELD_HIDDEN,
65
+ GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
66
+ IS_RESOLVER: () => IS_RESOLVER,
67
+ RESOLVER_OPTIONS_KEY: () => RESOLVER_OPTIONS_KEY,
68
+ WEAVER_CONFIG: () => WEAVER_CONFIG
69
+ });
70
+ var GET_GRAPHQL_TYPE = Symbol.for("gqloom.get_graphql_type");
71
+ var WEAVER_CONFIG = Symbol.for("gqloom.weaver_config");
72
+ var RESOLVER_OPTIONS_KEY = Symbol.for("gqloom.resolver-options");
73
+ var IS_RESOLVER = Symbol.for("gqloom.is-resolver");
74
+ var CONTEXT_MEMORY_MAP_KEY = Symbol.for("gqloom.context-memory");
75
+ var FIELD_HIDDEN = Symbol.for("gqloom.field-hidden");
76
+
77
+ // src/utils/context.ts
78
+ function onlyMemoization() {
79
+ return { memoization: /* @__PURE__ */ new WeakMap(), isMemoization: true };
80
+ }
81
+ function isOnlyMemoryPayload(payload) {
82
+ return payload.isMemoization === true;
83
+ }
84
+ var resolverPayloadStorage = new AsyncLocalStorage();
85
+ function useResolverPayload() {
86
+ const payload = resolverPayloadStorage.getStore();
87
+ if (payload === void 0 || isOnlyMemoryPayload(payload)) return;
88
+ return payload;
89
+ }
90
+ function useContext() {
91
+ return useResolverPayload()?.context;
92
+ }
93
+ function useMemoizationMap() {
94
+ const payload = resolverPayloadStorage.getStore();
95
+ if (payload == null) return;
96
+ if (isOnlyMemoryPayload(payload)) return payload.memoization;
97
+ return ContextMemoization.assignMemoizationMap(payload.context);
98
+ }
99
+ var ContextMemoization = class {
100
+ constructor(getter, options = {}) {
101
+ this.getter = getter;
102
+ this.getter = getter;
103
+ this.getMemoizationMap = options.getMemoizationMap ?? useMemoizationMap;
104
+ this.key = options.key ?? this.getter;
105
+ }
106
+ getMemoizationMap;
107
+ key;
108
+ /**
109
+ * Get the value in memoization or call the getter function
110
+ * @returns the value of the getter function
111
+ */
112
+ get() {
113
+ const map = this.getMemoizationMap();
114
+ if (!map) return this.getter();
115
+ if (!map.has(this.key)) {
116
+ map.set(this.key, this.getter());
117
+ }
118
+ return map.get(this.key);
119
+ }
120
+ /**
121
+ * Clear the memoization
122
+ * @returns true if the memoization is cleared, undefined if the context is not found
123
+ */
124
+ clear() {
125
+ const map = this.getMemoizationMap();
126
+ if (!map) return;
127
+ return map.delete(this.key);
128
+ }
129
+ /**
130
+ * Check if the memoization exists
131
+ * @returns true if the memoization exists, undefined if the context is not found
132
+ */
133
+ exists() {
134
+ const map = this.getMemoizationMap();
135
+ if (!map) return;
136
+ return map.has(this.key);
137
+ }
138
+ /**
139
+ * Set a new value to the memoization
140
+ * @param value the new value to set
141
+ * @returns the memoization map or undefined if the context is not found
142
+ */
143
+ set(value) {
144
+ const map = this.getMemoizationMap();
145
+ if (!map) return;
146
+ return map.set(this.key, value);
147
+ }
148
+ static assignMemoizationMap(target) {
149
+ target[CONTEXT_MEMORY_MAP_KEY] ??= /* @__PURE__ */ new WeakMap();
150
+ return target[CONTEXT_MEMORY_MAP_KEY];
151
+ }
152
+ };
153
+ function createMemoization(...args) {
154
+ const memoization = new ContextMemoization(...args);
155
+ const callable = () => memoization.get();
156
+ return Object.assign(callable, {
157
+ get: () => memoization.get(),
158
+ set: (value) => memoization.set(value),
159
+ clear: () => memoization.clear(),
160
+ exists: () => memoization.exists(),
161
+ getter: memoization.getter
162
+ });
163
+ }
164
+
165
+ // src/utils/object.ts
166
+ function mapValue(record, fn) {
167
+ const result = /* @__PURE__ */ Object.create(null);
168
+ for (const key of Object.keys(record)) {
169
+ const value = fn(record[key], key);
170
+ if (value === SKIP) continue;
171
+ result[key] = value;
172
+ }
173
+ return result;
174
+ }
175
+ var SKIP = Symbol.for("mapValue.skip");
176
+ mapValue.SKIP = SKIP;
177
+ function toObjMap(obj) {
178
+ if (obj == null) {
179
+ return /* @__PURE__ */ Object.create(null);
180
+ }
181
+ if (Object.getPrototypeOf(obj) === null) {
182
+ return obj;
183
+ }
184
+ const map = /* @__PURE__ */ Object.create(null);
185
+ for (const [key, value] of Object.entries(obj)) {
186
+ map[key] = value;
187
+ }
188
+ return map;
189
+ }
190
+ function notNullish(x) {
191
+ return x != null;
192
+ }
193
+ function deepMerge(...objects) {
194
+ const result = {};
195
+ for (const obj of objects) {
196
+ if (obj == null) continue;
197
+ for (const [key, value] of Object.entries(obj)) {
198
+ if (value !== null && typeof value === "object") {
199
+ if (Array.isArray(value)) {
200
+ if (!Array.isArray(result[key])) {
201
+ result[key] = [];
202
+ }
203
+ result[key] = [...result[key], ...value];
204
+ } else {
205
+ result[key] = deepMerge(result[key], value);
206
+ }
207
+ } else {
208
+ result[key] = value;
209
+ }
210
+ }
211
+ }
212
+ return result;
213
+ }
214
+ function meta(data) {
215
+ return { "~meta": data };
216
+ }
217
+
218
+ // src/utils/string.ts
219
+ function pascalCase(str) {
220
+ return str.split(/[\s-_]+/).map(
221
+ (word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
222
+ ).join("");
223
+ }
224
+ function capitalize(str) {
225
+ return str.slice(0, 1).toUpperCase() + str.slice(1);
226
+ }
227
+
228
+ // src/utils/error.ts
229
+ function markErrorLocation(error, ...locations) {
230
+ if (error instanceof Error) {
231
+ error.message = markLocation(error.message, ...locations);
232
+ }
233
+ return error;
234
+ }
235
+ function tryIn(func, ...locations) {
236
+ try {
237
+ return func();
238
+ } catch (error) {
239
+ throw markErrorLocation(error, ...locations);
240
+ }
241
+ }
242
+ function markLocation(message, ...locations) {
243
+ if (locations.length === 0) {
244
+ return message;
245
+ }
246
+ const [existingPrefix, newMessage] = (() => {
247
+ const existingPrefixPattern = /^\[(.*?)\]/;
248
+ const match = existingPrefixPattern.exec(message);
249
+ if (match) return [match[1], message.slice(match[0].length).trim()];
250
+ return [void 0, message];
251
+ })();
252
+ const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
253
+ return `[${combinedLocation}] ${newMessage}`;
254
+ }
255
+
256
+ // src/utils/loader.ts
257
+ var EasyDataLoader = class _EasyDataLoader {
258
+ constructor(batchLoadFn) {
259
+ this.batchLoadFn = batchLoadFn;
260
+ this.queue = [];
261
+ this.cache = /* @__PURE__ */ new Map();
262
+ this.resolvers = /* @__PURE__ */ new Map();
263
+ }
264
+ queue;
265
+ cache;
266
+ resolvers;
267
+ load(key) {
268
+ const existing = this.cache.get(key);
269
+ if (existing) return existing;
270
+ const promise = new Promise((resolve, reject) => {
271
+ this.queue.push(key);
272
+ this.resolvers.set(key, [resolve, reject]);
273
+ this.nextTickBatchLoad();
274
+ });
275
+ this.cache.set(key, promise);
276
+ return promise;
277
+ }
278
+ clear() {
279
+ this.queue = [];
280
+ this.cache = /* @__PURE__ */ new Map();
281
+ this.resolvers = /* @__PURE__ */ new Map();
282
+ }
283
+ clearByKey(key) {
284
+ this.queue = this.queue.filter((k) => k !== key);
285
+ this.cache.delete(key);
286
+ this.resolvers.delete(key);
287
+ }
288
+ async executeBatchLoad() {
289
+ if (this.queue.length === 0) return;
290
+ const [keys, resolvers] = [this.queue, this.resolvers];
291
+ this.queue = [];
292
+ this.resolvers = /* @__PURE__ */ new Map();
293
+ try {
294
+ const list = await this.batchLoadFn(keys);
295
+ for (let i = 0; i < list.length; i++) {
296
+ const data = list[i];
297
+ const resolve = resolvers.get(keys[i])?.[0];
298
+ const reject = resolvers.get(keys[i])?.[1];
299
+ if (data instanceof Error) {
300
+ reject?.(data);
301
+ } else {
302
+ resolve?.(data);
303
+ }
304
+ }
305
+ } catch (error) {
306
+ for (const key of keys) {
307
+ const reject = resolvers.get(key)?.[1];
308
+ reject?.(error);
309
+ }
310
+ }
311
+ }
312
+ nextTickPromise;
313
+ nextTickBatchLoad() {
314
+ this.nextTickPromise ??= _EasyDataLoader.nextTick().then(() => this.executeBatchLoad()).finally(() => this.nextTickPromise = void 0);
315
+ return this.nextTickPromise;
316
+ }
317
+ static nextTick() {
318
+ return new Promise((resolve) => setTimeout(resolve));
319
+ }
320
+ };
321
+
7
322
  // src/resolver/silk.ts
8
323
  import {
9
324
  GraphQLList,
@@ -17,23 +332,6 @@ import {
17
332
  isScalarType,
18
333
  isUnionType
19
334
  } from "graphql";
20
-
21
- // src/utils/symbols.ts
22
- var symbols_exports = {};
23
- __export(symbols_exports, {
24
- CONTEXT_MEMORY_MAP_KEY: () => CONTEXT_MEMORY_MAP_KEY,
25
- FIELD_HIDDEN: () => FIELD_HIDDEN,
26
- GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
27
- RESOLVER_OPTIONS_KEY: () => RESOLVER_OPTIONS_KEY,
28
- WEAVER_CONFIG: () => WEAVER_CONFIG
29
- });
30
- var GET_GRAPHQL_TYPE = Symbol.for("gqloom.get_graphql_type");
31
- var WEAVER_CONFIG = Symbol.for("gqloom.weaver_config");
32
- var RESOLVER_OPTIONS_KEY = Symbol.for("gqloom.resolver-options");
33
- var CONTEXT_MEMORY_MAP_KEY = Symbol.for("gqloom.context-memory");
34
- var FIELD_HIDDEN = Symbol.for("gqloom.field-hidden");
35
-
36
- // src/schema/weaver-context.ts
37
335
  var ref;
38
336
  var names = /* @__PURE__ */ new WeakMap();
39
337
  function initWeaverContext() {
@@ -205,331 +503,38 @@ function nullableSilk(origin) {
205
503
  return {
206
504
  ...origin,
207
505
  [GET_GRAPHQL_TYPE]: () => {
208
- const originType = getGraphQLType(origin);
209
- if (originType instanceof GraphQLNonNull) {
210
- return originType.ofType;
211
- } else {
212
- return originType;
213
- }
214
- }
215
- };
216
- }
217
- function getGraphQLType(silk2) {
218
- if (GET_GRAPHQL_TYPE in silk2 && silk2[GET_GRAPHQL_TYPE] != null)
219
- return silk2[GET_GRAPHQL_TYPE]();
220
- const vendorWeavers = weaverContext.vendorWeavers;
221
- if (vendorWeavers == null) throw new Error("Schema Weaver is not initialized");
222
- const weaver = vendorWeavers.get(silk2["~standard"].vendor);
223
- if (weaver == null)
224
- throw new Error(
225
- `Schema Weaver for ${silk2["~standard"].vendor} is not found`
226
- );
227
- return weaver.getGraphQLType(silk2);
228
- }
229
- function parseSilk(silk2, input) {
230
- return silk2["~standard"].validate(input);
231
- }
232
- function isSilk(target) {
233
- if (typeof target !== "object") return false;
234
- if (target == null) return false;
235
- if (GET_GRAPHQL_TYPE in target) return true;
236
- if (!("~standard" in target)) return false;
237
- return "vendor" in target["~standard"] && typeof target["~standard"].vendor === "string" && "version" in target["~standard"] && typeof target["~standard"].version === "number";
238
- }
239
-
240
- // src/utils/args.ts
241
- function getOperationOptions(resolveOrOptions) {
242
- if (typeof resolveOrOptions === "function") {
243
- return { resolve: resolveOrOptions };
244
- }
245
- return resolveOrOptions;
246
- }
247
- function getSubscriptionOptions(subscribeOrOptions) {
248
- if (typeof subscribeOrOptions === "function") {
249
- return { subscribe: subscribeOrOptions };
250
- }
251
- return subscribeOrOptions;
252
- }
253
- function getFieldOptions({
254
- description,
255
- deprecationReason,
256
- extensions
257
- }) {
258
- return {
259
- description,
260
- deprecationReason,
261
- extensions
262
- };
263
- }
264
-
265
- // src/utils/middleware.ts
266
- function applyMiddlewares(middlewares, resolveFunction, options) {
267
- const next = (index) => {
268
- if (index >= middlewares.length) {
269
- return resolveFunction();
270
- }
271
- const middleware = middlewares[index];
272
- const callableOptions = Object.assign(() => next(index + 1), {
273
- ...options,
274
- next: () => next(index + 1)
275
- });
276
- return middleware(callableOptions);
277
- };
278
- return next(0);
279
- }
280
- function compose(...lists) {
281
- const list = [];
282
- for (const item of lists) {
283
- if (item != null) {
284
- list.push(...item);
285
- }
286
- }
287
- return list;
288
- }
289
-
290
- // src/utils/context.ts
291
- import { AsyncLocalStorage } from "async_hooks";
292
- function onlyMemoization() {
293
- return { memoization: /* @__PURE__ */ new WeakMap(), isMemoization: true };
294
- }
295
- function isOnlyMemoryPayload(payload) {
296
- return payload.isMemoization === true;
297
- }
298
- var resolverPayloadStorage = new AsyncLocalStorage();
299
- function useResolverPayload() {
300
- const payload = resolverPayloadStorage.getStore();
301
- if (payload === void 0 || isOnlyMemoryPayload(payload)) return;
302
- return payload;
303
- }
304
- function useContext() {
305
- return useResolverPayload()?.context;
306
- }
307
- function useMemoizationMap() {
308
- const payload = resolverPayloadStorage.getStore();
309
- if (payload == null) return;
310
- if (isOnlyMemoryPayload(payload)) return payload.memoization;
311
- return ContextMemoization.assignMemoizationMap(payload.context);
312
- }
313
- var ContextMemoization = class {
314
- constructor(getter, options = {}) {
315
- this.getter = getter;
316
- this.getter = getter;
317
- this.getMemoizationMap = options.getMemoizationMap ?? useMemoizationMap;
318
- this.key = options.key ?? this.getter;
319
- }
320
- getMemoizationMap;
321
- key;
322
- /**
323
- * Get the value in memoization or call the getter function
324
- * @returns the value of the getter function
325
- */
326
- get() {
327
- const map = this.getMemoizationMap();
328
- if (!map) return this.getter();
329
- if (!map.has(this.key)) {
330
- map.set(this.key, this.getter());
331
- }
332
- return map.get(this.key);
333
- }
334
- /**
335
- * Clear the memoization
336
- * @returns true if the memoization is cleared, undefined if the context is not found
337
- */
338
- clear() {
339
- const map = this.getMemoizationMap();
340
- if (!map) return;
341
- return map.delete(this.key);
342
- }
343
- /**
344
- * Check if the memoization exists
345
- * @returns true if the memoization exists, undefined if the context is not found
346
- */
347
- exists() {
348
- const map = this.getMemoizationMap();
349
- if (!map) return;
350
- return map.has(this.key);
351
- }
352
- /**
353
- * Set a new value to the memoization
354
- * @param value the new value to set
355
- * @returns the memoization map or undefined if the context is not found
356
- */
357
- set(value) {
358
- const map = this.getMemoizationMap();
359
- if (!map) return;
360
- return map.set(this.key, value);
361
- }
362
- static assignMemoizationMap(target) {
363
- target[CONTEXT_MEMORY_MAP_KEY] ??= /* @__PURE__ */ new WeakMap();
364
- return target[CONTEXT_MEMORY_MAP_KEY];
365
- }
366
- };
367
- function createMemoization(...args) {
368
- const memoization = new ContextMemoization(...args);
369
- const callable = () => memoization.get();
370
- return Object.assign(callable, {
371
- get: () => memoization.get(),
372
- set: (value) => memoization.set(value),
373
- clear: () => memoization.clear(),
374
- exists: () => memoization.exists(),
375
- getter: memoization.getter
376
- });
377
- }
378
-
379
- // src/utils/object.ts
380
- function mapValue(record, fn) {
381
- const result = /* @__PURE__ */ Object.create(null);
382
- for (const key of Object.keys(record)) {
383
- const value = fn(record[key], key);
384
- if (value === SKIP) continue;
385
- result[key] = value;
386
- }
387
- return result;
388
- }
389
- var SKIP = Symbol.for("mapValue.skip");
390
- mapValue.SKIP = SKIP;
391
- function toObjMap(obj) {
392
- if (obj == null) {
393
- return /* @__PURE__ */ Object.create(null);
394
- }
395
- if (Object.getPrototypeOf(obj) === null) {
396
- return obj;
397
- }
398
- const map = /* @__PURE__ */ Object.create(null);
399
- for (const [key, value] of Object.entries(obj)) {
400
- map[key] = value;
401
- }
402
- return map;
403
- }
404
- function notNullish(x) {
405
- return x != null;
406
- }
407
- function deepMerge(...objects) {
408
- const result = {};
409
- for (const obj of objects) {
410
- if (obj == null) continue;
411
- for (const [key, value] of Object.entries(obj)) {
412
- if (value !== null && typeof value === "object") {
413
- if (Array.isArray(value)) {
414
- if (!Array.isArray(result[key])) {
415
- result[key] = [];
416
- }
417
- result[key] = [...result[key], ...value];
418
- } else {
419
- result[key] = deepMerge(result[key], value);
420
- }
506
+ const originType = getGraphQLType(origin);
507
+ if (originType instanceof GraphQLNonNull) {
508
+ return originType.ofType;
421
509
  } else {
422
- result[key] = value;
510
+ return originType;
423
511
  }
424
512
  }
425
- }
426
- return result;
427
- }
428
-
429
- // src/utils/string.ts
430
- function pascalCase(str) {
431
- return str.split(/[\s-_]+/).map(
432
- (word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
433
- ).join("");
434
- }
435
- function capitalize(str) {
436
- return str.slice(0, 1).toUpperCase() + str.slice(1);
513
+ };
437
514
  }
438
-
439
- // src/utils/error.ts
440
- function markErrorLocation(error, ...locations) {
441
- if (error instanceof Error) {
442
- error.message = markLocation(error.message, ...locations);
443
- }
444
- return error;
515
+ function getGraphQLType(silk2) {
516
+ if (GET_GRAPHQL_TYPE in silk2 && silk2[GET_GRAPHQL_TYPE] != null)
517
+ return silk2[GET_GRAPHQL_TYPE]();
518
+ const vendorWeavers = weaverContext.vendorWeavers;
519
+ if (vendorWeavers == null) throw new Error("Schema Weaver is not initialized");
520
+ const weaver = vendorWeavers.get(silk2["~standard"].vendor);
521
+ if (weaver == null)
522
+ throw new Error(
523
+ `Schema Weaver for ${silk2["~standard"].vendor} is not found`
524
+ );
525
+ return weaver.getGraphQLType(silk2);
445
526
  }
446
- function tryIn(func, ...locations) {
447
- try {
448
- return func();
449
- } catch (error) {
450
- throw markErrorLocation(error, ...locations);
451
- }
527
+ function parseSilk(silk2, input) {
528
+ return silk2["~standard"].validate(input);
452
529
  }
453
- function markLocation(message, ...locations) {
454
- if (locations.length === 0) {
455
- return message;
456
- }
457
- const [existingPrefix, newMessage] = (() => {
458
- const existingPrefixPattern = /^\[(.*?)\]/;
459
- const match = existingPrefixPattern.exec(message);
460
- if (match) return [match[1], message.slice(match[0].length).trim()];
461
- return [void 0, message];
462
- })();
463
- const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
464
- return `[${combinedLocation}] ${newMessage}`;
530
+ function isSilk(target) {
531
+ if (typeof target !== "object") return false;
532
+ if (target == null) return false;
533
+ if (GET_GRAPHQL_TYPE in target) return true;
534
+ if (!("~standard" in target)) return false;
535
+ return "vendor" in target["~standard"] && typeof target["~standard"].vendor === "string" && "version" in target["~standard"] && typeof target["~standard"].version === "number";
465
536
  }
466
537
 
467
- // src/utils/loader.ts
468
- var EasyDataLoader = class _EasyDataLoader {
469
- constructor(batchLoadFn) {
470
- this.batchLoadFn = batchLoadFn;
471
- this.queue = [];
472
- this.cache = /* @__PURE__ */ new Map();
473
- this.resolvers = /* @__PURE__ */ new Map();
474
- }
475
- queue;
476
- cache;
477
- resolvers;
478
- load(key) {
479
- const existing = this.cache.get(key);
480
- if (existing) return existing;
481
- const promise = new Promise((resolve, reject) => {
482
- this.queue.push(key);
483
- this.resolvers.set(key, [resolve, reject]);
484
- this.nextTickBatchLoad();
485
- });
486
- this.cache.set(key, promise);
487
- return promise;
488
- }
489
- clear() {
490
- this.queue = [];
491
- this.cache = /* @__PURE__ */ new Map();
492
- this.resolvers = /* @__PURE__ */ new Map();
493
- }
494
- clearByKey(key) {
495
- this.queue = this.queue.filter((k) => k !== key);
496
- this.cache.delete(key);
497
- this.resolvers.delete(key);
498
- }
499
- async executeBatchLoad() {
500
- if (this.queue.length === 0) return;
501
- const [keys, resolvers] = [this.queue, this.resolvers];
502
- this.queue = [];
503
- this.resolvers = /* @__PURE__ */ new Map();
504
- try {
505
- const list = await this.batchLoadFn(keys);
506
- for (let i = 0; i < list.length; i++) {
507
- const data = list[i];
508
- const resolve = resolvers.get(keys[i])?.[0];
509
- const reject = resolvers.get(keys[i])?.[1];
510
- if (data instanceof Error) {
511
- reject?.(data);
512
- } else {
513
- resolve?.(data);
514
- }
515
- }
516
- } catch (error) {
517
- for (const key of keys) {
518
- const reject = resolvers.get(key)?.[1];
519
- reject?.(error);
520
- }
521
- }
522
- }
523
- nextTickPromise;
524
- nextTickBatchLoad() {
525
- this.nextTickPromise ??= _EasyDataLoader.nextTick().then(() => this.executeBatchLoad()).finally(() => this.nextTickPromise = void 0);
526
- return this.nextTickPromise;
527
- }
528
- static nextTick() {
529
- return new Promise((resolve) => setTimeout(resolve));
530
- }
531
- };
532
-
533
538
  // src/resolver/input.ts
534
539
  import { GraphQLError } from "graphql";
535
540
  function createInputParser(schema, value) {
@@ -544,6 +549,9 @@ function createInputParser(schema, value) {
544
549
  get: () => result,
545
550
  set: (value2) => result = value2
546
551
  });
552
+ Object.defineProperty(parse, "getResult", {
553
+ value: async () => getStandardValue(await parse())
554
+ });
547
555
  return parse;
548
556
  }
549
557
  function parseInputValue(inputSchema, input) {
@@ -623,9 +631,6 @@ var FieldChainFactory = class _FieldChainFactory extends BaseChainFactory {
623
631
  clone(options) {
624
632
  return new _FieldChainFactory({ ...this.options, ...options });
625
633
  }
626
- use(...middlewares) {
627
- return super.use(...middlewares);
628
- }
629
634
  output(output) {
630
635
  return new _FieldChainFactory({ ...this.options, output });
631
636
  }
@@ -633,11 +638,44 @@ var FieldChainFactory = class _FieldChainFactory extends BaseChainFactory {
633
638
  return new _FieldChainFactory({ ...this.options, input });
634
639
  }
635
640
  resolve(resolve) {
636
- return createField(this.options?.output, {
641
+ if (!this.options?.output) throw new Error("Output is required");
642
+ return createField(this.options.output, {
637
643
  ...this.options,
638
644
  resolve
639
645
  });
640
646
  }
647
+ load(resolve) {
648
+ if (!this.options?.output) throw new Error("Output is required");
649
+ const useUnifiedParseInput = createMemoization(() => ({ current: void 0 }));
650
+ const useUserLoader = createMemoization(
651
+ () => new EasyDataLoader(
652
+ async (parents) => resolve(
653
+ parents,
654
+ await useUnifiedParseInput().current?.getResult()
655
+ )
656
+ )
657
+ );
658
+ const operation = "field";
659
+ return meta({
660
+ ...getFieldOptions(this.options),
661
+ operation,
662
+ input: this.options.input,
663
+ output: this.options.output,
664
+ resolve: async (parent, inputValue, extraOptions) => {
665
+ const unifiedParseInput = useUnifiedParseInput();
666
+ unifiedParseInput.current ??= createInputParser(
667
+ this.options?.input,
668
+ inputValue
669
+ );
670
+ const parseInput = unifiedParseInput.current;
671
+ return applyMiddlewares(
672
+ compose(extraOptions?.middlewares, this.options?.middlewares),
673
+ async () => useUserLoader().load(parent),
674
+ { parseInput, parent, outputSilk: this.output, operation }
675
+ );
676
+ }
677
+ });
678
+ }
641
679
  };
642
680
  var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
643
681
  static methods() {
@@ -652,9 +690,6 @@ var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
652
690
  clone(options) {
653
691
  return new _QueryChainFactory({ ...this.options, ...options });
654
692
  }
655
- use(...middlewares) {
656
- return super.use(...middlewares);
657
- }
658
693
  output(output) {
659
694
  return new _QueryChainFactory({ ...this.options, output });
660
695
  }
@@ -662,7 +697,8 @@ var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
662
697
  return new _QueryChainFactory({ ...this.options, input });
663
698
  }
664
699
  resolve(resolve) {
665
- return createQuery(this.options?.output, {
700
+ if (!this.options?.output) throw new Error("Output is required");
701
+ return createQuery(this.options.output, {
666
702
  ...this.options,
667
703
  resolve
668
704
  });
@@ -681,9 +717,6 @@ var MutationChainFactory = class _MutationChainFactory extends BaseChainFactory
681
717
  clone(options) {
682
718
  return new _MutationChainFactory({ ...this.options, ...options });
683
719
  }
684
- use(...middlewares) {
685
- return super.use(...middlewares);
686
- }
687
720
  output(output) {
688
721
  return new _MutationChainFactory({ ...this.options, output });
689
722
  }
@@ -691,7 +724,8 @@ var MutationChainFactory = class _MutationChainFactory extends BaseChainFactory
691
724
  return new _MutationChainFactory({ ...this.options, input });
692
725
  }
693
726
  resolve(resolve) {
694
- return createMutation(this.options?.output, {
727
+ if (!this.options?.output) throw new Error("Output is required");
728
+ return createMutation(this.options.output, {
695
729
  ...this.options,
696
730
  resolve
697
731
  });
@@ -710,9 +744,6 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
710
744
  clone(options) {
711
745
  return new _SubscriptionChainFactory({ ...this.options, ...options });
712
746
  }
713
- use(...middlewares) {
714
- return super.use(...middlewares);
715
- }
716
747
  output(output) {
717
748
  return new _SubscriptionChainFactory({ ...this.options, output });
718
749
  }
@@ -721,14 +752,16 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
721
752
  }
722
753
  subscribe(subscribe) {
723
754
  const options = this.options;
724
- const subscription2 = createSubscription(options?.output, {
755
+ const output = this.options?.output;
756
+ if (!output) throw new Error("Output is required");
757
+ const subscription2 = createSubscription(output, {
725
758
  ...options,
726
759
  subscribe
727
760
  });
728
- const subscriptionResolve = subscription2.resolve;
761
+ const subscriptionResolve = subscription2["~meta"].resolve;
729
762
  const resolve = (...args) => {
730
763
  if (args.length === 1 && typeof args[0] === "function") {
731
- return createSubscription(options?.output, {
764
+ return createSubscription(output, {
732
765
  ...options,
733
766
  resolve: args[0],
734
767
  subscribe
@@ -739,6 +772,66 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
739
772
  return Object.assign(subscription2, { resolve });
740
773
  }
741
774
  };
775
+ var QueryFactoryWithResolve = class _QueryFactoryWithResolve extends BaseChainFactory {
776
+ constructor(output, options) {
777
+ super(options);
778
+ this.output = output;
779
+ this.options = options;
780
+ }
781
+ get "~meta"() {
782
+ return loom.query(this.output, this.options)["~meta"];
783
+ }
784
+ clone(options) {
785
+ return new _QueryFactoryWithResolve(this.output, {
786
+ ...this.options,
787
+ ...options
788
+ });
789
+ }
790
+ input(input) {
791
+ return new _QueryFactoryWithResolve(this.output, {
792
+ ...this.options,
793
+ input
794
+ });
795
+ }
796
+ };
797
+ var MutationFactoryWithResolve = class _MutationFactoryWithResolve extends BaseChainFactory {
798
+ constructor(output, options) {
799
+ super(options);
800
+ this.output = output;
801
+ this.options = options;
802
+ }
803
+ get "~meta"() {
804
+ return loom.mutation(this.output, this.options)["~meta"];
805
+ }
806
+ clone(options) {
807
+ return new _MutationFactoryWithResolve(this.output, {
808
+ ...this.options,
809
+ ...options
810
+ });
811
+ }
812
+ input(input) {
813
+ return new _MutationFactoryWithResolve(this.output, {
814
+ ...this.options,
815
+ input
816
+ });
817
+ }
818
+ };
819
+ var FieldFactoryWithResolve = class _FieldFactoryWithResolve extends BaseChainFactory {
820
+ constructor(output, options) {
821
+ super(options);
822
+ this.output = output;
823
+ this.options = options;
824
+ }
825
+ get "~meta"() {
826
+ return loom.field(this.output, this.options)["~meta"];
827
+ }
828
+ clone(options) {
829
+ return new _FieldFactoryWithResolve(this.output, {
830
+ ...this.options,
831
+ ...options
832
+ });
833
+ }
834
+ };
742
835
 
743
836
  // src/resolver/resolver.ts
744
837
  var createQuery = (output, resolveOrOptions) => {
@@ -746,8 +839,8 @@ var createQuery = (output, resolveOrOptions) => {
746
839
  return new QueryChainFactory({ output });
747
840
  }
748
841
  const options = getOperationOptions(resolveOrOptions);
749
- const type = "query";
750
- return {
842
+ const operation = "query";
843
+ return meta({
751
844
  ...getFieldOptions(options),
752
845
  input: options.input,
753
846
  output,
@@ -756,11 +849,11 @@ var createQuery = (output, resolveOrOptions) => {
756
849
  return applyMiddlewares(
757
850
  compose(extraOptions?.middlewares, options.middlewares),
758
851
  async () => options.resolve(getStandardValue(await parseInput())),
759
- { parseInput, parent: void 0, outputSilk: output, type }
852
+ { parseInput, parent: void 0, outputSilk: output, operation }
760
853
  );
761
854
  },
762
- type
763
- };
855
+ operation
856
+ });
764
857
  };
765
858
  var query = Object.assign(
766
859
  createQuery,
@@ -771,8 +864,8 @@ var createMutation = (output, resolveOrOptions) => {
771
864
  return new MutationChainFactory({ output });
772
865
  }
773
866
  const options = getOperationOptions(resolveOrOptions);
774
- const type = "mutation";
775
- return {
867
+ const operation = "mutation";
868
+ return meta({
776
869
  ...getFieldOptions(options),
777
870
  input: options.input,
778
871
  output,
@@ -781,11 +874,11 @@ var createMutation = (output, resolveOrOptions) => {
781
874
  return applyMiddlewares(
782
875
  compose(extraOptions?.middlewares, options.middlewares),
783
876
  async () => options.resolve(getStandardValue(await parseInput())),
784
- { parseInput, parent: void 0, outputSilk: output, type }
877
+ { parseInput, parent: void 0, outputSilk: output, operation }
785
878
  );
786
879
  },
787
- type
788
- };
880
+ operation
881
+ });
789
882
  };
790
883
  var mutation = Object.assign(
791
884
  createMutation,
@@ -796,8 +889,8 @@ var createField = (output, resolveOrOptions) => {
796
889
  return new FieldChainFactory({ output });
797
890
  }
798
891
  const options = getOperationOptions(resolveOrOptions);
799
- const type = "field";
800
- return {
892
+ const operation = "field";
893
+ return meta({
801
894
  ...getFieldOptions(options),
802
895
  input: options.input,
803
896
  output,
@@ -806,11 +899,11 @@ var createField = (output, resolveOrOptions) => {
806
899
  return applyMiddlewares(
807
900
  compose(extraOptions?.middlewares, options.middlewares),
808
901
  async () => options.resolve(parent, getStandardValue(await parseInput())),
809
- { parseInput, parent, outputSilk: output, type }
902
+ { parseInput, parent, outputSilk: output, operation }
810
903
  );
811
904
  },
812
- type
813
- };
905
+ operation
906
+ });
814
907
  };
815
908
  var field = Object.assign(
816
909
  createField,
@@ -818,13 +911,13 @@ var field = Object.assign(
818
911
  FieldChainFactory.methods()
819
912
  );
820
913
  var defaultSubscriptionResolve = (source) => source;
821
- var createSubscription = (output, subscribeOrOptions) => {
914
+ function createSubscription(output, subscribeOrOptions) {
822
915
  if (subscribeOrOptions == null) {
823
916
  return new SubscriptionChainFactory({ output });
824
917
  }
825
918
  const options = getSubscriptionOptions(subscribeOrOptions);
826
- const type = "subscription";
827
- return {
919
+ const operation = "subscription";
920
+ return meta({
828
921
  ...getFieldOptions(options),
829
922
  input: options.input,
830
923
  output,
@@ -836,62 +929,66 @@ var createSubscription = (output, subscribeOrOptions) => {
836
929
  options.middlewares
837
930
  ),
838
931
  async () => options.subscribe(getStandardValue(await parseInput())),
839
- { parseInput, parent: void 0, outputSilk: output, type }
932
+ { parseInput, parent: void 0, outputSilk: output, operation }
840
933
  );
841
934
  },
842
935
  resolve: options.resolve ?? defaultSubscriptionResolve,
843
- type
844
- };
845
- };
936
+ operation
937
+ });
938
+ }
846
939
  var subscription = Object.assign(
847
940
  createSubscription,
848
941
  SubscriptionChainFactory.methods()
849
942
  );
850
- var ResolverOptionsMap = /* @__PURE__ */ new WeakMap();
851
- function baseResolver(operations, options) {
852
- const record = {};
853
- Object.entries(operations).forEach(([name, operation]) => {
854
- record[name] = extraOperationOptions(operation, options);
855
- });
856
- if (options) ResolverOptionsMap.set(record, options);
857
- return record;
858
- }
859
- function extraOperationOptions(operation, options) {
943
+ function extraOperationOptions(field2, options) {
944
+ if (typeof field2 === "symbol") return field2;
860
945
  const composeMiddlewares = (extraOptions) => compose(extraOptions?.middlewares, options?.middlewares);
861
- if (typeof operation === "symbol") return operation;
862
- switch (operation.type) {
946
+ switch (field2["~meta"].operation) {
863
947
  case "field":
864
948
  return {
865
- ...operation,
866
- resolve: (parent, input, extraOptions) => operation.resolve(parent, input, {
867
- ...extraOptions,
868
- middlewares: composeMiddlewares(extraOptions)
869
- })
949
+ ...field2,
950
+ "~meta": {
951
+ ...field2["~meta"],
952
+ resolve: (parent, input, extraOptions) => field2["~meta"].resolve(parent, input, {
953
+ ...extraOptions,
954
+ middlewares: composeMiddlewares(extraOptions)
955
+ })
956
+ }
870
957
  };
871
958
  case "subscription":
872
959
  return {
873
- ...operation,
874
- subscribe: (input, extraOptions) => operation.subscribe(input, {
875
- ...extraOptions,
876
- middlewares: composeMiddlewares(extraOptions)
877
- })
960
+ ...field2,
961
+ "~meta": {
962
+ ...field2["~meta"],
963
+ subscribe: (input, extraOptions) => field2["~meta"].subscribe(
964
+ input,
965
+ {
966
+ ...extraOptions,
967
+ middlewares: composeMiddlewares(extraOptions)
968
+ }
969
+ )
970
+ }
878
971
  };
879
972
  default:
880
973
  return {
881
- ...operation,
882
- resolve: (input, extraOptions) => operation.resolve(input, {
883
- ...extraOptions,
884
- middlewares: composeMiddlewares(extraOptions)
885
- })
974
+ ...field2,
975
+ "~meta": {
976
+ ...field2["~meta"],
977
+ resolve: (input, extraOptions) => field2["~meta"].resolve(input, {
978
+ ...extraOptions,
979
+ middlewares: composeMiddlewares(extraOptions)
980
+ })
981
+ }
886
982
  };
887
983
  }
888
984
  }
889
985
  var resolver = Object.assign(
890
- baseResolver,
986
+ (operations, options) => new ChainResolver(operations, options),
891
987
  {
892
- of: (parent, operations, options) => baseResolver(
988
+ of: (parent, operations, options) => new ObjectChainResolver(
989
+ parent,
893
990
  operations,
894
- { ...options, parent }
991
+ options
895
992
  )
896
993
  }
897
994
  );
@@ -902,93 +999,69 @@ var loom = {
902
999
  subscription,
903
1000
  mutation
904
1001
  };
905
-
906
- // src/helper/create-loom.ts
907
- function toSilkInput(schema, toSilk, isSchema) {
908
- if (schema == null) {
909
- return schema;
1002
+ var ChainResolver = class {
1003
+ meta;
1004
+ constructor(fields, options) {
1005
+ this.meta = {
1006
+ [IS_RESOLVER]: true,
1007
+ fields,
1008
+ options
1009
+ };
910
1010
  }
911
- if (isSchema(schema)) {
912
- return toSilk(schema);
1011
+ get "~meta"() {
1012
+ const fields = {};
1013
+ Object.entries(this.meta.fields).forEach(([name, field2]) => {
1014
+ if (field2 === FIELD_HIDDEN) {
1015
+ fields[name] = field2;
1016
+ } else {
1017
+ fields[name] = extraOperationOptions(field2, this.meta.options);
1018
+ }
1019
+ });
1020
+ return {
1021
+ ...this.meta,
1022
+ fields
1023
+ };
913
1024
  }
914
- const record = {};
915
- for (const [key, value] of Object.entries(schema)) {
916
- record[key] = toSilk(value);
1025
+ use(...middlewares) {
1026
+ this.meta.options ??= {};
1027
+ this.meta.options.middlewares ??= [];
1028
+ this.meta.options.middlewares.push(...middlewares);
1029
+ return this;
917
1030
  }
918
- return record;
919
- }
920
- function createResolverFactory(toSilk) {
921
- return Object.assign(baseResolver, {
922
- of: (parent, operations, options) => baseResolver(
923
- operations,
924
- { ...options, parent: toSilk(parent) }
925
- )
926
- });
927
- }
928
- function createFieldFactory(toSilk, isSchema) {
929
- const baseFieldFunc = (output, resolveOrOptions) => {
930
- if (resolveOrOptions == null) {
931
- return new FieldChainFactory({ output: toSilk(output) });
932
- }
933
- const options = getOperationOptions(
934
- resolveOrOptions
935
- );
936
- return field(toSilk(output), {
937
- ...options,
938
- input: toSilkInput(options.input, toSilk, isSchema)
939
- });
940
- };
941
- return Object.assign(
942
- baseFieldFunc,
943
- { hidden: FIELD_HIDDEN },
944
- FieldChainFactory.methods()
945
- );
946
- }
947
- function createQueryFactory(toSilk, isSchema) {
948
- return (output, resolveOrOptions) => {
949
- if (resolveOrOptions == null) {
950
- return new QueryChainFactory({ output: toSilk(output) });
951
- }
952
- const options = getOperationOptions(resolveOrOptions);
953
- return query(toSilk(output), {
954
- ...options,
955
- input: toSilkInput(options.input, toSilk, isSchema)
956
- });
957
- };
958
- }
959
- function createMutationFactory(toSilk, isSchema) {
960
- return (output, resolveOrOptions) => {
961
- if (resolveOrOptions == null) {
962
- return new MutationChainFactory({ output: toSilk(output) });
963
- }
964
- const options = getOperationOptions(resolveOrOptions);
965
- return mutation(toSilk(output), {
966
- ...options,
967
- input: toSilkInput(options.input, toSilk, isSchema)
968
- });
969
- };
970
- }
971
- function createSubscriptionFactory(toSilk, isSchema) {
972
- return (output, resolveOrOptions) => {
973
- if (resolveOrOptions == null) {
974
- return new SubscriptionChainFactory({ output: toSilk(output) });
975
- }
976
- const options = getSubscriptionOptions(resolveOrOptions);
977
- return subscription(toSilk(output), {
978
- ...options,
979
- input: toSilkInput(options.input, toSilk, isSchema)
1031
+ toExecutor() {
1032
+ const fields = this["~meta"].fields;
1033
+ const executor = {};
1034
+ Object.entries(fields).forEach(([name, field2]) => {
1035
+ if (field2 === FIELD_HIDDEN) return;
1036
+ executor[name] = field2["~meta"].resolve;
980
1037
  });
981
- };
982
- }
983
- function createLoom(toSilk, isSchema) {
984
- return {
985
- query: createQueryFactory(toSilk, isSchema),
986
- mutation: createMutationFactory(toSilk, isSchema),
987
- field: createFieldFactory(toSilk, isSchema),
988
- resolver: createResolverFactory(toSilk),
989
- subscription: createSubscriptionFactory(toSilk, isSchema)
990
- };
991
- }
1038
+ return executor;
1039
+ }
1040
+ };
1041
+ var ObjectChainResolver = class extends ChainResolver {
1042
+ meta;
1043
+ constructor(parent, fields, options) {
1044
+ super(fields, options);
1045
+ this.meta = {
1046
+ [IS_RESOLVER]: true,
1047
+ fields,
1048
+ parent,
1049
+ options
1050
+ };
1051
+ }
1052
+ get "~meta"() {
1053
+ return super["~meta"];
1054
+ }
1055
+ extensions(extensions) {
1056
+ this.meta.options ??= {};
1057
+ this.meta.options.extensions ??= {};
1058
+ this.meta.options.extensions = {
1059
+ ...this.meta.options.extensions,
1060
+ ...extensions
1061
+ };
1062
+ return this;
1063
+ }
1064
+ };
992
1065
 
993
1066
  // src/schema/object.ts
994
1067
  import {
@@ -1191,13 +1264,13 @@ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
1191
1264
  toFieldConfig(field2, fieldName) {
1192
1265
  try {
1193
1266
  const outputType = this.getCacheType(
1194
- getGraphQLType(field2.output),
1267
+ getGraphQLType(field2["~meta"].output),
1195
1268
  fieldName
1196
1269
  );
1197
1270
  return {
1198
1271
  ...extract(field2),
1199
1272
  type: outputType,
1200
- args: inputToArgs(field2.input, {
1273
+ args: inputToArgs(field2["~meta"].input, {
1201
1274
  fieldName: fieldName ? parentName(this.name) + fieldName : void 0
1202
1275
  }),
1203
1276
  ...this.provideForResolve(field2),
@@ -1208,27 +1281,31 @@ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
1208
1281
  }
1209
1282
  }
1210
1283
  provideForResolve(field2) {
1211
- if (field2?.resolve == null) return;
1212
- if (field2.resolve === defaultSubscriptionResolve)
1284
+ if (field2?.["~meta"]?.resolve == null) return;
1285
+ if (field2["~meta"].resolve === defaultSubscriptionResolve)
1213
1286
  return { resolve: defaultSubscriptionResolve };
1214
- const resolve = field2.type === "field" ? (root, args, context, info) => resolverPayloadStorage.run(
1287
+ const resolve = field2["~meta"].operation === "field" ? (root, args, context, info) => resolverPayloadStorage.run(
1215
1288
  { root, args, context, info, field: field2 },
1216
- () => field2.resolve(root, args, this.resolverOptions)
1217
- ) : field2.type === "subscription" ? (root, args, context, info) => resolverPayloadStorage.run(
1289
+ () => field2["~meta"].resolve(root, args, this.resolverOptions)
1290
+ ) : field2["~meta"].operation === "subscription" ? (root, args, context, info) => resolverPayloadStorage.run(
1218
1291
  { root, args, context, info, field: field2 },
1219
- () => field2.resolve(root, args)
1292
+ () => field2["~meta"].resolve(root, args)
1220
1293
  ) : (root, args, context, info) => resolverPayloadStorage.run(
1221
1294
  { root, args, context, info, field: field2 },
1222
- () => field2.resolve(args, this.resolverOptions)
1295
+ () => field2["~meta"].resolve(args, this.resolverOptions)
1223
1296
  );
1224
1297
  return { resolve };
1225
1298
  }
1226
1299
  provideForSubscribe(field2) {
1227
- if (field2?.subscribe == null) return;
1300
+ if (field2?.["~meta"]?.subscribe == null)
1301
+ return;
1228
1302
  return {
1229
1303
  subscribe: (root, args, context, info) => resolverPayloadStorage.run(
1230
1304
  { root, args, context, info, field: field2 },
1231
- () => field2.subscribe?.(args, this.resolverOptions)
1305
+ () => field2["~meta"].subscribe?.(
1306
+ args,
1307
+ this.resolverOptions
1308
+ )
1232
1309
  )
1233
1310
  };
1234
1311
  }
@@ -1240,11 +1317,8 @@ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
1240
1317
  return { resolverOptions, weaverContext: weaverContext2 };
1241
1318
  }
1242
1319
  };
1243
- function extract({
1244
- deprecationReason,
1245
- description,
1246
- extensions
1247
- }) {
1320
+ function extract(field2) {
1321
+ const { deprecationReason, description, extensions } = field2["~meta"];
1248
1322
  return {
1249
1323
  description,
1250
1324
  deprecationReason,
@@ -1324,6 +1398,7 @@ function parentName(name) {
1324
1398
 
1325
1399
  // src/schema/schema-weaver.ts
1326
1400
  function isSchemaVendorWeaver(some) {
1401
+ if (some == null) return false;
1327
1402
  if (typeof some !== "object" && typeof some !== "function") return false;
1328
1403
  if (!("getGraphQLType" in some) || typeof some.getGraphQLType !== "function")
1329
1404
  return false;
@@ -1415,8 +1490,8 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
1415
1490
  return schema;
1416
1491
  }
1417
1492
  addResolver(resolver2) {
1418
- const resolverOptions = ResolverOptionsMap.get(resolver2);
1419
- const parent = resolverOptions?.parent;
1493
+ const resolverOptions = resolver2["~meta"].options;
1494
+ const parent = resolver2["~meta"].parent;
1420
1495
  const parentObject = (() => {
1421
1496
  if (parent == null) return void 0;
1422
1497
  let gqlType = getGraphQLType(parent);
@@ -1435,16 +1510,18 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
1435
1510
  })();
1436
1511
  if (resolverOptions?.extensions && parentObject)
1437
1512
  parentObject.mergeExtensions(resolverOptions.extensions);
1438
- Object.entries(resolver2).forEach(([name, operation]) => {
1439
- if (operation === FIELD_HIDDEN) {
1513
+ Object.entries(resolver2["~meta"].fields).forEach(([name, field2]) => {
1514
+ if (field2 === FIELD_HIDDEN) {
1440
1515
  if (parentObject == null) return;
1441
1516
  parentObject.hideField(name);
1442
- } else if (operation.type === "field") {
1517
+ } else if (field2["~meta"].operation === "field") {
1443
1518
  if (parentObject == null) return;
1444
- parentObject.addField(name, operation);
1519
+ parentObject.addField(name, field2);
1445
1520
  } else {
1446
- const operationObject = this.getOperationObject(operation.type);
1447
- operationObject.addField(name, operation);
1521
+ const operationObject = this.getOperationObject(
1522
+ field2["~meta"].operation
1523
+ );
1524
+ operationObject.addField(name, field2);
1448
1525
  }
1449
1526
  });
1450
1527
  return this;
@@ -1498,7 +1575,7 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
1498
1575
  }
1499
1576
  } else if (isSilk(item)) {
1500
1577
  silks.add(item);
1501
- } else {
1578
+ } else if (item["~meta"][IS_RESOLVER]) {
1502
1579
  resolvers.add(item);
1503
1580
  }
1504
1581
  }
@@ -1552,31 +1629,33 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
1552
1629
  return interfaceType;
1553
1630
  }
1554
1631
  export {
1632
+ BaseChainFactory,
1633
+ ChainResolver,
1555
1634
  ContextMemoization,
1556
1635
  EasyDataLoader,
1636
+ FieldChainFactory,
1637
+ FieldFactoryWithResolve,
1557
1638
  GraphQLSchemaLoom,
1558
1639
  LoomObjectType,
1640
+ MutationChainFactory,
1641
+ MutationFactoryWithResolve,
1559
1642
  OPERATION_OBJECT_NAMES,
1560
- ResolverOptionsMap,
1643
+ ObjectChainResolver,
1644
+ QueryChainFactory,
1645
+ QueryFactoryWithResolve,
1561
1646
  symbols_exports as SYMBOLS,
1647
+ SubscriptionChainFactory,
1562
1648
  applyMiddlewares,
1563
- baseResolver,
1564
1649
  capitalize,
1565
1650
  collectName,
1566
1651
  collectNames,
1567
1652
  compose,
1568
1653
  createField,
1569
- createFieldFactory,
1570
1654
  createInputParser,
1571
- createLoom,
1572
1655
  createMemoization,
1573
1656
  createMutation,
1574
- createMutationFactory,
1575
1657
  createQuery,
1576
- createQueryFactory,
1577
- createResolverFactory,
1578
1658
  createSubscription,
1579
- createSubscriptionFactory,
1580
1659
  deepMerge,
1581
1660
  defaultSubscriptionResolve,
1582
1661
  ensureInputObjectType,
@@ -1599,6 +1678,7 @@ export {
1599
1678
  mapValue,
1600
1679
  markErrorLocation,
1601
1680
  markLocation,
1681
+ meta,
1602
1682
  mutation,
1603
1683
  nonNullSilk,
1604
1684
  notNullish,