@gqloom/core 0.11.0 → 0.12.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/{chunk-Cl8Af3a2.js → chunk-CTAAG5j7.js} +3 -1
- package/dist/{context-CpbCknos.js → context-BxqO4Eg9.js} +7 -10
- package/dist/{context-3UlS1xGQ.cjs → context-DshDoxiE.cjs} +14 -9
- package/dist/context.cjs +1 -1
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -1
- package/dist/{index-DUqXX1Tm.d.cts → index-B1bRSxSg.d.cts} +14 -15
- package/dist/{index-GSWAHvDy.d.ts → index-_VhWbhmU.d.ts} +14 -15
- package/dist/index.cjs +54 -46
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +53 -47
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
//#region rolldown:runtime
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __export = (
|
|
3
|
+
var __export = (all) => {
|
|
4
|
+
let target = {};
|
|
4
5
|
for (var name in all) __defProp(target, name, {
|
|
5
6
|
get: all[name],
|
|
6
7
|
enumerable: true
|
|
7
8
|
});
|
|
9
|
+
return target;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
//#endregion
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { __export } from "./chunk-
|
|
1
|
+
import { __export } from "./chunk-CTAAG5j7.js";
|
|
2
2
|
import { Kind, isInterfaceType, isListType, isNonNullType, isObjectType } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/constants.ts
|
|
5
5
|
const DERIVED_DEPENDENCIES = "loom.derived-from-dependencies";
|
|
6
|
+
const AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
6
7
|
|
|
7
8
|
//#endregion
|
|
8
9
|
//#region src/utils/type.ts
|
|
@@ -182,8 +183,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
182
183
|
case Kind.FIELD: {
|
|
183
184
|
const fieldName = selection.name.value;
|
|
184
185
|
currentFields.add(fieldName);
|
|
185
|
-
|
|
186
|
-
if (hasSelectionSet) {
|
|
186
|
+
if (selection.selectionSet != null) {
|
|
187
187
|
const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
188
188
|
this.collectFields(selection.selectionSet, fieldPath, currentDepth + 1);
|
|
189
189
|
}
|
|
@@ -217,8 +217,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
217
217
|
if (value.kind === Kind.BOOLEAN) return value.value;
|
|
218
218
|
if (value.kind === Kind.VARIABLE) {
|
|
219
219
|
const variableName = value.name.value;
|
|
220
|
-
|
|
221
|
-
return variableValue === true;
|
|
220
|
+
return this.info.variableValues?.[variableName] === true;
|
|
222
221
|
}
|
|
223
222
|
return true;
|
|
224
223
|
}
|
|
@@ -232,8 +231,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
232
231
|
shouldIncludeNode(node) {
|
|
233
232
|
if (!node.directives?.length) return true;
|
|
234
233
|
return node.directives.every((directive) => {
|
|
235
|
-
|
|
236
|
-
if (isIncludeDirective) return this.getDirectiveValue(directive);
|
|
234
|
+
if (directive.name.value === "include") return this.getDirectiveValue(directive);
|
|
237
235
|
if (directive.name.value === "skip") return !this.getDirectiveValue(directive);
|
|
238
236
|
return true;
|
|
239
237
|
});
|
|
@@ -242,8 +240,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
242
240
|
|
|
243
241
|
//#endregion
|
|
244
242
|
//#region src/utils/symbols.ts
|
|
245
|
-
var symbols_exports = {
|
|
246
|
-
__export(symbols_exports, {
|
|
243
|
+
var symbols_exports = /* @__PURE__ */ __export({
|
|
247
244
|
CONTEXT_MAP_KEY: () => CONTEXT_MAP_KEY,
|
|
248
245
|
FIELD_HIDDEN: () => FIELD_HIDDEN,
|
|
249
246
|
GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
|
|
@@ -302,4 +299,4 @@ function assignContextMap(target) {
|
|
|
302
299
|
}
|
|
303
300
|
|
|
304
301
|
//#endregion
|
|
305
|
-
export { DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports };
|
|
302
|
+
export { AUTO_ALIASING, DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports };
|
|
@@ -5,11 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (
|
|
8
|
+
var __export = (all) => {
|
|
9
|
+
let target = {};
|
|
9
10
|
for (var name in all) __defProp(target, name, {
|
|
10
11
|
get: all[name],
|
|
11
12
|
enumerable: true
|
|
12
13
|
});
|
|
14
|
+
return target;
|
|
13
15
|
};
|
|
14
16
|
var __copyProps = (to, from, except, desc) => {
|
|
15
17
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -32,6 +34,7 @@ graphql = __toESM(graphql);
|
|
|
32
34
|
|
|
33
35
|
//#region src/utils/constants.ts
|
|
34
36
|
const DERIVED_DEPENDENCIES = "loom.derived-from-dependencies";
|
|
37
|
+
const AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
35
38
|
|
|
36
39
|
//#endregion
|
|
37
40
|
//#region src/utils/type.ts
|
|
@@ -211,8 +214,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
211
214
|
case graphql.Kind.FIELD: {
|
|
212
215
|
const fieldName = selection.name.value;
|
|
213
216
|
currentFields.add(fieldName);
|
|
214
|
-
|
|
215
|
-
if (hasSelectionSet) {
|
|
217
|
+
if (selection.selectionSet != null) {
|
|
216
218
|
const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
|
|
217
219
|
this.collectFields(selection.selectionSet, fieldPath, currentDepth + 1);
|
|
218
220
|
}
|
|
@@ -246,8 +248,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
246
248
|
if (value.kind === graphql.Kind.BOOLEAN) return value.value;
|
|
247
249
|
if (value.kind === graphql.Kind.VARIABLE) {
|
|
248
250
|
const variableName = value.name.value;
|
|
249
|
-
|
|
250
|
-
return variableValue === true;
|
|
251
|
+
return this.info.variableValues?.[variableName] === true;
|
|
251
252
|
}
|
|
252
253
|
return true;
|
|
253
254
|
}
|
|
@@ -261,8 +262,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
261
262
|
shouldIncludeNode(node) {
|
|
262
263
|
if (!node.directives?.length) return true;
|
|
263
264
|
return node.directives.every((directive) => {
|
|
264
|
-
|
|
265
|
-
if (isIncludeDirective) return this.getDirectiveValue(directive);
|
|
265
|
+
if (directive.name.value === "include") return this.getDirectiveValue(directive);
|
|
266
266
|
if (directive.name.value === "skip") return !this.getDirectiveValue(directive);
|
|
267
267
|
return true;
|
|
268
268
|
});
|
|
@@ -271,8 +271,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
|
|
|
271
271
|
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/utils/symbols.ts
|
|
274
|
-
var symbols_exports = {
|
|
275
|
-
__export(symbols_exports, {
|
|
274
|
+
var symbols_exports = /* @__PURE__ */ __export({
|
|
276
275
|
CONTEXT_MAP_KEY: () => CONTEXT_MAP_KEY,
|
|
277
276
|
FIELD_HIDDEN: () => FIELD_HIDDEN,
|
|
278
277
|
GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
|
|
@@ -331,6 +330,12 @@ function assignContextMap(target) {
|
|
|
331
330
|
}
|
|
332
331
|
|
|
333
332
|
//#endregion
|
|
333
|
+
Object.defineProperty(exports, 'AUTO_ALIASING', {
|
|
334
|
+
enumerable: true,
|
|
335
|
+
get: function () {
|
|
336
|
+
return AUTO_ALIASING;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
334
339
|
Object.defineProperty(exports, 'DERIVED_DEPENDENCIES', {
|
|
335
340
|
enumerable: true,
|
|
336
341
|
get: function () {
|
package/dist/context.cjs
CHANGED
package/dist/context.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-
|
|
1
|
+
import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-B1bRSxSg.cjs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/context/context.d.ts
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-
|
|
1
|
+
import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-_VhWbhmU.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/context/context.d.ts
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization } from "./context-
|
|
1
|
+
import { getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization } from "./context-BxqO4Eg9.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/context/async-iterator.ts
|
|
@@ -681,7 +681,7 @@ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<
|
|
|
681
681
|
* Non-nullable Silk.
|
|
682
682
|
*/
|
|
683
683
|
declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
|
|
684
|
-
type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<
|
|
684
|
+
type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<Array<StandardSchemaV1.InferOutput<TSilk>>, Array<StandardSchemaV1.InferOutput<TSilk>>>;
|
|
685
685
|
/**
|
|
686
686
|
* List Silk.
|
|
687
687
|
*/
|
|
@@ -709,7 +709,6 @@ type GraphQLVariants<TSource extends GraphQLNullableType> = TSource | GraphQLLis
|
|
|
709
709
|
type InferScalarInternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarInternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarInternalByVariants<U>[] : never : T extends GraphQLScalarType<infer TInternal, any> ? TInternal | null | undefined : never;
|
|
710
710
|
type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarExternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarExternalByVariants<U>[] : never : T extends GraphQLScalarType<any, infer TExternal> ? TExternal | null | undefined : never;
|
|
711
711
|
type InferObjectSourceByVariants<T extends GraphQLVariants<GraphQLObjectType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? NonNullable<InferObjectSourceByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? InferObjectSourceByVariants<U>[] : never : T extends GraphQLObjectType<infer TSource> ? TSource | null | undefined : never;
|
|
712
|
-
type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
|
|
713
712
|
//#endregion
|
|
714
713
|
//#region src/resolver/resolver.d.ts
|
|
715
714
|
/**
|
|
@@ -740,7 +739,7 @@ declare const mutation$1: MutationFactoryWithChain;
|
|
|
740
739
|
* @param resolveOrOptions - Either a resolve function or options object
|
|
741
740
|
* @returns A GraphQL field resolver
|
|
742
741
|
*/
|
|
743
|
-
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) =>
|
|
742
|
+
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => Field<any, any, any, any> | FieldChainFactory<never, undefined, undefined>;
|
|
744
743
|
/**
|
|
745
744
|
* Factory function for creating GraphQL fields with chainable configuration
|
|
746
745
|
*/
|
|
@@ -1062,6 +1061,10 @@ interface ContextMemoryContainer {
|
|
|
1062
1061
|
}
|
|
1063
1062
|
declare function assignContextMap(target: ContextMemoryContainer): WeakMap<WeakKey, any>;
|
|
1064
1063
|
//#endregion
|
|
1064
|
+
//#region src/utils/constants.d.ts
|
|
1065
|
+
declare const DERIVED_DEPENDENCIES = "loom.derived-from-dependencies";
|
|
1066
|
+
declare const AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1067
|
+
//#endregion
|
|
1065
1068
|
//#region src/schema/schema-weaver.d.ts
|
|
1066
1069
|
interface SchemaWeaver {
|
|
1067
1070
|
vendor: string;
|
|
@@ -1084,6 +1087,7 @@ interface WeaverContext {
|
|
|
1084
1087
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1085
1088
|
getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
|
|
1086
1089
|
names: WeakMap<object, string>;
|
|
1090
|
+
autoAliasTypes: WeakSet<GraphQLNamedType>;
|
|
1087
1091
|
vendorWeavers: Map<string, SchemaWeaver>;
|
|
1088
1092
|
}
|
|
1089
1093
|
interface WeaverConfig {
|
|
@@ -1094,7 +1098,7 @@ declare function initWeaverContext(): WeaverContext;
|
|
|
1094
1098
|
declare namespace initWeaverContext {
|
|
1095
1099
|
var increasingID: number;
|
|
1096
1100
|
}
|
|
1097
|
-
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType";
|
|
1101
|
+
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType" | "autoAliasTypes";
|
|
1098
1102
|
interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
|
|
1099
1103
|
value?: WeaverContext;
|
|
1100
1104
|
useConfig<TConfig extends WeaverConfig, TCallback extends () => any>(config: TConfig, callback: TCallback): ReturnType<TCallback>;
|
|
@@ -1126,7 +1130,6 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
1126
1130
|
declare class LoomObjectType extends GraphQLObjectType {
|
|
1127
1131
|
protected extraFields: Map<string, BaseField>;
|
|
1128
1132
|
protected hiddenFields: Set<string>;
|
|
1129
|
-
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
1130
1133
|
protected weaverContext: WeaverContext;
|
|
1131
1134
|
protected globalOptions?: ResolverOptions;
|
|
1132
1135
|
/**
|
|
@@ -1137,11 +1140,7 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
1137
1140
|
weaverContext?: WeaverContext;
|
|
1138
1141
|
globalOptions?: ResolverOptions;
|
|
1139
1142
|
});
|
|
1140
|
-
|
|
1141
|
-
protected _aliases: string[];
|
|
1142
|
-
get aliases(): string[];
|
|
1143
|
-
addAlias(name: string): void;
|
|
1144
|
-
protected renameByAliases(): void;
|
|
1143
|
+
addAlias(alias?: string): void;
|
|
1145
1144
|
hideField(name: string): void;
|
|
1146
1145
|
addField(name: string, field: BaseField, resolver: Resolver | undefined): void;
|
|
1147
1146
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
@@ -1228,11 +1227,11 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
|
1228
1227
|
//#endregion
|
|
1229
1228
|
//#region src/schema/input.d.ts
|
|
1230
1229
|
interface EnsureInputOptions {
|
|
1231
|
-
fieldName
|
|
1230
|
+
fieldName: string;
|
|
1232
1231
|
}
|
|
1233
|
-
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions
|
|
1234
|
-
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions
|
|
1235
|
-
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions
|
|
1232
|
+
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions): GraphQLFieldConfigArgumentMap | undefined;
|
|
1233
|
+
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions): GraphQLInputType;
|
|
1234
|
+
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions): GraphQLInputObjectType;
|
|
1236
1235
|
//#endregion
|
|
1237
1236
|
//#region src/schema/interface.d.ts
|
|
1238
1237
|
declare function ensureInterfaceType(gqlType: GraphQLOutputType, interfaceConfig?: Partial<GraphQLInterfaceTypeConfig<any, any>>): GraphQLInterfaceType;
|
|
@@ -1252,4 +1251,4 @@ interface GQLoomExtensionAttribute {
|
|
|
1252
1251
|
directives?: string[];
|
|
1253
1252
|
}
|
|
1254
1253
|
//#endregion
|
|
1255
|
-
export { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation$1 as mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query$1 as query, resolver, screamingSnakeCase, silk, subscription$1 as subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext };
|
|
1254
|
+
export { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation$1 as mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query$1 as query, resolver, screamingSnakeCase, silk, subscription$1 as subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext };
|
|
@@ -679,7 +679,7 @@ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<
|
|
|
679
679
|
* Non-nullable Silk.
|
|
680
680
|
*/
|
|
681
681
|
declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
|
|
682
|
-
type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<
|
|
682
|
+
type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<Array<StandardSchemaV1.InferOutput<TSilk>>, Array<StandardSchemaV1.InferOutput<TSilk>>>;
|
|
683
683
|
/**
|
|
684
684
|
* List Silk.
|
|
685
685
|
*/
|
|
@@ -707,7 +707,6 @@ type GraphQLVariants<TSource extends GraphQLNullableType> = TSource | GraphQLLis
|
|
|
707
707
|
type InferScalarInternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarInternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarInternalByVariants<U>[] : never : T extends GraphQLScalarType<infer TInternal, any> ? TInternal | null | undefined : never;
|
|
708
708
|
type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarExternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarExternalByVariants<U>[] : never : T extends GraphQLScalarType<any, infer TExternal> ? TExternal | null | undefined : never;
|
|
709
709
|
type InferObjectSourceByVariants<T extends GraphQLVariants<GraphQLObjectType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? NonNullable<InferObjectSourceByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? InferObjectSourceByVariants<U>[] : never : T extends GraphQLObjectType<infer TSource> ? TSource | null | undefined : never;
|
|
710
|
-
type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
|
|
711
710
|
//#endregion
|
|
712
711
|
//#region src/resolver/resolver.d.ts
|
|
713
712
|
/**
|
|
@@ -738,7 +737,7 @@ declare const mutation$1: MutationFactoryWithChain;
|
|
|
738
737
|
* @param resolveOrOptions - Either a resolve function or options object
|
|
739
738
|
* @returns A GraphQL field resolver
|
|
740
739
|
*/
|
|
741
|
-
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) =>
|
|
740
|
+
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => Field<any, any, any, any> | FieldChainFactory<never, undefined, undefined>;
|
|
742
741
|
/**
|
|
743
742
|
* Factory function for creating GraphQL fields with chainable configuration
|
|
744
743
|
*/
|
|
@@ -1060,6 +1059,10 @@ interface ContextMemoryContainer {
|
|
|
1060
1059
|
}
|
|
1061
1060
|
declare function assignContextMap(target: ContextMemoryContainer): WeakMap<WeakKey, any>;
|
|
1062
1061
|
//#endregion
|
|
1062
|
+
//#region src/utils/constants.d.ts
|
|
1063
|
+
declare const DERIVED_DEPENDENCIES = "loom.derived-from-dependencies";
|
|
1064
|
+
declare const AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1065
|
+
//#endregion
|
|
1063
1066
|
//#region src/schema/schema-weaver.d.ts
|
|
1064
1067
|
interface SchemaWeaver {
|
|
1065
1068
|
vendor: string;
|
|
@@ -1082,6 +1085,7 @@ interface WeaverContext {
|
|
|
1082
1085
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1083
1086
|
getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
|
|
1084
1087
|
names: WeakMap<object, string>;
|
|
1088
|
+
autoAliasTypes: WeakSet<GraphQLNamedType>;
|
|
1085
1089
|
vendorWeavers: Map<string, SchemaWeaver>;
|
|
1086
1090
|
}
|
|
1087
1091
|
interface WeaverConfig {
|
|
@@ -1092,7 +1096,7 @@ declare function initWeaverContext(): WeaverContext;
|
|
|
1092
1096
|
declare namespace initWeaverContext {
|
|
1093
1097
|
var increasingID: number;
|
|
1094
1098
|
}
|
|
1095
|
-
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType";
|
|
1099
|
+
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType" | "autoAliasTypes";
|
|
1096
1100
|
interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
|
|
1097
1101
|
value?: WeaverContext;
|
|
1098
1102
|
useConfig<TConfig extends WeaverConfig, TCallback extends () => any>(config: TConfig, callback: TCallback): ReturnType<TCallback>;
|
|
@@ -1124,7 +1128,6 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
1124
1128
|
declare class LoomObjectType extends GraphQLObjectType {
|
|
1125
1129
|
protected extraFields: Map<string, BaseField>;
|
|
1126
1130
|
protected hiddenFields: Set<string>;
|
|
1127
|
-
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
1128
1131
|
protected weaverContext: WeaverContext;
|
|
1129
1132
|
protected globalOptions?: ResolverOptions;
|
|
1130
1133
|
/**
|
|
@@ -1135,11 +1138,7 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
1135
1138
|
weaverContext?: WeaverContext;
|
|
1136
1139
|
globalOptions?: ResolverOptions;
|
|
1137
1140
|
});
|
|
1138
|
-
|
|
1139
|
-
protected _aliases: string[];
|
|
1140
|
-
get aliases(): string[];
|
|
1141
|
-
addAlias(name: string): void;
|
|
1142
|
-
protected renameByAliases(): void;
|
|
1141
|
+
addAlias(alias?: string): void;
|
|
1143
1142
|
hideField(name: string): void;
|
|
1144
1143
|
addField(name: string, field: BaseField, resolver: Resolver | undefined): void;
|
|
1145
1144
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
@@ -1226,11 +1225,11 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
|
1226
1225
|
//#endregion
|
|
1227
1226
|
//#region src/schema/input.d.ts
|
|
1228
1227
|
interface EnsureInputOptions {
|
|
1229
|
-
fieldName
|
|
1228
|
+
fieldName: string;
|
|
1230
1229
|
}
|
|
1231
|
-
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions
|
|
1232
|
-
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions
|
|
1233
|
-
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions
|
|
1230
|
+
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions): GraphQLFieldConfigArgumentMap | undefined;
|
|
1231
|
+
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions): GraphQLInputType;
|
|
1232
|
+
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions): GraphQLInputObjectType;
|
|
1234
1233
|
//#endregion
|
|
1235
1234
|
//#region src/schema/interface.d.ts
|
|
1236
1235
|
declare function ensureInterfaceType(gqlType: GraphQLOutputType, interfaceConfig?: Partial<GraphQLInterfaceTypeConfig<any, any>>): GraphQLInterfaceType;
|
|
@@ -1250,4 +1249,4 @@ interface GQLoomExtensionAttribute {
|
|
|
1250
1249
|
directives?: string[];
|
|
1251
1250
|
}
|
|
1252
1251
|
//#endregion
|
|
1253
|
-
export { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation$1 as mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query$1 as query, resolver, screamingSnakeCase, silk, subscription$1 as subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext };
|
|
1252
|
+
export { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation$1 as mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query$1 as query, resolver, screamingSnakeCase, silk, subscription$1 as subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext };
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_context = require('./context-
|
|
1
|
+
const require_context = require('./context-DshDoxiE.cjs');
|
|
2
2
|
let graphql = require("graphql");
|
|
3
3
|
graphql = require_context.__toESM(graphql);
|
|
4
4
|
|
|
@@ -46,8 +46,7 @@ function filterMiddlewares(operation, ...middlewareList) {
|
|
|
46
46
|
return middlewareList.reduce((acc, m) => {
|
|
47
47
|
if (!m) return acc;
|
|
48
48
|
acc.push(...ensureArray(m).filter((m$1) => {
|
|
49
|
-
|
|
50
|
-
return ops.includes(operation);
|
|
49
|
+
return (m$1.operations ?? defaultOperations).includes(operation);
|
|
51
50
|
}));
|
|
52
51
|
return acc;
|
|
53
52
|
}, []);
|
|
@@ -149,13 +148,11 @@ function tryIn(func, ...locations) {
|
|
|
149
148
|
function markLocation(message, ...locations) {
|
|
150
149
|
if (locations.length === 0) return message;
|
|
151
150
|
const [existingPrefix, newMessage] = (() => {
|
|
152
|
-
const
|
|
153
|
-
const match = existingPrefixPattern.exec(message);
|
|
151
|
+
const match = /^\[(.*?)\]/.exec(message);
|
|
154
152
|
if (match) return [match[1], message.slice(match[0].length).trim()];
|
|
155
153
|
return [void 0, message];
|
|
156
154
|
})();
|
|
157
|
-
|
|
158
|
-
return `[${combinedLocation}] ${newMessage}`;
|
|
155
|
+
return `[${locations.concat(existingPrefix ? [existingPrefix] : []).join(".")}] ${newMessage}`;
|
|
159
156
|
}
|
|
160
157
|
|
|
161
158
|
//#endregion
|
|
@@ -245,6 +242,7 @@ var EasyDataLoader = class extends LoomDataLoader {
|
|
|
245
242
|
//#region src/schema/weaver-context.ts
|
|
246
243
|
let ref;
|
|
247
244
|
const names = /* @__PURE__ */ new WeakMap();
|
|
245
|
+
const autoAliasTypes = /* @__PURE__ */ new WeakSet();
|
|
248
246
|
function initWeaverContext() {
|
|
249
247
|
return {
|
|
250
248
|
id: initWeaverContext.increasingID++,
|
|
@@ -264,6 +262,7 @@ function initWeaverContext() {
|
|
|
264
262
|
this.configs.delete(key);
|
|
265
263
|
},
|
|
266
264
|
names,
|
|
265
|
+
autoAliasTypes,
|
|
267
266
|
namedTypes: /* @__PURE__ */ new Map(),
|
|
268
267
|
memoNamedType(gqlTypeValue) {
|
|
269
268
|
const gqlType = gqlTypeValue;
|
|
@@ -319,6 +318,7 @@ const weaverContext = {
|
|
|
319
318
|
return result;
|
|
320
319
|
},
|
|
321
320
|
names,
|
|
321
|
+
autoAliasTypes,
|
|
322
322
|
getNamedType(name) {
|
|
323
323
|
return ref?.getNamedType(name);
|
|
324
324
|
},
|
|
@@ -451,7 +451,7 @@ function parseSilk(silk$1, input) {
|
|
|
451
451
|
return silk$1["~standard"].validate(input);
|
|
452
452
|
}
|
|
453
453
|
function isSilk(target) {
|
|
454
|
-
if (typeof target !== "object") return false;
|
|
454
|
+
if (typeof target !== "object" && typeof target !== "function") return false;
|
|
455
455
|
if (target == null) return false;
|
|
456
456
|
if (require_context.GET_GRAPHQL_TYPE in target) return true;
|
|
457
457
|
if (!("~standard" in target)) return false;
|
|
@@ -676,8 +676,7 @@ var FieldChainFactory = class FieldChainFactory extends BaseChainFactory {
|
|
|
676
676
|
return createField(this.options.output, {
|
|
677
677
|
...this.options,
|
|
678
678
|
resolve: (parent, input, payload) => {
|
|
679
|
-
|
|
680
|
-
return loader.load([
|
|
679
|
+
return FieldLoader.getByPath(payload, resolve, this.options?.input != null).load([
|
|
681
680
|
parent,
|
|
682
681
|
input,
|
|
683
682
|
payload
|
|
@@ -1131,11 +1130,10 @@ var ChainResolver = class {
|
|
|
1131
1130
|
return this;
|
|
1132
1131
|
}
|
|
1133
1132
|
toExecutor(...middlewares) {
|
|
1134
|
-
|
|
1135
|
-
return executor;
|
|
1133
|
+
return mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
|
|
1136
1134
|
}
|
|
1137
1135
|
toExecutorOperation(field$1, executorMiddlewares) {
|
|
1138
|
-
if (field$1 === require_context.FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return
|
|
1136
|
+
if (field$1 === require_context.FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return;
|
|
1139
1137
|
const operation = field$1["~meta"].operation;
|
|
1140
1138
|
const middlewares = filterMiddlewares(operation, executorMiddlewares, this.meta.options?.middlewares, field$1["~meta"].middlewares);
|
|
1141
1139
|
if (field$1["~meta"].operation === "field") {
|
|
@@ -1208,6 +1206,15 @@ var ObjectChainResolver = class extends ChainResolver {
|
|
|
1208
1206
|
}
|
|
1209
1207
|
};
|
|
1210
1208
|
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/schema/alias.ts
|
|
1211
|
+
function setAlias(namedType, alias, context) {
|
|
1212
|
+
if (namedType.name === require_context.AUTO_ALIASING) context.autoAliasTypes.add(namedType);
|
|
1213
|
+
if (!context.autoAliasTypes.has(namedType) || !alias) return;
|
|
1214
|
+
if (namedType.name === require_context.AUTO_ALIASING) namedType.name = alias;
|
|
1215
|
+
namedType.name = alias.length < namedType.name.length ? alias : namedType.name;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1211
1218
|
//#endregion
|
|
1212
1219
|
//#region src/schema/input.ts
|
|
1213
1220
|
function inputToArgs(input, options) {
|
|
@@ -1216,8 +1223,7 @@ function inputToArgs(input, options) {
|
|
|
1216
1223
|
let inputType = getGraphQLType(input);
|
|
1217
1224
|
if ((0, graphql.isNonNullType)(inputType)) inputType = inputType.ofType;
|
|
1218
1225
|
if ((0, graphql.isObjectType)(inputType)) return mapValue(inputType.toConfig().fields, (it, key) => {
|
|
1219
|
-
|
|
1220
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1226
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1221
1227
|
return toInputFieldConfig(it, { fieldName });
|
|
1222
1228
|
});
|
|
1223
1229
|
throw new Error(`Cannot convert ${inputType.toString()} to input type`);
|
|
@@ -1225,8 +1231,7 @@ function inputToArgs(input, options) {
|
|
|
1225
1231
|
const args = {};
|
|
1226
1232
|
Object.entries(input).forEach(([name, field$1]) => {
|
|
1227
1233
|
tryIn(() => {
|
|
1228
|
-
|
|
1229
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1234
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1230
1235
|
args[name] = {
|
|
1231
1236
|
...field$1,
|
|
1232
1237
|
type: ensureInputType(field$1, { fieldName })
|
|
@@ -1244,6 +1249,13 @@ function ensureInputType(silkOrType, options) {
|
|
|
1244
1249
|
if ((0, graphql.isNonNullType)(gqlType)) return new graphql.GraphQLNonNull(ensureInputType(gqlType.ofType, options));
|
|
1245
1250
|
if ((0, graphql.isListType)(gqlType)) return new graphql.GraphQLList(ensureInputType(gqlType.ofType, options));
|
|
1246
1251
|
if ((0, graphql.isObjectType)(gqlType) || (0, graphql.isInterfaceType)(gqlType)) return ensureInputObjectType(gqlType, options);
|
|
1252
|
+
if ((0, graphql.isEnumType)(gqlType)) {
|
|
1253
|
+
if (gqlType.name === require_context.AUTO_ALIASING) {
|
|
1254
|
+
const alias = `${pascalCase(options.fieldName)}Input`;
|
|
1255
|
+
setAlias(gqlType, alias, weaverContext);
|
|
1256
|
+
}
|
|
1257
|
+
return gqlType;
|
|
1258
|
+
}
|
|
1247
1259
|
return gqlType;
|
|
1248
1260
|
}
|
|
1249
1261
|
function ensureInputObjectType(object, options) {
|
|
@@ -1252,9 +1264,8 @@ function ensureInputObjectType(object, options) {
|
|
|
1252
1264
|
if (existing != null) return existing;
|
|
1253
1265
|
const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
|
|
1254
1266
|
let name = object.name;
|
|
1255
|
-
if (name ===
|
|
1256
|
-
|
|
1257
|
-
name = getInputObjectName(name);
|
|
1267
|
+
if (name === require_context.AUTO_ALIASING) name = `${pascalCase(options.fieldName)}Input`;
|
|
1268
|
+
name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
|
|
1258
1269
|
const input = new graphql.GraphQLInputObjectType({
|
|
1259
1270
|
...config,
|
|
1260
1271
|
name,
|
|
@@ -1276,10 +1287,9 @@ function inputFieldName(name) {
|
|
|
1276
1287
|
|
|
1277
1288
|
//#endregion
|
|
1278
1289
|
//#region src/schema/object.ts
|
|
1279
|
-
var LoomObjectType = class
|
|
1290
|
+
var LoomObjectType = class extends graphql.GraphQLObjectType {
|
|
1280
1291
|
extraFields = /* @__PURE__ */ new Map();
|
|
1281
1292
|
hiddenFields = /* @__PURE__ */ new Set();
|
|
1282
|
-
static AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1283
1293
|
weaverContext;
|
|
1284
1294
|
globalOptions;
|
|
1285
1295
|
/**
|
|
@@ -1300,22 +1310,11 @@ var LoomObjectType = class LoomObjectType extends graphql.GraphQLObjectType {
|
|
|
1300
1310
|
this.globalOptions = options.globalOptions;
|
|
1301
1311
|
this.weaverContext = options.weaverContext ?? initWeaverContext();
|
|
1302
1312
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
1303
|
-
if (this.name
|
|
1313
|
+
if (this.name === require_context.AUTO_ALIASING) this.weaverContext.autoAliasTypes.add(this);
|
|
1304
1314
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
return this._aliases;
|
|
1309
|
-
}
|
|
1310
|
-
addAlias(name) {
|
|
1311
|
-
if (this.hasExplicitName) return;
|
|
1312
|
-
this._aliases.push(name);
|
|
1313
|
-
this.renameByAliases();
|
|
1314
|
-
}
|
|
1315
|
-
renameByAliases() {
|
|
1316
|
-
let name;
|
|
1317
|
-
for (const alias of this.aliases) if (name === void 0 || alias.length < name.length) name = alias;
|
|
1318
|
-
if (name) this.name = name;
|
|
1315
|
+
addAlias(alias) {
|
|
1316
|
+
if (!this.weaverContext.autoAliasTypes.has(this) || !alias) return;
|
|
1317
|
+
this.name = alias.length < this.name.length ? alias : this.name;
|
|
1319
1318
|
}
|
|
1320
1319
|
hideField(name) {
|
|
1321
1320
|
this.hiddenFields.add(name);
|
|
@@ -1354,7 +1353,7 @@ var LoomObjectType = class LoomObjectType extends graphql.GraphQLObjectType {
|
|
|
1354
1353
|
return {
|
|
1355
1354
|
...extract(field$1),
|
|
1356
1355
|
type: outputType,
|
|
1357
|
-
args: inputToArgs(field$1["~meta"].input, { fieldName:
|
|
1356
|
+
args: inputToArgs(field$1["~meta"].input, { fieldName: parentName(this.name) + fieldName }),
|
|
1358
1357
|
resolve,
|
|
1359
1358
|
...subscribe ? { subscribe } : {}
|
|
1360
1359
|
};
|
|
@@ -1506,13 +1505,17 @@ const OPERATION_OBJECT_NAMES = new Set([
|
|
|
1506
1505
|
]);
|
|
1507
1506
|
function getCacheType(gqlType, options = {}) {
|
|
1508
1507
|
const context = options.weaverContext ?? weaverContext;
|
|
1508
|
+
const getAlias = () => {
|
|
1509
|
+
if (!options.fieldName || !options.parent) return;
|
|
1510
|
+
return parentName(options.parent.name) + pascalCase(options.fieldName);
|
|
1511
|
+
};
|
|
1509
1512
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1510
1513
|
if ((0, graphql.isObjectType)(gqlType)) {
|
|
1511
1514
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1512
1515
|
if (gqlObject != null) return gqlObject;
|
|
1513
1516
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1514
1517
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1515
|
-
|
|
1518
|
+
setAlias(loomObject, getAlias(), context);
|
|
1516
1519
|
return loomObject;
|
|
1517
1520
|
} else if ((0, graphql.isListType)(gqlType)) return new graphql.GraphQLList(getCacheType(gqlType.ofType, options));
|
|
1518
1521
|
else if ((0, graphql.isNonNullType)(gqlType)) return new graphql.GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
@@ -1522,10 +1525,17 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1522
1525
|
const config = gqlType.toConfig();
|
|
1523
1526
|
const unionType = new graphql.GraphQLUnionType({
|
|
1524
1527
|
...config,
|
|
1525
|
-
types: config.types.map((type) => getCacheType(type,
|
|
1528
|
+
types: config.types.map((type, i) => getCacheType(type, {
|
|
1529
|
+
...options,
|
|
1530
|
+
fieldName: options.fieldName ? `${options.fieldName}${i + 1}` : void 0
|
|
1531
|
+
}))
|
|
1526
1532
|
});
|
|
1527
1533
|
context.loomUnionMap?.set(gqlType, unionType);
|
|
1534
|
+
setAlias(unionType, getAlias(), context);
|
|
1528
1535
|
return unionType;
|
|
1536
|
+
} else if ((0, graphql.isEnumType)(gqlType)) {
|
|
1537
|
+
setAlias(gqlType, getAlias(), context);
|
|
1538
|
+
return gqlType;
|
|
1529
1539
|
}
|
|
1530
1540
|
return gqlType;
|
|
1531
1541
|
}
|
|
@@ -1608,14 +1618,13 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
|
|
|
1608
1618
|
weaveGraphQLSchema() {
|
|
1609
1619
|
const { query: query$1, mutation: mutation$1, subscription: subscription$1, types } = this;
|
|
1610
1620
|
const config = this.context.getConfig("gqloom.core.schema");
|
|
1611
|
-
|
|
1621
|
+
return new graphql.GraphQLSchema({
|
|
1612
1622
|
query: query$1,
|
|
1613
1623
|
mutation: mutation$1,
|
|
1614
1624
|
subscription: subscription$1,
|
|
1615
1625
|
types: [...types ?? [], ...config?.types ?? []],
|
|
1616
1626
|
...config
|
|
1617
1627
|
});
|
|
1618
|
-
return schema;
|
|
1619
1628
|
}
|
|
1620
1629
|
addResolver(resolver$1, modifyParent) {
|
|
1621
1630
|
const resolverOptions = resolver$1["~meta"].options;
|
|
@@ -1641,10 +1650,7 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
|
|
|
1641
1650
|
} else if (field$1["~meta"].operation === "field") {
|
|
1642
1651
|
if (parentObject == null) return;
|
|
1643
1652
|
parentObject.addField(name, field$1, resolver$1);
|
|
1644
|
-
} else
|
|
1645
|
-
const operationObject = this.getOperationObject(field$1["~meta"].operation);
|
|
1646
|
-
operationObject.addField(name, field$1, resolver$1);
|
|
1647
|
-
}
|
|
1653
|
+
} else this.getOperationObject(field$1["~meta"].operation).addField(name, field$1, resolver$1);
|
|
1648
1654
|
});
|
|
1649
1655
|
return this;
|
|
1650
1656
|
}
|
|
@@ -1751,8 +1757,10 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1751
1757
|
}
|
|
1752
1758
|
|
|
1753
1759
|
//#endregion
|
|
1760
|
+
exports.AUTO_ALIASING = require_context.AUTO_ALIASING;
|
|
1754
1761
|
exports.BaseChainFactory = BaseChainFactory;
|
|
1755
1762
|
exports.ChainResolver = ChainResolver;
|
|
1763
|
+
exports.DERIVED_DEPENDENCIES = require_context.DERIVED_DEPENDENCIES;
|
|
1756
1764
|
exports.EasyDataLoader = EasyDataLoader;
|
|
1757
1765
|
exports.FieldChainFactory = FieldChainFactory;
|
|
1758
1766
|
exports.FieldFactoryWithResolve = FieldFactoryWithResolve;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext } from "./index-
|
|
2
|
-
export { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, types_loom_d_exports as Loom, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, symbols_d_exports as SYMBOLS, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|
|
1
|
+
import { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext } from "./index-B1bRSxSg.cjs";
|
|
2
|
+
export { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, types_loom_d_exports as Loom, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, symbols_d_exports as SYMBOLS, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext } from "./index-
|
|
2
|
-
export { BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, types_loom_d_exports as Loom, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, symbols_d_exports as SYMBOLS, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|
|
1
|
+
import { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, symbols_d_exports, toObjMap, tryIn, types_loom_d_exports, weave, weaverContext } from "./index-_VhWbhmU.js";
|
|
2
|
+
export { AUTO_ALIASING, BaseChainFactory, BaseField, BatchLoadFn, CallableInputParser, CallableMiddlewareOptions, ChainFactoryOptions, ChainResolver, CoreSchemaWeaverConfig, CoreSchemaWeaverConfigOptions, DERIVED_DEPENDENCIES, DirectiveItem, DirectiveRecord, EasyDataLoader, Executor, Field, FieldChainFactory, FieldFactory, FieldFactoryWithResolve, FieldFactoryWithUtils, FieldMeta, FieldOptions, FieldOrOperation, FieldOrOperationType, GQLoomExtensionAttribute, GQLoomExtensions, GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, IChainFactory, InferFieldInput, InferFieldOutput, InferInputI, InferInputO, IsAny, ListSilk, types_loom_d_exports as Loom, LoomDataLoader, LoomObjectType, MayPromise, Middleware, MiddlewareConfig, MiddlewareOperation, MiddlewareOptions, Mutation, MutationChainFactory, MutationFactory, MutationFactoryWithChain, MutationFactoryWithResolve, MutationOptions, NonNullSilk, NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, OnlyMemoizationPayload, Operation, OperationType, Query, QueryChainFactory, QueryFactory, QueryFactoryWithChain, QueryFactoryWithResolve, QueryOptions, RequireKeys, ResolvableSubscription, Resolver, ResolverFactory, ResolverMeta, ResolverOptions, ResolverOptionsWithExtensions, ResolverOptionsWithParent, ResolverPayload, ResolvingFields, ResolvingOptions, symbols_d_exports as SYMBOLS, SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactory, SubscriptionFactoryWithChain, SubscriptionNeedResolve, SubscriptionOptions, ToExecutorProps, ValueOf, WeaverConfig, WeaverContext, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports } from "./context-
|
|
1
|
+
import { AUTO_ALIASING, DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports } from "./context-BxqO4Eg9.js";
|
|
2
2
|
import { GraphQLError, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLUnionType, assertName, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, resolveObjMapThunk } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/args.ts
|
|
@@ -45,8 +45,7 @@ function filterMiddlewares(operation, ...middlewareList) {
|
|
|
45
45
|
return middlewareList.reduce((acc, m) => {
|
|
46
46
|
if (!m) return acc;
|
|
47
47
|
acc.push(...ensureArray(m).filter((m$1) => {
|
|
48
|
-
|
|
49
|
-
return ops.includes(operation);
|
|
48
|
+
return (m$1.operations ?? defaultOperations).includes(operation);
|
|
50
49
|
}));
|
|
51
50
|
return acc;
|
|
52
51
|
}, []);
|
|
@@ -148,13 +147,11 @@ function tryIn(func, ...locations) {
|
|
|
148
147
|
function markLocation(message, ...locations) {
|
|
149
148
|
if (locations.length === 0) return message;
|
|
150
149
|
const [existingPrefix, newMessage] = (() => {
|
|
151
|
-
const
|
|
152
|
-
const match = existingPrefixPattern.exec(message);
|
|
150
|
+
const match = /^\[(.*?)\]/.exec(message);
|
|
153
151
|
if (match) return [match[1], message.slice(match[0].length).trim()];
|
|
154
152
|
return [void 0, message];
|
|
155
153
|
})();
|
|
156
|
-
|
|
157
|
-
return `[${combinedLocation}] ${newMessage}`;
|
|
154
|
+
return `[${locations.concat(existingPrefix ? [existingPrefix] : []).join(".")}] ${newMessage}`;
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
//#endregion
|
|
@@ -244,6 +241,7 @@ var EasyDataLoader = class extends LoomDataLoader {
|
|
|
244
241
|
//#region src/schema/weaver-context.ts
|
|
245
242
|
let ref;
|
|
246
243
|
const names = /* @__PURE__ */ new WeakMap();
|
|
244
|
+
const autoAliasTypes = /* @__PURE__ */ new WeakSet();
|
|
247
245
|
function initWeaverContext() {
|
|
248
246
|
return {
|
|
249
247
|
id: initWeaverContext.increasingID++,
|
|
@@ -263,6 +261,7 @@ function initWeaverContext() {
|
|
|
263
261
|
this.configs.delete(key);
|
|
264
262
|
},
|
|
265
263
|
names,
|
|
264
|
+
autoAliasTypes,
|
|
266
265
|
namedTypes: /* @__PURE__ */ new Map(),
|
|
267
266
|
memoNamedType(gqlTypeValue) {
|
|
268
267
|
const gqlType = gqlTypeValue;
|
|
@@ -318,6 +317,7 @@ const weaverContext = {
|
|
|
318
317
|
return result;
|
|
319
318
|
},
|
|
320
319
|
names,
|
|
320
|
+
autoAliasTypes,
|
|
321
321
|
getNamedType(name) {
|
|
322
322
|
return ref?.getNamedType(name);
|
|
323
323
|
},
|
|
@@ -450,7 +450,7 @@ function parseSilk(silk$1, input) {
|
|
|
450
450
|
return silk$1["~standard"].validate(input);
|
|
451
451
|
}
|
|
452
452
|
function isSilk(target) {
|
|
453
|
-
if (typeof target !== "object") return false;
|
|
453
|
+
if (typeof target !== "object" && typeof target !== "function") return false;
|
|
454
454
|
if (target == null) return false;
|
|
455
455
|
if (GET_GRAPHQL_TYPE in target) return true;
|
|
456
456
|
if (!("~standard" in target)) return false;
|
|
@@ -675,8 +675,7 @@ var FieldChainFactory = class FieldChainFactory extends BaseChainFactory {
|
|
|
675
675
|
return createField(this.options.output, {
|
|
676
676
|
...this.options,
|
|
677
677
|
resolve: (parent, input, payload) => {
|
|
678
|
-
|
|
679
|
-
return loader.load([
|
|
678
|
+
return FieldLoader.getByPath(payload, resolve, this.options?.input != null).load([
|
|
680
679
|
parent,
|
|
681
680
|
input,
|
|
682
681
|
payload
|
|
@@ -1130,11 +1129,10 @@ var ChainResolver = class {
|
|
|
1130
1129
|
return this;
|
|
1131
1130
|
}
|
|
1132
1131
|
toExecutor(...middlewares) {
|
|
1133
|
-
|
|
1134
|
-
return executor;
|
|
1132
|
+
return mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
|
|
1135
1133
|
}
|
|
1136
1134
|
toExecutorOperation(field$1, executorMiddlewares) {
|
|
1137
|
-
if (field$1 === FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return
|
|
1135
|
+
if (field$1 === FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return;
|
|
1138
1136
|
const operation = field$1["~meta"].operation;
|
|
1139
1137
|
const middlewares = filterMiddlewares(operation, executorMiddlewares, this.meta.options?.middlewares, field$1["~meta"].middlewares);
|
|
1140
1138
|
if (field$1["~meta"].operation === "field") {
|
|
@@ -1207,6 +1205,15 @@ var ObjectChainResolver = class extends ChainResolver {
|
|
|
1207
1205
|
}
|
|
1208
1206
|
};
|
|
1209
1207
|
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/schema/alias.ts
|
|
1210
|
+
function setAlias(namedType, alias, context) {
|
|
1211
|
+
if (namedType.name === AUTO_ALIASING) context.autoAliasTypes.add(namedType);
|
|
1212
|
+
if (!context.autoAliasTypes.has(namedType) || !alias) return;
|
|
1213
|
+
if (namedType.name === AUTO_ALIASING) namedType.name = alias;
|
|
1214
|
+
namedType.name = alias.length < namedType.name.length ? alias : namedType.name;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1210
1217
|
//#endregion
|
|
1211
1218
|
//#region src/schema/input.ts
|
|
1212
1219
|
function inputToArgs(input, options) {
|
|
@@ -1215,8 +1222,7 @@ function inputToArgs(input, options) {
|
|
|
1215
1222
|
let inputType = getGraphQLType(input);
|
|
1216
1223
|
if (isNonNullType(inputType)) inputType = inputType.ofType;
|
|
1217
1224
|
if (isObjectType(inputType)) return mapValue(inputType.toConfig().fields, (it, key) => {
|
|
1218
|
-
|
|
1219
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1225
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1220
1226
|
return toInputFieldConfig(it, { fieldName });
|
|
1221
1227
|
});
|
|
1222
1228
|
throw new Error(`Cannot convert ${inputType.toString()} to input type`);
|
|
@@ -1224,8 +1230,7 @@ function inputToArgs(input, options) {
|
|
|
1224
1230
|
const args = {};
|
|
1225
1231
|
Object.entries(input).forEach(([name, field$1]) => {
|
|
1226
1232
|
tryIn(() => {
|
|
1227
|
-
|
|
1228
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1233
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1229
1234
|
args[name] = {
|
|
1230
1235
|
...field$1,
|
|
1231
1236
|
type: ensureInputType(field$1, { fieldName })
|
|
@@ -1243,6 +1248,13 @@ function ensureInputType(silkOrType, options) {
|
|
|
1243
1248
|
if (isNonNullType(gqlType)) return new GraphQLNonNull(ensureInputType(gqlType.ofType, options));
|
|
1244
1249
|
if (isListType(gqlType)) return new GraphQLList(ensureInputType(gqlType.ofType, options));
|
|
1245
1250
|
if (isObjectType(gqlType) || isInterfaceType(gqlType)) return ensureInputObjectType(gqlType, options);
|
|
1251
|
+
if (isEnumType(gqlType)) {
|
|
1252
|
+
if (gqlType.name === AUTO_ALIASING) {
|
|
1253
|
+
const alias = `${pascalCase(options.fieldName)}Input`;
|
|
1254
|
+
setAlias(gqlType, alias, weaverContext);
|
|
1255
|
+
}
|
|
1256
|
+
return gqlType;
|
|
1257
|
+
}
|
|
1246
1258
|
return gqlType;
|
|
1247
1259
|
}
|
|
1248
1260
|
function ensureInputObjectType(object, options) {
|
|
@@ -1251,9 +1263,8 @@ function ensureInputObjectType(object, options) {
|
|
|
1251
1263
|
if (existing != null) return existing;
|
|
1252
1264
|
const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
|
|
1253
1265
|
let name = object.name;
|
|
1254
|
-
if (name ===
|
|
1255
|
-
|
|
1256
|
-
name = getInputObjectName(name);
|
|
1266
|
+
if (name === AUTO_ALIASING) name = `${pascalCase(options.fieldName)}Input`;
|
|
1267
|
+
name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
|
|
1257
1268
|
const input = new GraphQLInputObjectType({
|
|
1258
1269
|
...config,
|
|
1259
1270
|
name,
|
|
@@ -1275,10 +1286,9 @@ function inputFieldName(name) {
|
|
|
1275
1286
|
|
|
1276
1287
|
//#endregion
|
|
1277
1288
|
//#region src/schema/object.ts
|
|
1278
|
-
var LoomObjectType = class
|
|
1289
|
+
var LoomObjectType = class extends GraphQLObjectType {
|
|
1279
1290
|
extraFields = /* @__PURE__ */ new Map();
|
|
1280
1291
|
hiddenFields = /* @__PURE__ */ new Set();
|
|
1281
|
-
static AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1282
1292
|
weaverContext;
|
|
1283
1293
|
globalOptions;
|
|
1284
1294
|
/**
|
|
@@ -1299,22 +1309,11 @@ var LoomObjectType = class LoomObjectType extends GraphQLObjectType {
|
|
|
1299
1309
|
this.globalOptions = options.globalOptions;
|
|
1300
1310
|
this.weaverContext = options.weaverContext ?? initWeaverContext();
|
|
1301
1311
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
1302
|
-
if (this.name
|
|
1312
|
+
if (this.name === AUTO_ALIASING) this.weaverContext.autoAliasTypes.add(this);
|
|
1303
1313
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
return this._aliases;
|
|
1308
|
-
}
|
|
1309
|
-
addAlias(name) {
|
|
1310
|
-
if (this.hasExplicitName) return;
|
|
1311
|
-
this._aliases.push(name);
|
|
1312
|
-
this.renameByAliases();
|
|
1313
|
-
}
|
|
1314
|
-
renameByAliases() {
|
|
1315
|
-
let name;
|
|
1316
|
-
for (const alias of this.aliases) if (name === void 0 || alias.length < name.length) name = alias;
|
|
1317
|
-
if (name) this.name = name;
|
|
1314
|
+
addAlias(alias) {
|
|
1315
|
+
if (!this.weaverContext.autoAliasTypes.has(this) || !alias) return;
|
|
1316
|
+
this.name = alias.length < this.name.length ? alias : this.name;
|
|
1318
1317
|
}
|
|
1319
1318
|
hideField(name) {
|
|
1320
1319
|
this.hiddenFields.add(name);
|
|
@@ -1353,7 +1352,7 @@ var LoomObjectType = class LoomObjectType extends GraphQLObjectType {
|
|
|
1353
1352
|
return {
|
|
1354
1353
|
...extract(field$1),
|
|
1355
1354
|
type: outputType,
|
|
1356
|
-
args: inputToArgs(field$1["~meta"].input, { fieldName:
|
|
1355
|
+
args: inputToArgs(field$1["~meta"].input, { fieldName: parentName(this.name) + fieldName }),
|
|
1357
1356
|
resolve,
|
|
1358
1357
|
...subscribe ? { subscribe } : {}
|
|
1359
1358
|
};
|
|
@@ -1505,13 +1504,17 @@ const OPERATION_OBJECT_NAMES = new Set([
|
|
|
1505
1504
|
]);
|
|
1506
1505
|
function getCacheType(gqlType, options = {}) {
|
|
1507
1506
|
const context = options.weaverContext ?? weaverContext;
|
|
1507
|
+
const getAlias = () => {
|
|
1508
|
+
if (!options.fieldName || !options.parent) return;
|
|
1509
|
+
return parentName(options.parent.name) + pascalCase(options.fieldName);
|
|
1510
|
+
};
|
|
1508
1511
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1509
1512
|
if (isObjectType(gqlType)) {
|
|
1510
1513
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1511
1514
|
if (gqlObject != null) return gqlObject;
|
|
1512
1515
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1513
1516
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1514
|
-
|
|
1517
|
+
setAlias(loomObject, getAlias(), context);
|
|
1515
1518
|
return loomObject;
|
|
1516
1519
|
} else if (isListType(gqlType)) return new GraphQLList(getCacheType(gqlType.ofType, options));
|
|
1517
1520
|
else if (isNonNullType(gqlType)) return new GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
@@ -1521,10 +1524,17 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1521
1524
|
const config = gqlType.toConfig();
|
|
1522
1525
|
const unionType = new GraphQLUnionType({
|
|
1523
1526
|
...config,
|
|
1524
|
-
types: config.types.map((type) => getCacheType(type,
|
|
1527
|
+
types: config.types.map((type, i) => getCacheType(type, {
|
|
1528
|
+
...options,
|
|
1529
|
+
fieldName: options.fieldName ? `${options.fieldName}${i + 1}` : void 0
|
|
1530
|
+
}))
|
|
1525
1531
|
});
|
|
1526
1532
|
context.loomUnionMap?.set(gqlType, unionType);
|
|
1533
|
+
setAlias(unionType, getAlias(), context);
|
|
1527
1534
|
return unionType;
|
|
1535
|
+
} else if (isEnumType(gqlType)) {
|
|
1536
|
+
setAlias(gqlType, getAlias(), context);
|
|
1537
|
+
return gqlType;
|
|
1528
1538
|
}
|
|
1529
1539
|
return gqlType;
|
|
1530
1540
|
}
|
|
@@ -1607,14 +1617,13 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
|
|
|
1607
1617
|
weaveGraphQLSchema() {
|
|
1608
1618
|
const { query: query$1, mutation: mutation$1, subscription: subscription$1, types } = this;
|
|
1609
1619
|
const config = this.context.getConfig("gqloom.core.schema");
|
|
1610
|
-
|
|
1620
|
+
return new GraphQLSchema({
|
|
1611
1621
|
query: query$1,
|
|
1612
1622
|
mutation: mutation$1,
|
|
1613
1623
|
subscription: subscription$1,
|
|
1614
1624
|
types: [...types ?? [], ...config?.types ?? []],
|
|
1615
1625
|
...config
|
|
1616
1626
|
});
|
|
1617
|
-
return schema;
|
|
1618
1627
|
}
|
|
1619
1628
|
addResolver(resolver$1, modifyParent) {
|
|
1620
1629
|
const resolverOptions = resolver$1["~meta"].options;
|
|
@@ -1640,10 +1649,7 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
|
|
|
1640
1649
|
} else if (field$1["~meta"].operation === "field") {
|
|
1641
1650
|
if (parentObject == null) return;
|
|
1642
1651
|
parentObject.addField(name, field$1, resolver$1);
|
|
1643
|
-
} else
|
|
1644
|
-
const operationObject = this.getOperationObject(field$1["~meta"].operation);
|
|
1645
|
-
operationObject.addField(name, field$1, resolver$1);
|
|
1646
|
-
}
|
|
1652
|
+
} else this.getOperationObject(field$1["~meta"].operation).addField(name, field$1, resolver$1);
|
|
1647
1653
|
});
|
|
1648
1654
|
return this;
|
|
1649
1655
|
}
|
|
@@ -1750,4 +1756,4 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1750
1756
|
}
|
|
1751
1757
|
|
|
1752
1758
|
//#endregion
|
|
1753
|
-
export { BaseChainFactory, ChainResolver, EasyDataLoader, FieldChainFactory, FieldFactoryWithResolve, GraphQLSchemaLoom, LoomDataLoader, LoomObjectType, MutationChainFactory, MutationFactoryWithResolve, OPERATION_OBJECT_NAMES, ObjectChainResolver, QueryChainFactory, QueryFactoryWithResolve, symbols_exports as SYMBOLS, SubscriptionChainFactory, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|
|
1759
|
+
export { AUTO_ALIASING, BaseChainFactory, ChainResolver, DERIVED_DEPENDENCIES, EasyDataLoader, FieldChainFactory, FieldFactoryWithResolve, GraphQLSchemaLoom, LoomDataLoader, LoomObjectType, MutationChainFactory, MutationFactoryWithResolve, OPERATION_OBJECT_NAMES, ObjectChainResolver, QueryChainFactory, QueryFactoryWithResolve, symbols_exports as SYMBOLS, SubscriptionChainFactory, applyMiddlewares, assignContextMap, capitalize, collectName, collectNames, createField, createInputParser, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, filterMiddlewares, getCacheType, getDeepResolvingFields, getFieldOptions, getGraphQLType, getMemoizationMap, getOperationOptions, getResolvingFields, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseResolvingFields, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|