@gqloom/core 0.11.1 → 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/{context-BtR7FTYT.js → context-BxqO4Eg9.js} +2 -1
- package/dist/{context-CnY_BFnk.cjs → context-DshDoxiE.cjs} +7 -0
- 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-t3pO8DK2.d.ts → index-B1bRSxSg.d.cts} +14 -12
- package/dist/{index-DXUAbzqx.d.cts → index-_VhWbhmU.d.ts} +12 -14
- package/dist/index.cjs +44 -26
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -27
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { Kind, isInterfaceType, isListType, isNonNullType, isObjectType } from "
|
|
|
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
|
|
@@ -298,4 +299,4 @@ function assignContextMap(target) {
|
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
//#endregion
|
|
301
|
-
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 };
|
|
@@ -34,6 +34,7 @@ graphql = __toESM(graphql);
|
|
|
34
34
|
|
|
35
35
|
//#region src/utils/constants.ts
|
|
36
36
|
const DERIVED_DEPENDENCIES = "loom.derived-from-dependencies";
|
|
37
|
+
const AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
37
38
|
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region src/utils/type.ts
|
|
@@ -329,6 +330,12 @@ function assignContextMap(target) {
|
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
//#endregion
|
|
333
|
+
Object.defineProperty(exports, 'AUTO_ALIASING', {
|
|
334
|
+
enumerable: true,
|
|
335
|
+
get: function () {
|
|
336
|
+
return AUTO_ALIASING;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
332
339
|
Object.defineProperty(exports, 'DERIVED_DEPENDENCIES', {
|
|
333
340
|
enumerable: true,
|
|
334
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
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldExtensions, GraphQLFieldMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLNullableType, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema, GraphQLSchemaConfig, GraphQLType, GraphQLUnionType } from "graphql";
|
|
2
2
|
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
//#endregion
|
|
3
5
|
//#region src/utils/types.d.ts
|
|
4
6
|
type MayPromise<T> = T | Promise<T>;
|
|
5
7
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
@@ -1059,6 +1061,10 @@ interface ContextMemoryContainer {
|
|
|
1059
1061
|
}
|
|
1060
1062
|
declare function assignContextMap(target: ContextMemoryContainer): WeakMap<WeakKey, any>;
|
|
1061
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
|
|
1062
1068
|
//#region src/schema/schema-weaver.d.ts
|
|
1063
1069
|
interface SchemaWeaver {
|
|
1064
1070
|
vendor: string;
|
|
@@ -1081,6 +1087,7 @@ interface WeaverContext {
|
|
|
1081
1087
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1082
1088
|
getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
|
|
1083
1089
|
names: WeakMap<object, string>;
|
|
1090
|
+
autoAliasTypes: WeakSet<GraphQLNamedType>;
|
|
1084
1091
|
vendorWeavers: Map<string, SchemaWeaver>;
|
|
1085
1092
|
}
|
|
1086
1093
|
interface WeaverConfig {
|
|
@@ -1091,7 +1098,7 @@ declare function initWeaverContext(): WeaverContext;
|
|
|
1091
1098
|
declare namespace initWeaverContext {
|
|
1092
1099
|
var increasingID: number;
|
|
1093
1100
|
}
|
|
1094
|
-
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType";
|
|
1101
|
+
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType" | "autoAliasTypes";
|
|
1095
1102
|
interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
|
|
1096
1103
|
value?: WeaverContext;
|
|
1097
1104
|
useConfig<TConfig extends WeaverConfig, TCallback extends () => any>(config: TConfig, callback: TCallback): ReturnType<TCallback>;
|
|
@@ -1123,7 +1130,6 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
1123
1130
|
declare class LoomObjectType extends GraphQLObjectType {
|
|
1124
1131
|
protected extraFields: Map<string, BaseField>;
|
|
1125
1132
|
protected hiddenFields: Set<string>;
|
|
1126
|
-
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
1127
1133
|
protected weaverContext: WeaverContext;
|
|
1128
1134
|
protected globalOptions?: ResolverOptions;
|
|
1129
1135
|
/**
|
|
@@ -1134,11 +1140,7 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
1134
1140
|
weaverContext?: WeaverContext;
|
|
1135
1141
|
globalOptions?: ResolverOptions;
|
|
1136
1142
|
});
|
|
1137
|
-
|
|
1138
|
-
protected _aliases: string[];
|
|
1139
|
-
get aliases(): string[];
|
|
1140
|
-
addAlias(name: string): void;
|
|
1141
|
-
protected renameByAliases(): void;
|
|
1143
|
+
addAlias(alias?: string): void;
|
|
1142
1144
|
hideField(name: string): void;
|
|
1143
1145
|
addField(name: string, field: BaseField, resolver: Resolver | undefined): void;
|
|
1144
1146
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
@@ -1225,11 +1227,11 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
|
1225
1227
|
//#endregion
|
|
1226
1228
|
//#region src/schema/input.d.ts
|
|
1227
1229
|
interface EnsureInputOptions {
|
|
1228
|
-
fieldName
|
|
1230
|
+
fieldName: string;
|
|
1229
1231
|
}
|
|
1230
|
-
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions
|
|
1231
|
-
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions
|
|
1232
|
-
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;
|
|
1233
1235
|
//#endregion
|
|
1234
1236
|
//#region src/schema/interface.d.ts
|
|
1235
1237
|
declare function ensureInterfaceType(gqlType: GraphQLOutputType, interfaceConfig?: Partial<GraphQLInterfaceTypeConfig<any, any>>): GraphQLInterfaceType;
|
|
@@ -1249,4 +1251,4 @@ interface GQLoomExtensionAttribute {
|
|
|
1249
1251
|
directives?: string[];
|
|
1250
1252
|
}
|
|
1251
1253
|
//#endregion
|
|
1252
|
-
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 };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldExtensions, GraphQLFieldMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLNullableType, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLOutputType, GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema, GraphQLSchemaConfig, GraphQLType, GraphQLUnionType } from "graphql";
|
|
2
2
|
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
//#endregion
|
|
5
3
|
//#region src/utils/types.d.ts
|
|
6
4
|
type MayPromise<T> = T | Promise<T>;
|
|
7
5
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
@@ -1061,6 +1059,10 @@ interface ContextMemoryContainer {
|
|
|
1061
1059
|
}
|
|
1062
1060
|
declare function assignContextMap(target: ContextMemoryContainer): WeakMap<WeakKey, any>;
|
|
1063
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
|
|
1064
1066
|
//#region src/schema/schema-weaver.d.ts
|
|
1065
1067
|
interface SchemaWeaver {
|
|
1066
1068
|
vendor: string;
|
|
@@ -1083,6 +1085,7 @@ interface WeaverContext {
|
|
|
1083
1085
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1084
1086
|
getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
|
|
1085
1087
|
names: WeakMap<object, string>;
|
|
1088
|
+
autoAliasTypes: WeakSet<GraphQLNamedType>;
|
|
1086
1089
|
vendorWeavers: Map<string, SchemaWeaver>;
|
|
1087
1090
|
}
|
|
1088
1091
|
interface WeaverConfig {
|
|
@@ -1093,7 +1096,7 @@ declare function initWeaverContext(): WeaverContext;
|
|
|
1093
1096
|
declare namespace initWeaverContext {
|
|
1094
1097
|
var increasingID: number;
|
|
1095
1098
|
}
|
|
1096
|
-
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType";
|
|
1099
|
+
type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType" | "autoAliasTypes";
|
|
1097
1100
|
interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
|
|
1098
1101
|
value?: WeaverContext;
|
|
1099
1102
|
useConfig<TConfig extends WeaverConfig, TCallback extends () => any>(config: TConfig, callback: TCallback): ReturnType<TCallback>;
|
|
@@ -1125,7 +1128,6 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
1125
1128
|
declare class LoomObjectType extends GraphQLObjectType {
|
|
1126
1129
|
protected extraFields: Map<string, BaseField>;
|
|
1127
1130
|
protected hiddenFields: Set<string>;
|
|
1128
|
-
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
1129
1131
|
protected weaverContext: WeaverContext;
|
|
1130
1132
|
protected globalOptions?: ResolverOptions;
|
|
1131
1133
|
/**
|
|
@@ -1136,11 +1138,7 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
1136
1138
|
weaverContext?: WeaverContext;
|
|
1137
1139
|
globalOptions?: ResolverOptions;
|
|
1138
1140
|
});
|
|
1139
|
-
|
|
1140
|
-
protected _aliases: string[];
|
|
1141
|
-
get aliases(): string[];
|
|
1142
|
-
addAlias(name: string): void;
|
|
1143
|
-
protected renameByAliases(): void;
|
|
1141
|
+
addAlias(alias?: string): void;
|
|
1144
1142
|
hideField(name: string): void;
|
|
1145
1143
|
addField(name: string, field: BaseField, resolver: Resolver | undefined): void;
|
|
1146
1144
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
@@ -1227,11 +1225,11 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
|
1227
1225
|
//#endregion
|
|
1228
1226
|
//#region src/schema/input.d.ts
|
|
1229
1227
|
interface EnsureInputOptions {
|
|
1230
|
-
fieldName
|
|
1228
|
+
fieldName: string;
|
|
1231
1229
|
}
|
|
1232
|
-
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions
|
|
1233
|
-
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions
|
|
1234
|
-
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;
|
|
1235
1233
|
//#endregion
|
|
1236
1234
|
//#region src/schema/interface.d.ts
|
|
1237
1235
|
declare function ensureInterfaceType(gqlType: GraphQLOutputType, interfaceConfig?: Partial<GraphQLInterfaceTypeConfig<any, any>>): GraphQLInterfaceType;
|
|
@@ -1251,4 +1249,4 @@ interface GQLoomExtensionAttribute {
|
|
|
1251
1249
|
directives?: string[];
|
|
1252
1250
|
}
|
|
1253
1251
|
//#endregion
|
|
1254
|
-
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
|
|
|
@@ -242,6 +242,7 @@ var EasyDataLoader = class extends LoomDataLoader {
|
|
|
242
242
|
//#region src/schema/weaver-context.ts
|
|
243
243
|
let ref;
|
|
244
244
|
const names = /* @__PURE__ */ new WeakMap();
|
|
245
|
+
const autoAliasTypes = /* @__PURE__ */ new WeakSet();
|
|
245
246
|
function initWeaverContext() {
|
|
246
247
|
return {
|
|
247
248
|
id: initWeaverContext.increasingID++,
|
|
@@ -261,6 +262,7 @@ function initWeaverContext() {
|
|
|
261
262
|
this.configs.delete(key);
|
|
262
263
|
},
|
|
263
264
|
names,
|
|
265
|
+
autoAliasTypes,
|
|
264
266
|
namedTypes: /* @__PURE__ */ new Map(),
|
|
265
267
|
memoNamedType(gqlTypeValue) {
|
|
266
268
|
const gqlType = gqlTypeValue;
|
|
@@ -316,6 +318,7 @@ const weaverContext = {
|
|
|
316
318
|
return result;
|
|
317
319
|
},
|
|
318
320
|
names,
|
|
321
|
+
autoAliasTypes,
|
|
319
322
|
getNamedType(name) {
|
|
320
323
|
return ref?.getNamedType(name);
|
|
321
324
|
},
|
|
@@ -1203,6 +1206,15 @@ var ObjectChainResolver = class extends ChainResolver {
|
|
|
1203
1206
|
}
|
|
1204
1207
|
};
|
|
1205
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
|
+
|
|
1206
1218
|
//#endregion
|
|
1207
1219
|
//#region src/schema/input.ts
|
|
1208
1220
|
function inputToArgs(input, options) {
|
|
@@ -1211,8 +1223,7 @@ function inputToArgs(input, options) {
|
|
|
1211
1223
|
let inputType = getGraphQLType(input);
|
|
1212
1224
|
if ((0, graphql.isNonNullType)(inputType)) inputType = inputType.ofType;
|
|
1213
1225
|
if ((0, graphql.isObjectType)(inputType)) return mapValue(inputType.toConfig().fields, (it, key) => {
|
|
1214
|
-
|
|
1215
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1226
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1216
1227
|
return toInputFieldConfig(it, { fieldName });
|
|
1217
1228
|
});
|
|
1218
1229
|
throw new Error(`Cannot convert ${inputType.toString()} to input type`);
|
|
@@ -1220,8 +1231,7 @@ function inputToArgs(input, options) {
|
|
|
1220
1231
|
const args = {};
|
|
1221
1232
|
Object.entries(input).forEach(([name, field$1]) => {
|
|
1222
1233
|
tryIn(() => {
|
|
1223
|
-
|
|
1224
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1234
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1225
1235
|
args[name] = {
|
|
1226
1236
|
...field$1,
|
|
1227
1237
|
type: ensureInputType(field$1, { fieldName })
|
|
@@ -1239,6 +1249,13 @@ function ensureInputType(silkOrType, options) {
|
|
|
1239
1249
|
if ((0, graphql.isNonNullType)(gqlType)) return new graphql.GraphQLNonNull(ensureInputType(gqlType.ofType, options));
|
|
1240
1250
|
if ((0, graphql.isListType)(gqlType)) return new graphql.GraphQLList(ensureInputType(gqlType.ofType, options));
|
|
1241
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
|
+
}
|
|
1242
1259
|
return gqlType;
|
|
1243
1260
|
}
|
|
1244
1261
|
function ensureInputObjectType(object, options) {
|
|
@@ -1247,7 +1264,7 @@ function ensureInputObjectType(object, options) {
|
|
|
1247
1264
|
if (existing != null) return existing;
|
|
1248
1265
|
const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
|
|
1249
1266
|
let name = object.name;
|
|
1250
|
-
if (name ===
|
|
1267
|
+
if (name === require_context.AUTO_ALIASING) name = `${pascalCase(options.fieldName)}Input`;
|
|
1251
1268
|
name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
|
|
1252
1269
|
const input = new graphql.GraphQLInputObjectType({
|
|
1253
1270
|
...config,
|
|
@@ -1270,10 +1287,9 @@ function inputFieldName(name) {
|
|
|
1270
1287
|
|
|
1271
1288
|
//#endregion
|
|
1272
1289
|
//#region src/schema/object.ts
|
|
1273
|
-
var LoomObjectType = class
|
|
1290
|
+
var LoomObjectType = class extends graphql.GraphQLObjectType {
|
|
1274
1291
|
extraFields = /* @__PURE__ */ new Map();
|
|
1275
1292
|
hiddenFields = /* @__PURE__ */ new Set();
|
|
1276
|
-
static AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1277
1293
|
weaverContext;
|
|
1278
1294
|
globalOptions;
|
|
1279
1295
|
/**
|
|
@@ -1294,22 +1310,11 @@ var LoomObjectType = class LoomObjectType extends graphql.GraphQLObjectType {
|
|
|
1294
1310
|
this.globalOptions = options.globalOptions;
|
|
1295
1311
|
this.weaverContext = options.weaverContext ?? initWeaverContext();
|
|
1296
1312
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
1297
|
-
if (this.name
|
|
1313
|
+
if (this.name === require_context.AUTO_ALIASING) this.weaverContext.autoAliasTypes.add(this);
|
|
1298
1314
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
return this._aliases;
|
|
1303
|
-
}
|
|
1304
|
-
addAlias(name) {
|
|
1305
|
-
if (this.hasExplicitName) return;
|
|
1306
|
-
this._aliases.push(name);
|
|
1307
|
-
this.renameByAliases();
|
|
1308
|
-
}
|
|
1309
|
-
renameByAliases() {
|
|
1310
|
-
let name;
|
|
1311
|
-
for (const alias of this.aliases) if (name === void 0 || alias.length < name.length) name = alias;
|
|
1312
|
-
if (name) this.name = name;
|
|
1315
|
+
addAlias(alias) {
|
|
1316
|
+
if (!this.weaverContext.autoAliasTypes.has(this) || !alias) return;
|
|
1317
|
+
this.name = alias.length < this.name.length ? alias : this.name;
|
|
1313
1318
|
}
|
|
1314
1319
|
hideField(name) {
|
|
1315
1320
|
this.hiddenFields.add(name);
|
|
@@ -1348,7 +1353,7 @@ var LoomObjectType = class LoomObjectType extends graphql.GraphQLObjectType {
|
|
|
1348
1353
|
return {
|
|
1349
1354
|
...extract(field$1),
|
|
1350
1355
|
type: outputType,
|
|
1351
|
-
args: inputToArgs(field$1["~meta"].input, { fieldName:
|
|
1356
|
+
args: inputToArgs(field$1["~meta"].input, { fieldName: parentName(this.name) + fieldName }),
|
|
1352
1357
|
resolve,
|
|
1353
1358
|
...subscribe ? { subscribe } : {}
|
|
1354
1359
|
};
|
|
@@ -1500,13 +1505,17 @@ const OPERATION_OBJECT_NAMES = new Set([
|
|
|
1500
1505
|
]);
|
|
1501
1506
|
function getCacheType(gqlType, options = {}) {
|
|
1502
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
|
+
};
|
|
1503
1512
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1504
1513
|
if ((0, graphql.isObjectType)(gqlType)) {
|
|
1505
1514
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1506
1515
|
if (gqlObject != null) return gqlObject;
|
|
1507
1516
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1508
1517
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1509
|
-
|
|
1518
|
+
setAlias(loomObject, getAlias(), context);
|
|
1510
1519
|
return loomObject;
|
|
1511
1520
|
} else if ((0, graphql.isListType)(gqlType)) return new graphql.GraphQLList(getCacheType(gqlType.ofType, options));
|
|
1512
1521
|
else if ((0, graphql.isNonNullType)(gqlType)) return new graphql.GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
@@ -1516,10 +1525,17 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1516
1525
|
const config = gqlType.toConfig();
|
|
1517
1526
|
const unionType = new graphql.GraphQLUnionType({
|
|
1518
1527
|
...config,
|
|
1519
|
-
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
|
+
}))
|
|
1520
1532
|
});
|
|
1521
1533
|
context.loomUnionMap?.set(gqlType, unionType);
|
|
1534
|
+
setAlias(unionType, getAlias(), context);
|
|
1522
1535
|
return unionType;
|
|
1536
|
+
} else if ((0, graphql.isEnumType)(gqlType)) {
|
|
1537
|
+
setAlias(gqlType, getAlias(), context);
|
|
1538
|
+
return gqlType;
|
|
1523
1539
|
}
|
|
1524
1540
|
return gqlType;
|
|
1525
1541
|
}
|
|
@@ -1741,8 +1757,10 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1741
1757
|
}
|
|
1742
1758
|
|
|
1743
1759
|
//#endregion
|
|
1760
|
+
exports.AUTO_ALIASING = require_context.AUTO_ALIASING;
|
|
1744
1761
|
exports.BaseChainFactory = BaseChainFactory;
|
|
1745
1762
|
exports.ChainResolver = ChainResolver;
|
|
1763
|
+
exports.DERIVED_DEPENDENCIES = require_context.DERIVED_DEPENDENCIES;
|
|
1746
1764
|
exports.EasyDataLoader = EasyDataLoader;
|
|
1747
1765
|
exports.FieldChainFactory = FieldChainFactory;
|
|
1748
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
|
|
@@ -241,6 +241,7 @@ var EasyDataLoader = class extends LoomDataLoader {
|
|
|
241
241
|
//#region src/schema/weaver-context.ts
|
|
242
242
|
let ref;
|
|
243
243
|
const names = /* @__PURE__ */ new WeakMap();
|
|
244
|
+
const autoAliasTypes = /* @__PURE__ */ new WeakSet();
|
|
244
245
|
function initWeaverContext() {
|
|
245
246
|
return {
|
|
246
247
|
id: initWeaverContext.increasingID++,
|
|
@@ -260,6 +261,7 @@ function initWeaverContext() {
|
|
|
260
261
|
this.configs.delete(key);
|
|
261
262
|
},
|
|
262
263
|
names,
|
|
264
|
+
autoAliasTypes,
|
|
263
265
|
namedTypes: /* @__PURE__ */ new Map(),
|
|
264
266
|
memoNamedType(gqlTypeValue) {
|
|
265
267
|
const gqlType = gqlTypeValue;
|
|
@@ -315,6 +317,7 @@ const weaverContext = {
|
|
|
315
317
|
return result;
|
|
316
318
|
},
|
|
317
319
|
names,
|
|
320
|
+
autoAliasTypes,
|
|
318
321
|
getNamedType(name) {
|
|
319
322
|
return ref?.getNamedType(name);
|
|
320
323
|
},
|
|
@@ -1202,6 +1205,15 @@ var ObjectChainResolver = class extends ChainResolver {
|
|
|
1202
1205
|
}
|
|
1203
1206
|
};
|
|
1204
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
|
+
|
|
1205
1217
|
//#endregion
|
|
1206
1218
|
//#region src/schema/input.ts
|
|
1207
1219
|
function inputToArgs(input, options) {
|
|
@@ -1210,8 +1222,7 @@ function inputToArgs(input, options) {
|
|
|
1210
1222
|
let inputType = getGraphQLType(input);
|
|
1211
1223
|
if (isNonNullType(inputType)) inputType = inputType.ofType;
|
|
1212
1224
|
if (isObjectType(inputType)) return mapValue(inputType.toConfig().fields, (it, key) => {
|
|
1213
|
-
|
|
1214
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1225
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
|
|
1215
1226
|
return toInputFieldConfig(it, { fieldName });
|
|
1216
1227
|
});
|
|
1217
1228
|
throw new Error(`Cannot convert ${inputType.toString()} to input type`);
|
|
@@ -1219,8 +1230,7 @@ function inputToArgs(input, options) {
|
|
|
1219
1230
|
const args = {};
|
|
1220
1231
|
Object.entries(input).forEach(([name, field$1]) => {
|
|
1221
1232
|
tryIn(() => {
|
|
1222
|
-
|
|
1223
|
-
if (options?.fieldName) fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1233
|
+
const fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
|
|
1224
1234
|
args[name] = {
|
|
1225
1235
|
...field$1,
|
|
1226
1236
|
type: ensureInputType(field$1, { fieldName })
|
|
@@ -1238,6 +1248,13 @@ function ensureInputType(silkOrType, options) {
|
|
|
1238
1248
|
if (isNonNullType(gqlType)) return new GraphQLNonNull(ensureInputType(gqlType.ofType, options));
|
|
1239
1249
|
if (isListType(gqlType)) return new GraphQLList(ensureInputType(gqlType.ofType, options));
|
|
1240
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
|
+
}
|
|
1241
1258
|
return gqlType;
|
|
1242
1259
|
}
|
|
1243
1260
|
function ensureInputObjectType(object, options) {
|
|
@@ -1246,7 +1263,7 @@ function ensureInputObjectType(object, options) {
|
|
|
1246
1263
|
if (existing != null) return existing;
|
|
1247
1264
|
const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
|
|
1248
1265
|
let name = object.name;
|
|
1249
|
-
if (name ===
|
|
1266
|
+
if (name === AUTO_ALIASING) name = `${pascalCase(options.fieldName)}Input`;
|
|
1250
1267
|
name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
|
|
1251
1268
|
const input = new GraphQLInputObjectType({
|
|
1252
1269
|
...config,
|
|
@@ -1269,10 +1286,9 @@ function inputFieldName(name) {
|
|
|
1269
1286
|
|
|
1270
1287
|
//#endregion
|
|
1271
1288
|
//#region src/schema/object.ts
|
|
1272
|
-
var LoomObjectType = class
|
|
1289
|
+
var LoomObjectType = class extends GraphQLObjectType {
|
|
1273
1290
|
extraFields = /* @__PURE__ */ new Map();
|
|
1274
1291
|
hiddenFields = /* @__PURE__ */ new Set();
|
|
1275
|
-
static AUTO_ALIASING = "__gqloom_auto_aliasing";
|
|
1276
1292
|
weaverContext;
|
|
1277
1293
|
globalOptions;
|
|
1278
1294
|
/**
|
|
@@ -1293,22 +1309,11 @@ var LoomObjectType = class LoomObjectType extends GraphQLObjectType {
|
|
|
1293
1309
|
this.globalOptions = options.globalOptions;
|
|
1294
1310
|
this.weaverContext = options.weaverContext ?? initWeaverContext();
|
|
1295
1311
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
1296
|
-
if (this.name
|
|
1312
|
+
if (this.name === AUTO_ALIASING) this.weaverContext.autoAliasTypes.add(this);
|
|
1297
1313
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
return this._aliases;
|
|
1302
|
-
}
|
|
1303
|
-
addAlias(name) {
|
|
1304
|
-
if (this.hasExplicitName) return;
|
|
1305
|
-
this._aliases.push(name);
|
|
1306
|
-
this.renameByAliases();
|
|
1307
|
-
}
|
|
1308
|
-
renameByAliases() {
|
|
1309
|
-
let name;
|
|
1310
|
-
for (const alias of this.aliases) if (name === void 0 || alias.length < name.length) name = alias;
|
|
1311
|
-
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;
|
|
1312
1317
|
}
|
|
1313
1318
|
hideField(name) {
|
|
1314
1319
|
this.hiddenFields.add(name);
|
|
@@ -1347,7 +1352,7 @@ var LoomObjectType = class LoomObjectType extends GraphQLObjectType {
|
|
|
1347
1352
|
return {
|
|
1348
1353
|
...extract(field$1),
|
|
1349
1354
|
type: outputType,
|
|
1350
|
-
args: inputToArgs(field$1["~meta"].input, { fieldName:
|
|
1355
|
+
args: inputToArgs(field$1["~meta"].input, { fieldName: parentName(this.name) + fieldName }),
|
|
1351
1356
|
resolve,
|
|
1352
1357
|
...subscribe ? { subscribe } : {}
|
|
1353
1358
|
};
|
|
@@ -1499,13 +1504,17 @@ const OPERATION_OBJECT_NAMES = new Set([
|
|
|
1499
1504
|
]);
|
|
1500
1505
|
function getCacheType(gqlType, options = {}) {
|
|
1501
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
|
+
};
|
|
1502
1511
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1503
1512
|
if (isObjectType(gqlType)) {
|
|
1504
1513
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1505
1514
|
if (gqlObject != null) return gqlObject;
|
|
1506
1515
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1507
1516
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1508
|
-
|
|
1517
|
+
setAlias(loomObject, getAlias(), context);
|
|
1509
1518
|
return loomObject;
|
|
1510
1519
|
} else if (isListType(gqlType)) return new GraphQLList(getCacheType(gqlType.ofType, options));
|
|
1511
1520
|
else if (isNonNullType(gqlType)) return new GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
@@ -1515,10 +1524,17 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1515
1524
|
const config = gqlType.toConfig();
|
|
1516
1525
|
const unionType = new GraphQLUnionType({
|
|
1517
1526
|
...config,
|
|
1518
|
-
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
|
+
}))
|
|
1519
1531
|
});
|
|
1520
1532
|
context.loomUnionMap?.set(gqlType, unionType);
|
|
1533
|
+
setAlias(unionType, getAlias(), context);
|
|
1521
1534
|
return unionType;
|
|
1535
|
+
} else if (isEnumType(gqlType)) {
|
|
1536
|
+
setAlias(gqlType, getAlias(), context);
|
|
1537
|
+
return gqlType;
|
|
1522
1538
|
}
|
|
1523
1539
|
return gqlType;
|
|
1524
1540
|
}
|
|
@@ -1740,4 +1756,4 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
|
|
|
1740
1756
|
}
|
|
1741
1757
|
|
|
1742
1758
|
//#endregion
|
|
1743
|
-
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 };
|