@gqloom/core 0.7.2 → 0.8.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 +606 -523
- package/dist/index.d.cts +389 -350
- package/dist/index.d.ts +389 -350
- package/dist/index.js +600 -520
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -20,31 +20,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
BaseChainFactory: () => BaseChainFactory,
|
|
24
|
+
ChainResolver: () => ChainResolver,
|
|
23
25
|
ContextMemoization: () => ContextMemoization,
|
|
24
26
|
EasyDataLoader: () => EasyDataLoader,
|
|
27
|
+
FieldChainFactory: () => FieldChainFactory,
|
|
28
|
+
FieldFactoryWithResolve: () => FieldFactoryWithResolve,
|
|
25
29
|
GraphQLSchemaLoom: () => GraphQLSchemaLoom,
|
|
26
30
|
LoomObjectType: () => LoomObjectType,
|
|
31
|
+
MutationChainFactory: () => MutationChainFactory,
|
|
32
|
+
MutationFactoryWithResolve: () => MutationFactoryWithResolve,
|
|
27
33
|
OPERATION_OBJECT_NAMES: () => OPERATION_OBJECT_NAMES,
|
|
28
|
-
|
|
34
|
+
ObjectChainResolver: () => ObjectChainResolver,
|
|
35
|
+
QueryChainFactory: () => QueryChainFactory,
|
|
36
|
+
QueryFactoryWithResolve: () => QueryFactoryWithResolve,
|
|
29
37
|
SYMBOLS: () => symbols_exports,
|
|
38
|
+
SubscriptionChainFactory: () => SubscriptionChainFactory,
|
|
30
39
|
applyMiddlewares: () => applyMiddlewares,
|
|
31
|
-
baseResolver: () => baseResolver,
|
|
32
40
|
capitalize: () => capitalize,
|
|
33
41
|
collectName: () => collectName,
|
|
34
42
|
collectNames: () => collectNames,
|
|
35
43
|
compose: () => compose,
|
|
36
44
|
createField: () => createField,
|
|
37
|
-
createFieldFactory: () => createFieldFactory,
|
|
38
45
|
createInputParser: () => createInputParser,
|
|
39
|
-
createLoom: () => createLoom,
|
|
40
46
|
createMemoization: () => createMemoization,
|
|
41
47
|
createMutation: () => createMutation,
|
|
42
|
-
createMutationFactory: () => createMutationFactory,
|
|
43
48
|
createQuery: () => createQuery,
|
|
44
|
-
createQueryFactory: () => createQueryFactory,
|
|
45
|
-
createResolverFactory: () => createResolverFactory,
|
|
46
49
|
createSubscription: () => createSubscription,
|
|
47
|
-
createSubscriptionFactory: () => createSubscriptionFactory,
|
|
48
50
|
deepMerge: () => deepMerge,
|
|
49
51
|
defaultSubscriptionResolve: () => defaultSubscriptionResolve,
|
|
50
52
|
ensureInputObjectType: () => ensureInputObjectType,
|
|
@@ -67,6 +69,7 @@ __export(src_exports, {
|
|
|
67
69
|
mapValue: () => mapValue,
|
|
68
70
|
markErrorLocation: () => markErrorLocation,
|
|
69
71
|
markLocation: () => markLocation,
|
|
72
|
+
meta: () => meta,
|
|
70
73
|
mutation: () => mutation,
|
|
71
74
|
nonNullSilk: () => nonNullSilk,
|
|
72
75
|
notNullish: () => notNullish,
|
|
@@ -91,231 +94,6 @@ __export(src_exports, {
|
|
|
91
94
|
});
|
|
92
95
|
module.exports = __toCommonJS(src_exports);
|
|
93
96
|
|
|
94
|
-
// src/resolver/silk.ts
|
|
95
|
-
var import_graphql2 = require("graphql");
|
|
96
|
-
|
|
97
|
-
// src/schema/weaver-context.ts
|
|
98
|
-
var import_graphql = require("graphql");
|
|
99
|
-
|
|
100
|
-
// src/utils/symbols.ts
|
|
101
|
-
var symbols_exports = {};
|
|
102
|
-
__export(symbols_exports, {
|
|
103
|
-
CONTEXT_MEMORY_MAP_KEY: () => CONTEXT_MEMORY_MAP_KEY,
|
|
104
|
-
FIELD_HIDDEN: () => FIELD_HIDDEN,
|
|
105
|
-
GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
|
|
106
|
-
RESOLVER_OPTIONS_KEY: () => RESOLVER_OPTIONS_KEY,
|
|
107
|
-
WEAVER_CONFIG: () => WEAVER_CONFIG
|
|
108
|
-
});
|
|
109
|
-
var GET_GRAPHQL_TYPE = Symbol.for("gqloom.get_graphql_type");
|
|
110
|
-
var WEAVER_CONFIG = Symbol.for("gqloom.weaver_config");
|
|
111
|
-
var RESOLVER_OPTIONS_KEY = Symbol.for("gqloom.resolver-options");
|
|
112
|
-
var CONTEXT_MEMORY_MAP_KEY = Symbol.for("gqloom.context-memory");
|
|
113
|
-
var FIELD_HIDDEN = Symbol.for("gqloom.field-hidden");
|
|
114
|
-
|
|
115
|
-
// src/schema/weaver-context.ts
|
|
116
|
-
var ref;
|
|
117
|
-
var names = /* @__PURE__ */ new WeakMap();
|
|
118
|
-
function initWeaverContext() {
|
|
119
|
-
return {
|
|
120
|
-
id: initWeaverContext.increasingID++,
|
|
121
|
-
loomObjectMap: /* @__PURE__ */ new Map(),
|
|
122
|
-
loomUnionMap: /* @__PURE__ */ new Map(),
|
|
123
|
-
inputMap: /* @__PURE__ */ new Map(),
|
|
124
|
-
interfaceMap: /* @__PURE__ */ new Map(),
|
|
125
|
-
configs: /* @__PURE__ */ new Map(),
|
|
126
|
-
getConfig(key) {
|
|
127
|
-
return this.configs.get(key);
|
|
128
|
-
},
|
|
129
|
-
setConfig(config) {
|
|
130
|
-
const key = config[WEAVER_CONFIG];
|
|
131
|
-
this.configs.set(key, config);
|
|
132
|
-
},
|
|
133
|
-
deleteConfig(key) {
|
|
134
|
-
this.configs.delete(key);
|
|
135
|
-
},
|
|
136
|
-
names,
|
|
137
|
-
namedTypes: /* @__PURE__ */ new Map(),
|
|
138
|
-
memoNamedType(gqlTypeValue) {
|
|
139
|
-
const gqlType = gqlTypeValue;
|
|
140
|
-
if ((0, import_graphql.isObjectType)(gqlType) || (0, import_graphql.isUnionType)(gqlType) || (0, import_graphql.isEnumType)(gqlType) || (0, import_graphql.isScalarType)(gqlType)) {
|
|
141
|
-
this.namedTypes.set(gqlType.name, gqlType);
|
|
142
|
-
}
|
|
143
|
-
return gqlTypeValue;
|
|
144
|
-
},
|
|
145
|
-
getNamedType(name) {
|
|
146
|
-
return this.namedTypes.get(name);
|
|
147
|
-
},
|
|
148
|
-
vendorWeavers: /* @__PURE__ */ new Map()
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
initWeaverContext.increasingID = 1;
|
|
152
|
-
var weaverContext = {
|
|
153
|
-
get id() {
|
|
154
|
-
return ref?.id;
|
|
155
|
-
},
|
|
156
|
-
get loomObjectMap() {
|
|
157
|
-
return ref?.loomObjectMap;
|
|
158
|
-
},
|
|
159
|
-
get loomUnionMap() {
|
|
160
|
-
return ref?.loomUnionMap;
|
|
161
|
-
},
|
|
162
|
-
get inputMap() {
|
|
163
|
-
return ref?.inputMap;
|
|
164
|
-
},
|
|
165
|
-
get interfaceMap() {
|
|
166
|
-
return ref?.interfaceMap;
|
|
167
|
-
},
|
|
168
|
-
get configs() {
|
|
169
|
-
return ref?.configs;
|
|
170
|
-
},
|
|
171
|
-
get vendorWeavers() {
|
|
172
|
-
return ref?.vendorWeavers;
|
|
173
|
-
},
|
|
174
|
-
getConfig(key) {
|
|
175
|
-
return ref?.getConfig(key);
|
|
176
|
-
},
|
|
177
|
-
setConfig(config) {
|
|
178
|
-
ref?.setConfig(config);
|
|
179
|
-
},
|
|
180
|
-
deleteConfig(key) {
|
|
181
|
-
ref?.deleteConfig(key);
|
|
182
|
-
},
|
|
183
|
-
get value() {
|
|
184
|
-
return ref;
|
|
185
|
-
},
|
|
186
|
-
useConfig(config, callback) {
|
|
187
|
-
const context = weaverContext.value ?? initWeaverContext();
|
|
188
|
-
context.setConfig(config);
|
|
189
|
-
const result = provideWeaverContext(callback, context);
|
|
190
|
-
context.deleteConfig(config[WEAVER_CONFIG]);
|
|
191
|
-
return result;
|
|
192
|
-
},
|
|
193
|
-
names,
|
|
194
|
-
getNamedType(name) {
|
|
195
|
-
return ref?.getNamedType(name);
|
|
196
|
-
},
|
|
197
|
-
memoNamedType(gqlType) {
|
|
198
|
-
return ref?.memoNamedType(gqlType) ?? gqlType;
|
|
199
|
-
},
|
|
200
|
-
GraphQLTypes: /* @__PURE__ */ new WeakMap(),
|
|
201
|
-
getGraphQLType(origin) {
|
|
202
|
-
return this.GraphQLTypes.get(origin);
|
|
203
|
-
},
|
|
204
|
-
memoGraphQLType(origin, gqlType) {
|
|
205
|
-
this.GraphQLTypes.set(origin, gqlType);
|
|
206
|
-
return gqlType;
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
function provideWeaverContext(func, value) {
|
|
210
|
-
const lastRef = ref;
|
|
211
|
-
ref = value;
|
|
212
|
-
try {
|
|
213
|
-
return func();
|
|
214
|
-
} finally {
|
|
215
|
-
ref = lastRef;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
provideWeaverContext.inherit = (func) => {
|
|
219
|
-
const weaverContextRef = weaverContext.value;
|
|
220
|
-
return () => provideWeaverContext(func, weaverContextRef);
|
|
221
|
-
};
|
|
222
|
-
function collectNames(...namesList) {
|
|
223
|
-
const namesRecord = {};
|
|
224
|
-
for (const namesItem of namesList) {
|
|
225
|
-
for (const [name, schema] of Object.entries(namesItem)) {
|
|
226
|
-
names.set(schema, name);
|
|
227
|
-
namesRecord[name] = schema;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return namesRecord;
|
|
231
|
-
}
|
|
232
|
-
function collectName(name, schema) {
|
|
233
|
-
names.set(schema, name);
|
|
234
|
-
return schema;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// src/resolver/silk.ts
|
|
238
|
-
function silk(type, validate = (value) => ({
|
|
239
|
-
value: value ?? void 0
|
|
240
|
-
})) {
|
|
241
|
-
return {
|
|
242
|
-
[GET_GRAPHQL_TYPE]: typeof type === "function" ? type : () => type,
|
|
243
|
-
"~standard": {
|
|
244
|
-
version: 1,
|
|
245
|
-
vendor: "gqloom.silk",
|
|
246
|
-
validate
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
silk.parse = parseSilk;
|
|
251
|
-
silk.getType = getGraphQLType;
|
|
252
|
-
silk.nonNull = nonNullSilk;
|
|
253
|
-
silk.list = listSilk;
|
|
254
|
-
silk.nullable = nullableSilk;
|
|
255
|
-
function nonNullSilk(origin) {
|
|
256
|
-
return {
|
|
257
|
-
...origin,
|
|
258
|
-
[GET_GRAPHQL_TYPE]: () => {
|
|
259
|
-
const originType = getGraphQLType(origin);
|
|
260
|
-
if (originType instanceof import_graphql2.GraphQLNonNull) {
|
|
261
|
-
return originType;
|
|
262
|
-
} else {
|
|
263
|
-
return new import_graphql2.GraphQLNonNull(originType);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function listSilk(origin) {
|
|
269
|
-
return {
|
|
270
|
-
...origin,
|
|
271
|
-
[GET_GRAPHQL_TYPE]: () => {
|
|
272
|
-
let originType = getGraphQLType(origin);
|
|
273
|
-
if (originType instanceof import_graphql2.GraphQLNonNull && originType.ofType instanceof import_graphql2.GraphQLList) {
|
|
274
|
-
originType = originType.ofType.ofType;
|
|
275
|
-
}
|
|
276
|
-
if (originType instanceof import_graphql2.GraphQLList) {
|
|
277
|
-
originType = originType.ofType;
|
|
278
|
-
}
|
|
279
|
-
return new import_graphql2.GraphQLNonNull(new import_graphql2.GraphQLList(originType));
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function nullableSilk(origin) {
|
|
284
|
-
return {
|
|
285
|
-
...origin,
|
|
286
|
-
[GET_GRAPHQL_TYPE]: () => {
|
|
287
|
-
const originType = getGraphQLType(origin);
|
|
288
|
-
if (originType instanceof import_graphql2.GraphQLNonNull) {
|
|
289
|
-
return originType.ofType;
|
|
290
|
-
} else {
|
|
291
|
-
return originType;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
function getGraphQLType(silk2) {
|
|
297
|
-
if (GET_GRAPHQL_TYPE in silk2 && silk2[GET_GRAPHQL_TYPE] != null)
|
|
298
|
-
return silk2[GET_GRAPHQL_TYPE]();
|
|
299
|
-
const vendorWeavers = weaverContext.vendorWeavers;
|
|
300
|
-
if (vendorWeavers == null) throw new Error("Schema Weaver is not initialized");
|
|
301
|
-
const weaver = vendorWeavers.get(silk2["~standard"].vendor);
|
|
302
|
-
if (weaver == null)
|
|
303
|
-
throw new Error(
|
|
304
|
-
`Schema Weaver for ${silk2["~standard"].vendor} is not found`
|
|
305
|
-
);
|
|
306
|
-
return weaver.getGraphQLType(silk2);
|
|
307
|
-
}
|
|
308
|
-
function parseSilk(silk2, input) {
|
|
309
|
-
return silk2["~standard"].validate(input);
|
|
310
|
-
}
|
|
311
|
-
function isSilk(target) {
|
|
312
|
-
if (typeof target !== "object") return false;
|
|
313
|
-
if (target == null) return false;
|
|
314
|
-
if (GET_GRAPHQL_TYPE in target) return true;
|
|
315
|
-
if (!("~standard" in target)) return false;
|
|
316
|
-
return "vendor" in target["~standard"] && typeof target["~standard"].vendor === "string" && "version" in target["~standard"] && typeof target["~standard"].version === "number";
|
|
317
|
-
}
|
|
318
|
-
|
|
319
97
|
// src/utils/args.ts
|
|
320
98
|
function getOperationOptions(resolveOrOptions) {
|
|
321
99
|
if (typeof resolveOrOptions === "function") {
|
|
@@ -368,6 +146,25 @@ function compose(...lists) {
|
|
|
368
146
|
|
|
369
147
|
// src/utils/context.ts
|
|
370
148
|
var import_async_hooks = require("async_hooks");
|
|
149
|
+
|
|
150
|
+
// src/utils/symbols.ts
|
|
151
|
+
var symbols_exports = {};
|
|
152
|
+
__export(symbols_exports, {
|
|
153
|
+
CONTEXT_MEMORY_MAP_KEY: () => CONTEXT_MEMORY_MAP_KEY,
|
|
154
|
+
FIELD_HIDDEN: () => FIELD_HIDDEN,
|
|
155
|
+
GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
|
|
156
|
+
IS_RESOLVER: () => IS_RESOLVER,
|
|
157
|
+
RESOLVER_OPTIONS_KEY: () => RESOLVER_OPTIONS_KEY,
|
|
158
|
+
WEAVER_CONFIG: () => WEAVER_CONFIG
|
|
159
|
+
});
|
|
160
|
+
var GET_GRAPHQL_TYPE = Symbol.for("gqloom.get_graphql_type");
|
|
161
|
+
var WEAVER_CONFIG = Symbol.for("gqloom.weaver_config");
|
|
162
|
+
var RESOLVER_OPTIONS_KEY = Symbol.for("gqloom.resolver-options");
|
|
163
|
+
var IS_RESOLVER = Symbol.for("gqloom.is-resolver");
|
|
164
|
+
var CONTEXT_MEMORY_MAP_KEY = Symbol.for("gqloom.context-memory");
|
|
165
|
+
var FIELD_HIDDEN = Symbol.for("gqloom.field-hidden");
|
|
166
|
+
|
|
167
|
+
// src/utils/context.ts
|
|
371
168
|
function onlyMemoization() {
|
|
372
169
|
return { memoization: /* @__PURE__ */ new WeakMap(), isMemoization: true };
|
|
373
170
|
}
|
|
@@ -498,117 +295,328 @@ function deepMerge(...objects) {
|
|
|
498
295
|
result[key] = deepMerge(result[key], value);
|
|
499
296
|
}
|
|
500
297
|
} else {
|
|
501
|
-
result[key] = value;
|
|
298
|
+
result[key] = value;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
function meta(data) {
|
|
305
|
+
return { "~meta": data };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/utils/string.ts
|
|
309
|
+
function pascalCase(str) {
|
|
310
|
+
return str.split(/[\s-_]+/).map(
|
|
311
|
+
(word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
|
|
312
|
+
).join("");
|
|
313
|
+
}
|
|
314
|
+
function capitalize(str) {
|
|
315
|
+
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/utils/error.ts
|
|
319
|
+
function markErrorLocation(error, ...locations) {
|
|
320
|
+
if (error instanceof Error) {
|
|
321
|
+
error.message = markLocation(error.message, ...locations);
|
|
322
|
+
}
|
|
323
|
+
return error;
|
|
324
|
+
}
|
|
325
|
+
function tryIn(func, ...locations) {
|
|
326
|
+
try {
|
|
327
|
+
return func();
|
|
328
|
+
} catch (error) {
|
|
329
|
+
throw markErrorLocation(error, ...locations);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function markLocation(message, ...locations) {
|
|
333
|
+
if (locations.length === 0) {
|
|
334
|
+
return message;
|
|
335
|
+
}
|
|
336
|
+
const [existingPrefix, newMessage] = (() => {
|
|
337
|
+
const existingPrefixPattern = /^\[(.*?)\]/;
|
|
338
|
+
const match = existingPrefixPattern.exec(message);
|
|
339
|
+
if (match) return [match[1], message.slice(match[0].length).trim()];
|
|
340
|
+
return [void 0, message];
|
|
341
|
+
})();
|
|
342
|
+
const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
|
|
343
|
+
return `[${combinedLocation}] ${newMessage}`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/utils/loader.ts
|
|
347
|
+
var EasyDataLoader = class _EasyDataLoader {
|
|
348
|
+
constructor(batchLoadFn) {
|
|
349
|
+
this.batchLoadFn = batchLoadFn;
|
|
350
|
+
this.queue = [];
|
|
351
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
352
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
353
|
+
}
|
|
354
|
+
queue;
|
|
355
|
+
cache;
|
|
356
|
+
resolvers;
|
|
357
|
+
load(key) {
|
|
358
|
+
const existing = this.cache.get(key);
|
|
359
|
+
if (existing) return existing;
|
|
360
|
+
const promise = new Promise((resolve, reject) => {
|
|
361
|
+
this.queue.push(key);
|
|
362
|
+
this.resolvers.set(key, [resolve, reject]);
|
|
363
|
+
this.nextTickBatchLoad();
|
|
364
|
+
});
|
|
365
|
+
this.cache.set(key, promise);
|
|
366
|
+
return promise;
|
|
367
|
+
}
|
|
368
|
+
clear() {
|
|
369
|
+
this.queue = [];
|
|
370
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
371
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
372
|
+
}
|
|
373
|
+
clearByKey(key) {
|
|
374
|
+
this.queue = this.queue.filter((k) => k !== key);
|
|
375
|
+
this.cache.delete(key);
|
|
376
|
+
this.resolvers.delete(key);
|
|
377
|
+
}
|
|
378
|
+
async executeBatchLoad() {
|
|
379
|
+
if (this.queue.length === 0) return;
|
|
380
|
+
const [keys, resolvers] = [this.queue, this.resolvers];
|
|
381
|
+
this.queue = [];
|
|
382
|
+
this.resolvers = /* @__PURE__ */ new Map();
|
|
383
|
+
try {
|
|
384
|
+
const list = await this.batchLoadFn(keys);
|
|
385
|
+
for (let i = 0; i < list.length; i++) {
|
|
386
|
+
const data = list[i];
|
|
387
|
+
const resolve = resolvers.get(keys[i])?.[0];
|
|
388
|
+
const reject = resolvers.get(keys[i])?.[1];
|
|
389
|
+
if (data instanceof Error) {
|
|
390
|
+
reject?.(data);
|
|
391
|
+
} else {
|
|
392
|
+
resolve?.(data);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} catch (error) {
|
|
396
|
+
for (const key of keys) {
|
|
397
|
+
const reject = resolvers.get(key)?.[1];
|
|
398
|
+
reject?.(error);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
nextTickPromise;
|
|
403
|
+
nextTickBatchLoad() {
|
|
404
|
+
this.nextTickPromise ??= _EasyDataLoader.nextTick().then(() => this.executeBatchLoad()).finally(() => this.nextTickPromise = void 0);
|
|
405
|
+
return this.nextTickPromise;
|
|
406
|
+
}
|
|
407
|
+
static nextTick() {
|
|
408
|
+
return new Promise((resolve) => setTimeout(resolve));
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
// src/resolver/silk.ts
|
|
413
|
+
var import_graphql2 = require("graphql");
|
|
414
|
+
|
|
415
|
+
// src/schema/weaver-context.ts
|
|
416
|
+
var import_graphql = require("graphql");
|
|
417
|
+
var ref;
|
|
418
|
+
var names = /* @__PURE__ */ new WeakMap();
|
|
419
|
+
function initWeaverContext() {
|
|
420
|
+
return {
|
|
421
|
+
id: initWeaverContext.increasingID++,
|
|
422
|
+
loomObjectMap: /* @__PURE__ */ new Map(),
|
|
423
|
+
loomUnionMap: /* @__PURE__ */ new Map(),
|
|
424
|
+
inputMap: /* @__PURE__ */ new Map(),
|
|
425
|
+
interfaceMap: /* @__PURE__ */ new Map(),
|
|
426
|
+
configs: /* @__PURE__ */ new Map(),
|
|
427
|
+
getConfig(key) {
|
|
428
|
+
return this.configs.get(key);
|
|
429
|
+
},
|
|
430
|
+
setConfig(config) {
|
|
431
|
+
const key = config[WEAVER_CONFIG];
|
|
432
|
+
this.configs.set(key, config);
|
|
433
|
+
},
|
|
434
|
+
deleteConfig(key) {
|
|
435
|
+
this.configs.delete(key);
|
|
436
|
+
},
|
|
437
|
+
names,
|
|
438
|
+
namedTypes: /* @__PURE__ */ new Map(),
|
|
439
|
+
memoNamedType(gqlTypeValue) {
|
|
440
|
+
const gqlType = gqlTypeValue;
|
|
441
|
+
if ((0, import_graphql.isObjectType)(gqlType) || (0, import_graphql.isUnionType)(gqlType) || (0, import_graphql.isEnumType)(gqlType) || (0, import_graphql.isScalarType)(gqlType)) {
|
|
442
|
+
this.namedTypes.set(gqlType.name, gqlType);
|
|
443
|
+
}
|
|
444
|
+
return gqlTypeValue;
|
|
445
|
+
},
|
|
446
|
+
getNamedType(name) {
|
|
447
|
+
return this.namedTypes.get(name);
|
|
448
|
+
},
|
|
449
|
+
vendorWeavers: /* @__PURE__ */ new Map()
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
initWeaverContext.increasingID = 1;
|
|
453
|
+
var weaverContext = {
|
|
454
|
+
get id() {
|
|
455
|
+
return ref?.id;
|
|
456
|
+
},
|
|
457
|
+
get loomObjectMap() {
|
|
458
|
+
return ref?.loomObjectMap;
|
|
459
|
+
},
|
|
460
|
+
get loomUnionMap() {
|
|
461
|
+
return ref?.loomUnionMap;
|
|
462
|
+
},
|
|
463
|
+
get inputMap() {
|
|
464
|
+
return ref?.inputMap;
|
|
465
|
+
},
|
|
466
|
+
get interfaceMap() {
|
|
467
|
+
return ref?.interfaceMap;
|
|
468
|
+
},
|
|
469
|
+
get configs() {
|
|
470
|
+
return ref?.configs;
|
|
471
|
+
},
|
|
472
|
+
get vendorWeavers() {
|
|
473
|
+
return ref?.vendorWeavers;
|
|
474
|
+
},
|
|
475
|
+
getConfig(key) {
|
|
476
|
+
return ref?.getConfig(key);
|
|
477
|
+
},
|
|
478
|
+
setConfig(config) {
|
|
479
|
+
ref?.setConfig(config);
|
|
480
|
+
},
|
|
481
|
+
deleteConfig(key) {
|
|
482
|
+
ref?.deleteConfig(key);
|
|
483
|
+
},
|
|
484
|
+
get value() {
|
|
485
|
+
return ref;
|
|
486
|
+
},
|
|
487
|
+
useConfig(config, callback) {
|
|
488
|
+
const context = weaverContext.value ?? initWeaverContext();
|
|
489
|
+
context.setConfig(config);
|
|
490
|
+
const result = provideWeaverContext(callback, context);
|
|
491
|
+
context.deleteConfig(config[WEAVER_CONFIG]);
|
|
492
|
+
return result;
|
|
493
|
+
},
|
|
494
|
+
names,
|
|
495
|
+
getNamedType(name) {
|
|
496
|
+
return ref?.getNamedType(name);
|
|
497
|
+
},
|
|
498
|
+
memoNamedType(gqlType) {
|
|
499
|
+
return ref?.memoNamedType(gqlType) ?? gqlType;
|
|
500
|
+
},
|
|
501
|
+
GraphQLTypes: /* @__PURE__ */ new WeakMap(),
|
|
502
|
+
getGraphQLType(origin) {
|
|
503
|
+
return this.GraphQLTypes.get(origin);
|
|
504
|
+
},
|
|
505
|
+
memoGraphQLType(origin, gqlType) {
|
|
506
|
+
this.GraphQLTypes.set(origin, gqlType);
|
|
507
|
+
return gqlType;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
function provideWeaverContext(func, value) {
|
|
511
|
+
const lastRef = ref;
|
|
512
|
+
ref = value;
|
|
513
|
+
try {
|
|
514
|
+
return func();
|
|
515
|
+
} finally {
|
|
516
|
+
ref = lastRef;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
provideWeaverContext.inherit = (func) => {
|
|
520
|
+
const weaverContextRef = weaverContext.value;
|
|
521
|
+
return () => provideWeaverContext(func, weaverContextRef);
|
|
522
|
+
};
|
|
523
|
+
function collectNames(...namesList) {
|
|
524
|
+
const namesRecord = {};
|
|
525
|
+
for (const namesItem of namesList) {
|
|
526
|
+
for (const [name, schema] of Object.entries(namesItem)) {
|
|
527
|
+
names.set(schema, name);
|
|
528
|
+
namesRecord[name] = schema;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return namesRecord;
|
|
532
|
+
}
|
|
533
|
+
function collectName(name, schema) {
|
|
534
|
+
names.set(schema, name);
|
|
535
|
+
return schema;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/resolver/silk.ts
|
|
539
|
+
function silk(type, validate = (value) => ({
|
|
540
|
+
value: value ?? void 0
|
|
541
|
+
})) {
|
|
542
|
+
return {
|
|
543
|
+
[GET_GRAPHQL_TYPE]: typeof type === "function" ? type : () => type,
|
|
544
|
+
"~standard": {
|
|
545
|
+
version: 1,
|
|
546
|
+
vendor: "gqloom.silk",
|
|
547
|
+
validate
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
silk.parse = parseSilk;
|
|
552
|
+
silk.getType = getGraphQLType;
|
|
553
|
+
silk.nonNull = nonNullSilk;
|
|
554
|
+
silk.list = listSilk;
|
|
555
|
+
silk.nullable = nullableSilk;
|
|
556
|
+
function nonNullSilk(origin) {
|
|
557
|
+
return {
|
|
558
|
+
...origin,
|
|
559
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
560
|
+
const originType = getGraphQLType(origin);
|
|
561
|
+
if (originType instanceof import_graphql2.GraphQLNonNull) {
|
|
562
|
+
return originType;
|
|
563
|
+
} else {
|
|
564
|
+
return new import_graphql2.GraphQLNonNull(originType);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function listSilk(origin) {
|
|
570
|
+
return {
|
|
571
|
+
...origin,
|
|
572
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
573
|
+
let originType = getGraphQLType(origin);
|
|
574
|
+
if (originType instanceof import_graphql2.GraphQLNonNull && originType.ofType instanceof import_graphql2.GraphQLList) {
|
|
575
|
+
originType = originType.ofType.ofType;
|
|
576
|
+
}
|
|
577
|
+
if (originType instanceof import_graphql2.GraphQLList) {
|
|
578
|
+
originType = originType.ofType;
|
|
579
|
+
}
|
|
580
|
+
return new import_graphql2.GraphQLNonNull(new import_graphql2.GraphQLList(originType));
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function nullableSilk(origin) {
|
|
585
|
+
return {
|
|
586
|
+
...origin,
|
|
587
|
+
[GET_GRAPHQL_TYPE]: () => {
|
|
588
|
+
const originType = getGraphQLType(origin);
|
|
589
|
+
if (originType instanceof import_graphql2.GraphQLNonNull) {
|
|
590
|
+
return originType.ofType;
|
|
591
|
+
} else {
|
|
592
|
+
return originType;
|
|
502
593
|
}
|
|
503
594
|
}
|
|
504
|
-
}
|
|
505
|
-
return result;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// src/utils/string.ts
|
|
509
|
-
function pascalCase(str) {
|
|
510
|
-
return str.split(/[\s-_]+/).map(
|
|
511
|
-
(word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
|
|
512
|
-
).join("");
|
|
513
|
-
}
|
|
514
|
-
function capitalize(str) {
|
|
515
|
-
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
595
|
+
};
|
|
516
596
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
597
|
+
function getGraphQLType(silk2) {
|
|
598
|
+
if (GET_GRAPHQL_TYPE in silk2 && silk2[GET_GRAPHQL_TYPE] != null)
|
|
599
|
+
return silk2[GET_GRAPHQL_TYPE]();
|
|
600
|
+
const vendorWeavers = weaverContext.vendorWeavers;
|
|
601
|
+
if (vendorWeavers == null) throw new Error("Schema Weaver is not initialized");
|
|
602
|
+
const weaver = vendorWeavers.get(silk2["~standard"].vendor);
|
|
603
|
+
if (weaver == null)
|
|
604
|
+
throw new Error(
|
|
605
|
+
`Schema Weaver for ${silk2["~standard"].vendor} is not found`
|
|
606
|
+
);
|
|
607
|
+
return weaver.getGraphQLType(silk2);
|
|
524
608
|
}
|
|
525
|
-
function
|
|
526
|
-
|
|
527
|
-
return func();
|
|
528
|
-
} catch (error) {
|
|
529
|
-
throw markErrorLocation(error, ...locations);
|
|
530
|
-
}
|
|
609
|
+
function parseSilk(silk2, input) {
|
|
610
|
+
return silk2["~standard"].validate(input);
|
|
531
611
|
}
|
|
532
|
-
function
|
|
533
|
-
if (
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
const match = existingPrefixPattern.exec(message);
|
|
539
|
-
if (match) return [match[1], message.slice(match[0].length).trim()];
|
|
540
|
-
return [void 0, message];
|
|
541
|
-
})();
|
|
542
|
-
const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
|
|
543
|
-
return `[${combinedLocation}] ${newMessage}`;
|
|
612
|
+
function isSilk(target) {
|
|
613
|
+
if (typeof target !== "object") return false;
|
|
614
|
+
if (target == null) return false;
|
|
615
|
+
if (GET_GRAPHQL_TYPE in target) return true;
|
|
616
|
+
if (!("~standard" in target)) return false;
|
|
617
|
+
return "vendor" in target["~standard"] && typeof target["~standard"].vendor === "string" && "version" in target["~standard"] && typeof target["~standard"].version === "number";
|
|
544
618
|
}
|
|
545
619
|
|
|
546
|
-
// src/utils/loader.ts
|
|
547
|
-
var EasyDataLoader = class _EasyDataLoader {
|
|
548
|
-
constructor(batchLoadFn) {
|
|
549
|
-
this.batchLoadFn = batchLoadFn;
|
|
550
|
-
this.queue = [];
|
|
551
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
552
|
-
this.resolvers = /* @__PURE__ */ new Map();
|
|
553
|
-
}
|
|
554
|
-
queue;
|
|
555
|
-
cache;
|
|
556
|
-
resolvers;
|
|
557
|
-
load(key) {
|
|
558
|
-
const existing = this.cache.get(key);
|
|
559
|
-
if (existing) return existing;
|
|
560
|
-
const promise = new Promise((resolve, reject) => {
|
|
561
|
-
this.queue.push(key);
|
|
562
|
-
this.resolvers.set(key, [resolve, reject]);
|
|
563
|
-
this.nextTickBatchLoad();
|
|
564
|
-
});
|
|
565
|
-
this.cache.set(key, promise);
|
|
566
|
-
return promise;
|
|
567
|
-
}
|
|
568
|
-
clear() {
|
|
569
|
-
this.queue = [];
|
|
570
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
571
|
-
this.resolvers = /* @__PURE__ */ new Map();
|
|
572
|
-
}
|
|
573
|
-
clearByKey(key) {
|
|
574
|
-
this.queue = this.queue.filter((k) => k !== key);
|
|
575
|
-
this.cache.delete(key);
|
|
576
|
-
this.resolvers.delete(key);
|
|
577
|
-
}
|
|
578
|
-
async executeBatchLoad() {
|
|
579
|
-
if (this.queue.length === 0) return;
|
|
580
|
-
const [keys, resolvers] = [this.queue, this.resolvers];
|
|
581
|
-
this.queue = [];
|
|
582
|
-
this.resolvers = /* @__PURE__ */ new Map();
|
|
583
|
-
try {
|
|
584
|
-
const list = await this.batchLoadFn(keys);
|
|
585
|
-
for (let i = 0; i < list.length; i++) {
|
|
586
|
-
const data = list[i];
|
|
587
|
-
const resolve = resolvers.get(keys[i])?.[0];
|
|
588
|
-
const reject = resolvers.get(keys[i])?.[1];
|
|
589
|
-
if (data instanceof Error) {
|
|
590
|
-
reject?.(data);
|
|
591
|
-
} else {
|
|
592
|
-
resolve?.(data);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
} catch (error) {
|
|
596
|
-
for (const key of keys) {
|
|
597
|
-
const reject = resolvers.get(key)?.[1];
|
|
598
|
-
reject?.(error);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
nextTickPromise;
|
|
603
|
-
nextTickBatchLoad() {
|
|
604
|
-
this.nextTickPromise ??= _EasyDataLoader.nextTick().then(() => this.executeBatchLoad()).finally(() => this.nextTickPromise = void 0);
|
|
605
|
-
return this.nextTickPromise;
|
|
606
|
-
}
|
|
607
|
-
static nextTick() {
|
|
608
|
-
return new Promise((resolve) => setTimeout(resolve));
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
|
|
612
620
|
// src/resolver/input.ts
|
|
613
621
|
var import_graphql3 = require("graphql");
|
|
614
622
|
function createInputParser(schema, value) {
|
|
@@ -623,6 +631,9 @@ function createInputParser(schema, value) {
|
|
|
623
631
|
get: () => result,
|
|
624
632
|
set: (value2) => result = value2
|
|
625
633
|
});
|
|
634
|
+
Object.defineProperty(parse, "getResult", {
|
|
635
|
+
value: async () => getStandardValue(await parse())
|
|
636
|
+
});
|
|
626
637
|
return parse;
|
|
627
638
|
}
|
|
628
639
|
function parseInputValue(inputSchema, input) {
|
|
@@ -702,9 +713,6 @@ var FieldChainFactory = class _FieldChainFactory extends BaseChainFactory {
|
|
|
702
713
|
clone(options) {
|
|
703
714
|
return new _FieldChainFactory({ ...this.options, ...options });
|
|
704
715
|
}
|
|
705
|
-
use(...middlewares) {
|
|
706
|
-
return super.use(...middlewares);
|
|
707
|
-
}
|
|
708
716
|
output(output) {
|
|
709
717
|
return new _FieldChainFactory({ ...this.options, output });
|
|
710
718
|
}
|
|
@@ -712,11 +720,44 @@ var FieldChainFactory = class _FieldChainFactory extends BaseChainFactory {
|
|
|
712
720
|
return new _FieldChainFactory({ ...this.options, input });
|
|
713
721
|
}
|
|
714
722
|
resolve(resolve) {
|
|
715
|
-
|
|
723
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
724
|
+
return createField(this.options.output, {
|
|
716
725
|
...this.options,
|
|
717
726
|
resolve
|
|
718
727
|
});
|
|
719
728
|
}
|
|
729
|
+
load(resolve) {
|
|
730
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
731
|
+
const useUnifiedParseInput = createMemoization(() => ({ current: void 0 }));
|
|
732
|
+
const useUserLoader = createMemoization(
|
|
733
|
+
() => new EasyDataLoader(
|
|
734
|
+
async (parents) => resolve(
|
|
735
|
+
parents,
|
|
736
|
+
await useUnifiedParseInput().current?.getResult()
|
|
737
|
+
)
|
|
738
|
+
)
|
|
739
|
+
);
|
|
740
|
+
const operation = "field";
|
|
741
|
+
return meta({
|
|
742
|
+
...getFieldOptions(this.options),
|
|
743
|
+
operation,
|
|
744
|
+
input: this.options.input,
|
|
745
|
+
output: this.options.output,
|
|
746
|
+
resolve: async (parent, inputValue, extraOptions) => {
|
|
747
|
+
const unifiedParseInput = useUnifiedParseInput();
|
|
748
|
+
unifiedParseInput.current ??= createInputParser(
|
|
749
|
+
this.options?.input,
|
|
750
|
+
inputValue
|
|
751
|
+
);
|
|
752
|
+
const parseInput = unifiedParseInput.current;
|
|
753
|
+
return applyMiddlewares(
|
|
754
|
+
compose(extraOptions?.middlewares, this.options?.middlewares),
|
|
755
|
+
async () => useUserLoader().load(parent),
|
|
756
|
+
{ parseInput, parent, outputSilk: this.output, operation }
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
}
|
|
720
761
|
};
|
|
721
762
|
var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
|
|
722
763
|
static methods() {
|
|
@@ -731,9 +772,6 @@ var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
|
|
|
731
772
|
clone(options) {
|
|
732
773
|
return new _QueryChainFactory({ ...this.options, ...options });
|
|
733
774
|
}
|
|
734
|
-
use(...middlewares) {
|
|
735
|
-
return super.use(...middlewares);
|
|
736
|
-
}
|
|
737
775
|
output(output) {
|
|
738
776
|
return new _QueryChainFactory({ ...this.options, output });
|
|
739
777
|
}
|
|
@@ -741,7 +779,8 @@ var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
|
|
|
741
779
|
return new _QueryChainFactory({ ...this.options, input });
|
|
742
780
|
}
|
|
743
781
|
resolve(resolve) {
|
|
744
|
-
|
|
782
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
783
|
+
return createQuery(this.options.output, {
|
|
745
784
|
...this.options,
|
|
746
785
|
resolve
|
|
747
786
|
});
|
|
@@ -760,9 +799,6 @@ var MutationChainFactory = class _MutationChainFactory extends BaseChainFactory
|
|
|
760
799
|
clone(options) {
|
|
761
800
|
return new _MutationChainFactory({ ...this.options, ...options });
|
|
762
801
|
}
|
|
763
|
-
use(...middlewares) {
|
|
764
|
-
return super.use(...middlewares);
|
|
765
|
-
}
|
|
766
802
|
output(output) {
|
|
767
803
|
return new _MutationChainFactory({ ...this.options, output });
|
|
768
804
|
}
|
|
@@ -770,7 +806,8 @@ var MutationChainFactory = class _MutationChainFactory extends BaseChainFactory
|
|
|
770
806
|
return new _MutationChainFactory({ ...this.options, input });
|
|
771
807
|
}
|
|
772
808
|
resolve(resolve) {
|
|
773
|
-
|
|
809
|
+
if (!this.options?.output) throw new Error("Output is required");
|
|
810
|
+
return createMutation(this.options.output, {
|
|
774
811
|
...this.options,
|
|
775
812
|
resolve
|
|
776
813
|
});
|
|
@@ -789,9 +826,6 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
|
|
|
789
826
|
clone(options) {
|
|
790
827
|
return new _SubscriptionChainFactory({ ...this.options, ...options });
|
|
791
828
|
}
|
|
792
|
-
use(...middlewares) {
|
|
793
|
-
return super.use(...middlewares);
|
|
794
|
-
}
|
|
795
829
|
output(output) {
|
|
796
830
|
return new _SubscriptionChainFactory({ ...this.options, output });
|
|
797
831
|
}
|
|
@@ -800,14 +834,16 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
|
|
|
800
834
|
}
|
|
801
835
|
subscribe(subscribe) {
|
|
802
836
|
const options = this.options;
|
|
803
|
-
const
|
|
837
|
+
const output = this.options?.output;
|
|
838
|
+
if (!output) throw new Error("Output is required");
|
|
839
|
+
const subscription2 = createSubscription(output, {
|
|
804
840
|
...options,
|
|
805
841
|
subscribe
|
|
806
842
|
});
|
|
807
|
-
const subscriptionResolve = subscription2.resolve;
|
|
843
|
+
const subscriptionResolve = subscription2["~meta"].resolve;
|
|
808
844
|
const resolve = (...args) => {
|
|
809
845
|
if (args.length === 1 && typeof args[0] === "function") {
|
|
810
|
-
return createSubscription(
|
|
846
|
+
return createSubscription(output, {
|
|
811
847
|
...options,
|
|
812
848
|
resolve: args[0],
|
|
813
849
|
subscribe
|
|
@@ -818,6 +854,66 @@ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChain
|
|
|
818
854
|
return Object.assign(subscription2, { resolve });
|
|
819
855
|
}
|
|
820
856
|
};
|
|
857
|
+
var QueryFactoryWithResolve = class _QueryFactoryWithResolve extends BaseChainFactory {
|
|
858
|
+
constructor(output, options) {
|
|
859
|
+
super(options);
|
|
860
|
+
this.output = output;
|
|
861
|
+
this.options = options;
|
|
862
|
+
}
|
|
863
|
+
get "~meta"() {
|
|
864
|
+
return loom.query(this.output, this.options)["~meta"];
|
|
865
|
+
}
|
|
866
|
+
clone(options) {
|
|
867
|
+
return new _QueryFactoryWithResolve(this.output, {
|
|
868
|
+
...this.options,
|
|
869
|
+
...options
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
input(input) {
|
|
873
|
+
return new _QueryFactoryWithResolve(this.output, {
|
|
874
|
+
...this.options,
|
|
875
|
+
input
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
var MutationFactoryWithResolve = class _MutationFactoryWithResolve extends BaseChainFactory {
|
|
880
|
+
constructor(output, options) {
|
|
881
|
+
super(options);
|
|
882
|
+
this.output = output;
|
|
883
|
+
this.options = options;
|
|
884
|
+
}
|
|
885
|
+
get "~meta"() {
|
|
886
|
+
return loom.mutation(this.output, this.options)["~meta"];
|
|
887
|
+
}
|
|
888
|
+
clone(options) {
|
|
889
|
+
return new _MutationFactoryWithResolve(this.output, {
|
|
890
|
+
...this.options,
|
|
891
|
+
...options
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
input(input) {
|
|
895
|
+
return new _MutationFactoryWithResolve(this.output, {
|
|
896
|
+
...this.options,
|
|
897
|
+
input
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
var FieldFactoryWithResolve = class _FieldFactoryWithResolve extends BaseChainFactory {
|
|
902
|
+
constructor(output, options) {
|
|
903
|
+
super(options);
|
|
904
|
+
this.output = output;
|
|
905
|
+
this.options = options;
|
|
906
|
+
}
|
|
907
|
+
get "~meta"() {
|
|
908
|
+
return loom.field(this.output, this.options)["~meta"];
|
|
909
|
+
}
|
|
910
|
+
clone(options) {
|
|
911
|
+
return new _FieldFactoryWithResolve(this.output, {
|
|
912
|
+
...this.options,
|
|
913
|
+
...options
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
};
|
|
821
917
|
|
|
822
918
|
// src/resolver/resolver.ts
|
|
823
919
|
var createQuery = (output, resolveOrOptions) => {
|
|
@@ -825,8 +921,8 @@ var createQuery = (output, resolveOrOptions) => {
|
|
|
825
921
|
return new QueryChainFactory({ output });
|
|
826
922
|
}
|
|
827
923
|
const options = getOperationOptions(resolveOrOptions);
|
|
828
|
-
const
|
|
829
|
-
return {
|
|
924
|
+
const operation = "query";
|
|
925
|
+
return meta({
|
|
830
926
|
...getFieldOptions(options),
|
|
831
927
|
input: options.input,
|
|
832
928
|
output,
|
|
@@ -835,11 +931,11 @@ var createQuery = (output, resolveOrOptions) => {
|
|
|
835
931
|
return applyMiddlewares(
|
|
836
932
|
compose(extraOptions?.middlewares, options.middlewares),
|
|
837
933
|
async () => options.resolve(getStandardValue(await parseInput())),
|
|
838
|
-
{ parseInput, parent: void 0, outputSilk: output,
|
|
934
|
+
{ parseInput, parent: void 0, outputSilk: output, operation }
|
|
839
935
|
);
|
|
840
936
|
},
|
|
841
|
-
|
|
842
|
-
};
|
|
937
|
+
operation
|
|
938
|
+
});
|
|
843
939
|
};
|
|
844
940
|
var query = Object.assign(
|
|
845
941
|
createQuery,
|
|
@@ -850,8 +946,8 @@ var createMutation = (output, resolveOrOptions) => {
|
|
|
850
946
|
return new MutationChainFactory({ output });
|
|
851
947
|
}
|
|
852
948
|
const options = getOperationOptions(resolveOrOptions);
|
|
853
|
-
const
|
|
854
|
-
return {
|
|
949
|
+
const operation = "mutation";
|
|
950
|
+
return meta({
|
|
855
951
|
...getFieldOptions(options),
|
|
856
952
|
input: options.input,
|
|
857
953
|
output,
|
|
@@ -860,11 +956,11 @@ var createMutation = (output, resolveOrOptions) => {
|
|
|
860
956
|
return applyMiddlewares(
|
|
861
957
|
compose(extraOptions?.middlewares, options.middlewares),
|
|
862
958
|
async () => options.resolve(getStandardValue(await parseInput())),
|
|
863
|
-
{ parseInput, parent: void 0, outputSilk: output,
|
|
959
|
+
{ parseInput, parent: void 0, outputSilk: output, operation }
|
|
864
960
|
);
|
|
865
961
|
},
|
|
866
|
-
|
|
867
|
-
};
|
|
962
|
+
operation
|
|
963
|
+
});
|
|
868
964
|
};
|
|
869
965
|
var mutation = Object.assign(
|
|
870
966
|
createMutation,
|
|
@@ -875,8 +971,8 @@ var createField = (output, resolveOrOptions) => {
|
|
|
875
971
|
return new FieldChainFactory({ output });
|
|
876
972
|
}
|
|
877
973
|
const options = getOperationOptions(resolveOrOptions);
|
|
878
|
-
const
|
|
879
|
-
return {
|
|
974
|
+
const operation = "field";
|
|
975
|
+
return meta({
|
|
880
976
|
...getFieldOptions(options),
|
|
881
977
|
input: options.input,
|
|
882
978
|
output,
|
|
@@ -885,11 +981,11 @@ var createField = (output, resolveOrOptions) => {
|
|
|
885
981
|
return applyMiddlewares(
|
|
886
982
|
compose(extraOptions?.middlewares, options.middlewares),
|
|
887
983
|
async () => options.resolve(parent, getStandardValue(await parseInput())),
|
|
888
|
-
{ parseInput, parent, outputSilk: output,
|
|
984
|
+
{ parseInput, parent, outputSilk: output, operation }
|
|
889
985
|
);
|
|
890
986
|
},
|
|
891
|
-
|
|
892
|
-
};
|
|
987
|
+
operation
|
|
988
|
+
});
|
|
893
989
|
};
|
|
894
990
|
var field = Object.assign(
|
|
895
991
|
createField,
|
|
@@ -897,13 +993,13 @@ var field = Object.assign(
|
|
|
897
993
|
FieldChainFactory.methods()
|
|
898
994
|
);
|
|
899
995
|
var defaultSubscriptionResolve = (source) => source;
|
|
900
|
-
|
|
996
|
+
function createSubscription(output, subscribeOrOptions) {
|
|
901
997
|
if (subscribeOrOptions == null) {
|
|
902
998
|
return new SubscriptionChainFactory({ output });
|
|
903
999
|
}
|
|
904
1000
|
const options = getSubscriptionOptions(subscribeOrOptions);
|
|
905
|
-
const
|
|
906
|
-
return {
|
|
1001
|
+
const operation = "subscription";
|
|
1002
|
+
return meta({
|
|
907
1003
|
...getFieldOptions(options),
|
|
908
1004
|
input: options.input,
|
|
909
1005
|
output,
|
|
@@ -915,62 +1011,66 @@ var createSubscription = (output, subscribeOrOptions) => {
|
|
|
915
1011
|
options.middlewares
|
|
916
1012
|
),
|
|
917
1013
|
async () => options.subscribe(getStandardValue(await parseInput())),
|
|
918
|
-
{ parseInput, parent: void 0, outputSilk: output,
|
|
1014
|
+
{ parseInput, parent: void 0, outputSilk: output, operation }
|
|
919
1015
|
);
|
|
920
1016
|
},
|
|
921
1017
|
resolve: options.resolve ?? defaultSubscriptionResolve,
|
|
922
|
-
|
|
923
|
-
};
|
|
924
|
-
}
|
|
1018
|
+
operation
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
925
1021
|
var subscription = Object.assign(
|
|
926
1022
|
createSubscription,
|
|
927
1023
|
SubscriptionChainFactory.methods()
|
|
928
1024
|
);
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const record = {};
|
|
932
|
-
Object.entries(operations).forEach(([name, operation]) => {
|
|
933
|
-
record[name] = extraOperationOptions(operation, options);
|
|
934
|
-
});
|
|
935
|
-
if (options) ResolverOptionsMap.set(record, options);
|
|
936
|
-
return record;
|
|
937
|
-
}
|
|
938
|
-
function extraOperationOptions(operation, options) {
|
|
1025
|
+
function extraOperationOptions(field2, options) {
|
|
1026
|
+
if (typeof field2 === "symbol") return field2;
|
|
939
1027
|
const composeMiddlewares = (extraOptions) => compose(extraOptions?.middlewares, options?.middlewares);
|
|
940
|
-
|
|
941
|
-
switch (operation.type) {
|
|
1028
|
+
switch (field2["~meta"].operation) {
|
|
942
1029
|
case "field":
|
|
943
1030
|
return {
|
|
944
|
-
...
|
|
945
|
-
|
|
946
|
-
...
|
|
947
|
-
|
|
948
|
-
|
|
1031
|
+
...field2,
|
|
1032
|
+
"~meta": {
|
|
1033
|
+
...field2["~meta"],
|
|
1034
|
+
resolve: (parent, input, extraOptions) => field2["~meta"].resolve(parent, input, {
|
|
1035
|
+
...extraOptions,
|
|
1036
|
+
middlewares: composeMiddlewares(extraOptions)
|
|
1037
|
+
})
|
|
1038
|
+
}
|
|
949
1039
|
};
|
|
950
1040
|
case "subscription":
|
|
951
1041
|
return {
|
|
952
|
-
...
|
|
953
|
-
|
|
954
|
-
...
|
|
955
|
-
|
|
956
|
-
|
|
1042
|
+
...field2,
|
|
1043
|
+
"~meta": {
|
|
1044
|
+
...field2["~meta"],
|
|
1045
|
+
subscribe: (input, extraOptions) => field2["~meta"].subscribe(
|
|
1046
|
+
input,
|
|
1047
|
+
{
|
|
1048
|
+
...extraOptions,
|
|
1049
|
+
middlewares: composeMiddlewares(extraOptions)
|
|
1050
|
+
}
|
|
1051
|
+
)
|
|
1052
|
+
}
|
|
957
1053
|
};
|
|
958
1054
|
default:
|
|
959
1055
|
return {
|
|
960
|
-
...
|
|
961
|
-
|
|
962
|
-
...
|
|
963
|
-
|
|
964
|
-
|
|
1056
|
+
...field2,
|
|
1057
|
+
"~meta": {
|
|
1058
|
+
...field2["~meta"],
|
|
1059
|
+
resolve: (input, extraOptions) => field2["~meta"].resolve(input, {
|
|
1060
|
+
...extraOptions,
|
|
1061
|
+
middlewares: composeMiddlewares(extraOptions)
|
|
1062
|
+
})
|
|
1063
|
+
}
|
|
965
1064
|
};
|
|
966
1065
|
}
|
|
967
1066
|
}
|
|
968
1067
|
var resolver = Object.assign(
|
|
969
|
-
|
|
1068
|
+
(operations, options) => new ChainResolver(operations, options),
|
|
970
1069
|
{
|
|
971
|
-
of: (parent, operations, options) =>
|
|
1070
|
+
of: (parent, operations, options) => new ObjectChainResolver(
|
|
1071
|
+
parent,
|
|
972
1072
|
operations,
|
|
973
|
-
|
|
1073
|
+
options
|
|
974
1074
|
)
|
|
975
1075
|
}
|
|
976
1076
|
);
|
|
@@ -981,93 +1081,69 @@ var loom = {
|
|
|
981
1081
|
subscription,
|
|
982
1082
|
mutation
|
|
983
1083
|
};
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1084
|
+
var ChainResolver = class {
|
|
1085
|
+
meta;
|
|
1086
|
+
constructor(fields, options) {
|
|
1087
|
+
this.meta = {
|
|
1088
|
+
[IS_RESOLVER]: true,
|
|
1089
|
+
fields,
|
|
1090
|
+
options
|
|
1091
|
+
};
|
|
989
1092
|
}
|
|
990
|
-
|
|
991
|
-
|
|
1093
|
+
get "~meta"() {
|
|
1094
|
+
const fields = {};
|
|
1095
|
+
Object.entries(this.meta.fields).forEach(([name, field2]) => {
|
|
1096
|
+
if (field2 === FIELD_HIDDEN) {
|
|
1097
|
+
fields[name] = field2;
|
|
1098
|
+
} else {
|
|
1099
|
+
fields[name] = extraOperationOptions(field2, this.meta.options);
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
return {
|
|
1103
|
+
...this.meta,
|
|
1104
|
+
fields
|
|
1105
|
+
};
|
|
992
1106
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1107
|
+
use(...middlewares) {
|
|
1108
|
+
this.meta.options ??= {};
|
|
1109
|
+
this.meta.options.middlewares ??= [];
|
|
1110
|
+
this.meta.options.middlewares.push(...middlewares);
|
|
1111
|
+
return this;
|
|
996
1112
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
{ ...options, parent: toSilk(parent) }
|
|
1004
|
-
)
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
function createFieldFactory(toSilk, isSchema) {
|
|
1008
|
-
const baseFieldFunc = (output, resolveOrOptions) => {
|
|
1009
|
-
if (resolveOrOptions == null) {
|
|
1010
|
-
return new FieldChainFactory({ output: toSilk(output) });
|
|
1011
|
-
}
|
|
1012
|
-
const options = getOperationOptions(
|
|
1013
|
-
resolveOrOptions
|
|
1014
|
-
);
|
|
1015
|
-
return field(toSilk(output), {
|
|
1016
|
-
...options,
|
|
1017
|
-
input: toSilkInput(options.input, toSilk, isSchema)
|
|
1018
|
-
});
|
|
1019
|
-
};
|
|
1020
|
-
return Object.assign(
|
|
1021
|
-
baseFieldFunc,
|
|
1022
|
-
{ hidden: FIELD_HIDDEN },
|
|
1023
|
-
FieldChainFactory.methods()
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
function createQueryFactory(toSilk, isSchema) {
|
|
1027
|
-
return (output, resolveOrOptions) => {
|
|
1028
|
-
if (resolveOrOptions == null) {
|
|
1029
|
-
return new QueryChainFactory({ output: toSilk(output) });
|
|
1030
|
-
}
|
|
1031
|
-
const options = getOperationOptions(resolveOrOptions);
|
|
1032
|
-
return query(toSilk(output), {
|
|
1033
|
-
...options,
|
|
1034
|
-
input: toSilkInput(options.input, toSilk, isSchema)
|
|
1035
|
-
});
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
function createMutationFactory(toSilk, isSchema) {
|
|
1039
|
-
return (output, resolveOrOptions) => {
|
|
1040
|
-
if (resolveOrOptions == null) {
|
|
1041
|
-
return new MutationChainFactory({ output: toSilk(output) });
|
|
1042
|
-
}
|
|
1043
|
-
const options = getOperationOptions(resolveOrOptions);
|
|
1044
|
-
return mutation(toSilk(output), {
|
|
1045
|
-
...options,
|
|
1046
|
-
input: toSilkInput(options.input, toSilk, isSchema)
|
|
1047
|
-
});
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
function createSubscriptionFactory(toSilk, isSchema) {
|
|
1051
|
-
return (output, resolveOrOptions) => {
|
|
1052
|
-
if (resolveOrOptions == null) {
|
|
1053
|
-
return new SubscriptionChainFactory({ output: toSilk(output) });
|
|
1054
|
-
}
|
|
1055
|
-
const options = getSubscriptionOptions(resolveOrOptions);
|
|
1056
|
-
return subscription(toSilk(output), {
|
|
1057
|
-
...options,
|
|
1058
|
-
input: toSilkInput(options.input, toSilk, isSchema)
|
|
1113
|
+
toExecutor() {
|
|
1114
|
+
const fields = this["~meta"].fields;
|
|
1115
|
+
const executor = {};
|
|
1116
|
+
Object.entries(fields).forEach(([name, field2]) => {
|
|
1117
|
+
if (field2 === FIELD_HIDDEN) return;
|
|
1118
|
+
executor[name] = field2["~meta"].resolve;
|
|
1059
1119
|
});
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1120
|
+
return executor;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
var ObjectChainResolver = class extends ChainResolver {
|
|
1124
|
+
meta;
|
|
1125
|
+
constructor(parent, fields, options) {
|
|
1126
|
+
super(fields, options);
|
|
1127
|
+
this.meta = {
|
|
1128
|
+
[IS_RESOLVER]: true,
|
|
1129
|
+
fields,
|
|
1130
|
+
parent,
|
|
1131
|
+
options
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
get "~meta"() {
|
|
1135
|
+
return super["~meta"];
|
|
1136
|
+
}
|
|
1137
|
+
extensions(extensions) {
|
|
1138
|
+
this.meta.options ??= {};
|
|
1139
|
+
this.meta.options.extensions ??= {};
|
|
1140
|
+
this.meta.options.extensions = {
|
|
1141
|
+
...this.meta.options.extensions,
|
|
1142
|
+
...extensions
|
|
1143
|
+
};
|
|
1144
|
+
return this;
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1071
1147
|
|
|
1072
1148
|
// src/schema/object.ts
|
|
1073
1149
|
var import_graphql5 = require("graphql");
|
|
@@ -1249,13 +1325,13 @@ var LoomObjectType = class _LoomObjectType extends import_graphql5.GraphQLObject
|
|
|
1249
1325
|
toFieldConfig(field2, fieldName) {
|
|
1250
1326
|
try {
|
|
1251
1327
|
const outputType = this.getCacheType(
|
|
1252
|
-
getGraphQLType(field2.output),
|
|
1328
|
+
getGraphQLType(field2["~meta"].output),
|
|
1253
1329
|
fieldName
|
|
1254
1330
|
);
|
|
1255
1331
|
return {
|
|
1256
1332
|
...extract(field2),
|
|
1257
1333
|
type: outputType,
|
|
1258
|
-
args: inputToArgs(field2.input, {
|
|
1334
|
+
args: inputToArgs(field2["~meta"].input, {
|
|
1259
1335
|
fieldName: fieldName ? parentName(this.name) + fieldName : void 0
|
|
1260
1336
|
}),
|
|
1261
1337
|
...this.provideForResolve(field2),
|
|
@@ -1266,27 +1342,31 @@ var LoomObjectType = class _LoomObjectType extends import_graphql5.GraphQLObject
|
|
|
1266
1342
|
}
|
|
1267
1343
|
}
|
|
1268
1344
|
provideForResolve(field2) {
|
|
1269
|
-
if (field2?.resolve == null) return;
|
|
1270
|
-
if (field2.resolve === defaultSubscriptionResolve)
|
|
1345
|
+
if (field2?.["~meta"]?.resolve == null) return;
|
|
1346
|
+
if (field2["~meta"].resolve === defaultSubscriptionResolve)
|
|
1271
1347
|
return { resolve: defaultSubscriptionResolve };
|
|
1272
|
-
const resolve = field2.
|
|
1348
|
+
const resolve = field2["~meta"].operation === "field" ? (root, args, context, info) => resolverPayloadStorage.run(
|
|
1273
1349
|
{ root, args, context, info, field: field2 },
|
|
1274
|
-
() => field2.resolve(root, args, this.resolverOptions)
|
|
1275
|
-
) : field2.
|
|
1350
|
+
() => field2["~meta"].resolve(root, args, this.resolverOptions)
|
|
1351
|
+
) : field2["~meta"].operation === "subscription" ? (root, args, context, info) => resolverPayloadStorage.run(
|
|
1276
1352
|
{ root, args, context, info, field: field2 },
|
|
1277
|
-
() => field2.resolve(root, args)
|
|
1353
|
+
() => field2["~meta"].resolve(root, args)
|
|
1278
1354
|
) : (root, args, context, info) => resolverPayloadStorage.run(
|
|
1279
1355
|
{ root, args, context, info, field: field2 },
|
|
1280
|
-
() => field2.resolve(args, this.resolverOptions)
|
|
1356
|
+
() => field2["~meta"].resolve(args, this.resolverOptions)
|
|
1281
1357
|
);
|
|
1282
1358
|
return { resolve };
|
|
1283
1359
|
}
|
|
1284
1360
|
provideForSubscribe(field2) {
|
|
1285
|
-
if (field2?.subscribe == null)
|
|
1361
|
+
if (field2?.["~meta"]?.subscribe == null)
|
|
1362
|
+
return;
|
|
1286
1363
|
return {
|
|
1287
1364
|
subscribe: (root, args, context, info) => resolverPayloadStorage.run(
|
|
1288
1365
|
{ root, args, context, info, field: field2 },
|
|
1289
|
-
() => field2.subscribe?.(
|
|
1366
|
+
() => field2["~meta"].subscribe?.(
|
|
1367
|
+
args,
|
|
1368
|
+
this.resolverOptions
|
|
1369
|
+
)
|
|
1290
1370
|
)
|
|
1291
1371
|
};
|
|
1292
1372
|
}
|
|
@@ -1298,11 +1378,8 @@ var LoomObjectType = class _LoomObjectType extends import_graphql5.GraphQLObject
|
|
|
1298
1378
|
return { resolverOptions, weaverContext: weaverContext2 };
|
|
1299
1379
|
}
|
|
1300
1380
|
};
|
|
1301
|
-
function extract({
|
|
1302
|
-
deprecationReason,
|
|
1303
|
-
description,
|
|
1304
|
-
extensions
|
|
1305
|
-
}) {
|
|
1381
|
+
function extract(field2) {
|
|
1382
|
+
const { deprecationReason, description, extensions } = field2["~meta"];
|
|
1306
1383
|
return {
|
|
1307
1384
|
description,
|
|
1308
1385
|
deprecationReason,
|
|
@@ -1382,6 +1459,7 @@ function parentName(name) {
|
|
|
1382
1459
|
|
|
1383
1460
|
// src/schema/schema-weaver.ts
|
|
1384
1461
|
function isSchemaVendorWeaver(some) {
|
|
1462
|
+
if (some == null) return false;
|
|
1385
1463
|
if (typeof some !== "object" && typeof some !== "function") return false;
|
|
1386
1464
|
if (!("getGraphQLType" in some) || typeof some.getGraphQLType !== "function")
|
|
1387
1465
|
return false;
|
|
@@ -1467,8 +1545,8 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1467
1545
|
return schema;
|
|
1468
1546
|
}
|
|
1469
1547
|
addResolver(resolver2) {
|
|
1470
|
-
const resolverOptions =
|
|
1471
|
-
const parent =
|
|
1548
|
+
const resolverOptions = resolver2["~meta"].options;
|
|
1549
|
+
const parent = resolver2["~meta"].parent;
|
|
1472
1550
|
const parentObject = (() => {
|
|
1473
1551
|
if (parent == null) return void 0;
|
|
1474
1552
|
let gqlType = getGraphQLType(parent);
|
|
@@ -1487,16 +1565,18 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1487
1565
|
})();
|
|
1488
1566
|
if (resolverOptions?.extensions && parentObject)
|
|
1489
1567
|
parentObject.mergeExtensions(resolverOptions.extensions);
|
|
1490
|
-
Object.entries(resolver2).forEach(([name,
|
|
1491
|
-
if (
|
|
1568
|
+
Object.entries(resolver2["~meta"].fields).forEach(([name, field2]) => {
|
|
1569
|
+
if (field2 === FIELD_HIDDEN) {
|
|
1492
1570
|
if (parentObject == null) return;
|
|
1493
1571
|
parentObject.hideField(name);
|
|
1494
|
-
} else if (operation
|
|
1572
|
+
} else if (field2["~meta"].operation === "field") {
|
|
1495
1573
|
if (parentObject == null) return;
|
|
1496
|
-
parentObject.addField(name,
|
|
1574
|
+
parentObject.addField(name, field2);
|
|
1497
1575
|
} else {
|
|
1498
|
-
const operationObject = this.getOperationObject(
|
|
1499
|
-
|
|
1576
|
+
const operationObject = this.getOperationObject(
|
|
1577
|
+
field2["~meta"].operation
|
|
1578
|
+
);
|
|
1579
|
+
operationObject.addField(name, field2);
|
|
1500
1580
|
}
|
|
1501
1581
|
});
|
|
1502
1582
|
return this;
|
|
@@ -1550,7 +1630,7 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1550
1630
|
}
|
|
1551
1631
|
} else if (isSilk(item)) {
|
|
1552
1632
|
silks.add(item);
|
|
1553
|
-
} else {
|
|
1633
|
+
} else if (item["~meta"][IS_RESOLVER]) {
|
|
1554
1634
|
resolvers.add(item);
|
|
1555
1635
|
}
|
|
1556
1636
|
}
|
|
@@ -1601,31 +1681,33 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1601
1681
|
}
|
|
1602
1682
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1603
1683
|
0 && (module.exports = {
|
|
1684
|
+
BaseChainFactory,
|
|
1685
|
+
ChainResolver,
|
|
1604
1686
|
ContextMemoization,
|
|
1605
1687
|
EasyDataLoader,
|
|
1688
|
+
FieldChainFactory,
|
|
1689
|
+
FieldFactoryWithResolve,
|
|
1606
1690
|
GraphQLSchemaLoom,
|
|
1607
1691
|
LoomObjectType,
|
|
1692
|
+
MutationChainFactory,
|
|
1693
|
+
MutationFactoryWithResolve,
|
|
1608
1694
|
OPERATION_OBJECT_NAMES,
|
|
1609
|
-
|
|
1695
|
+
ObjectChainResolver,
|
|
1696
|
+
QueryChainFactory,
|
|
1697
|
+
QueryFactoryWithResolve,
|
|
1610
1698
|
SYMBOLS,
|
|
1699
|
+
SubscriptionChainFactory,
|
|
1611
1700
|
applyMiddlewares,
|
|
1612
|
-
baseResolver,
|
|
1613
1701
|
capitalize,
|
|
1614
1702
|
collectName,
|
|
1615
1703
|
collectNames,
|
|
1616
1704
|
compose,
|
|
1617
1705
|
createField,
|
|
1618
|
-
createFieldFactory,
|
|
1619
1706
|
createInputParser,
|
|
1620
|
-
createLoom,
|
|
1621
1707
|
createMemoization,
|
|
1622
1708
|
createMutation,
|
|
1623
|
-
createMutationFactory,
|
|
1624
1709
|
createQuery,
|
|
1625
|
-
createQueryFactory,
|
|
1626
|
-
createResolverFactory,
|
|
1627
1710
|
createSubscription,
|
|
1628
|
-
createSubscriptionFactory,
|
|
1629
1711
|
deepMerge,
|
|
1630
1712
|
defaultSubscriptionResolve,
|
|
1631
1713
|
ensureInputObjectType,
|
|
@@ -1648,6 +1730,7 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1648
1730
|
mapValue,
|
|
1649
1731
|
markErrorLocation,
|
|
1650
1732
|
markLocation,
|
|
1733
|
+
meta,
|
|
1651
1734
|
mutation,
|
|
1652
1735
|
nonNullSilk,
|
|
1653
1736
|
notNullish,
|