@gqloom/core 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/{index-C26E_cfW.d.cts → index-DPuy3FIT.d.cts} +7 -2
- package/dist/{index-BdLdDytD.d.ts → index-DyGHE5li.d.ts} +7 -2
- package/dist/index.cjs +63 -24
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -24
- package/package.json +1 -1
package/dist/context.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rt as OnlyMemoizationPayload, _n as BaseField, bt as Middleware, fn as ResolverPayload, lt as ResolvingFields } from "./index-
|
|
1
|
+
import { Rt as OnlyMemoizationPayload, _n as BaseField, bt as Middleware, fn as ResolverPayload, lt as ResolvingFields } from "./index-DPuy3FIT.cjs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/context/async-iterator.d.ts
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rt as OnlyMemoizationPayload, _n as BaseField, bt as Middleware, fn as ResolverPayload, lt as ResolvingFields } from "./index-
|
|
1
|
+
import { Rt as OnlyMemoizationPayload, _n as BaseField, bt as Middleware, fn as ResolverPayload, lt as ResolvingFields } from "./index-DyGHE5li.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/context/async-iterator.d.ts
|
|
@@ -1156,11 +1156,16 @@ declare class WeaverContext {
|
|
|
1156
1156
|
readonly Scalar: "Scalar";
|
|
1157
1157
|
};
|
|
1158
1158
|
protected aliasCounters: Partial<Record<keyof typeof WeaverContext.namedTypes, number>>;
|
|
1159
|
-
|
|
1159
|
+
protected aliasMap: WeakMap<GraphQLNamedType, Set<string>>;
|
|
1160
|
+
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string;
|
|
1160
1161
|
/**
|
|
1161
1162
|
* @returns -1 if a is better than b, 1 if b is better than a, 0 if they are equal
|
|
1162
1163
|
*/
|
|
1163
1164
|
protected static higherPriorityThan(a: string | undefined, b: string | undefined): number;
|
|
1165
|
+
protected ensureAliasStore(namedType: GraphQLNamedType): Set<string>;
|
|
1166
|
+
protected pickAlias(namedType: GraphQLNamedType, aliases: Set<string>): string;
|
|
1167
|
+
protected reduceAliases(aliases: Iterable<string>): string | undefined;
|
|
1168
|
+
protected createFallbackAlias(namedType: GraphQLNamedType): string;
|
|
1164
1169
|
static provide<T$1>(func: () => T$1, value: WeaverContext | undefined): T$1;
|
|
1165
1170
|
}
|
|
1166
1171
|
declare const initWeaverContext: () => WeaverContext;
|
|
@@ -1192,7 +1197,7 @@ declare class GlobalWeaverContext implements Partial<Omit<WeaverContext, GlobalC
|
|
|
1192
1197
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1193
1198
|
getGraphQLType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(origin: object): TGraphQLType | undefined;
|
|
1194
1199
|
memoGraphQLType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(origin: object, gqlType: TGraphQLType): TGraphQLType;
|
|
1195
|
-
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string
|
|
1200
|
+
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string;
|
|
1196
1201
|
}
|
|
1197
1202
|
declare const weaverContext: GlobalWeaverContext;
|
|
1198
1203
|
/**
|
|
@@ -1154,11 +1154,16 @@ declare class WeaverContext {
|
|
|
1154
1154
|
readonly Scalar: "Scalar";
|
|
1155
1155
|
};
|
|
1156
1156
|
protected aliasCounters: Partial<Record<keyof typeof WeaverContext.namedTypes, number>>;
|
|
1157
|
-
|
|
1157
|
+
protected aliasMap: WeakMap<GraphQLNamedType, Set<string>>;
|
|
1158
|
+
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string;
|
|
1158
1159
|
/**
|
|
1159
1160
|
* @returns -1 if a is better than b, 1 if b is better than a, 0 if they are equal
|
|
1160
1161
|
*/
|
|
1161
1162
|
protected static higherPriorityThan(a: string | undefined, b: string | undefined): number;
|
|
1163
|
+
protected ensureAliasStore(namedType: GraphQLNamedType): Set<string>;
|
|
1164
|
+
protected pickAlias(namedType: GraphQLNamedType, aliases: Set<string>): string;
|
|
1165
|
+
protected reduceAliases(aliases: Iterable<string>): string | undefined;
|
|
1166
|
+
protected createFallbackAlias(namedType: GraphQLNamedType): string;
|
|
1162
1167
|
static provide<T$1>(func: () => T$1, value: WeaverContext | undefined): T$1;
|
|
1163
1168
|
}
|
|
1164
1169
|
declare const initWeaverContext: () => WeaverContext;
|
|
@@ -1190,7 +1195,7 @@ declare class GlobalWeaverContext implements Partial<Omit<WeaverContext, GlobalC
|
|
|
1190
1195
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
1191
1196
|
getGraphQLType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(origin: object): TGraphQLType | undefined;
|
|
1192
1197
|
memoGraphQLType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(origin: object, gqlType: TGraphQLType): TGraphQLType;
|
|
1193
|
-
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string
|
|
1198
|
+
setAlias(namedType: GraphQLNamedType, alias: string | undefined): string;
|
|
1194
1199
|
}
|
|
1195
1200
|
declare const weaverContext: GlobalWeaverContext;
|
|
1196
1201
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -55,30 +55,13 @@ var WeaverContext = class WeaverContext {
|
|
|
55
55
|
Scalar: "Scalar"
|
|
56
56
|
};
|
|
57
57
|
aliasCounters = {};
|
|
58
|
+
aliasMap = /* @__PURE__ */ new WeakMap();
|
|
58
59
|
setAlias(namedType, alias) {
|
|
59
60
|
if (namedType.name === require_parse_resolving_fields.AUTO_ALIASING) WeaverContext.autoAliasTypes.add(namedType);
|
|
60
61
|
if (!WeaverContext.autoAliasTypes.has(namedType)) return namedType.name;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (namedType.name === require_parse_resolving_fields.AUTO_ALIASING) {
|
|
65
|
-
if ((0, graphql.isObjectType)(namedType) || (0, graphql.isInputObjectType)(namedType)) {
|
|
66
|
-
this.aliasCounters["Object"] ??= 0;
|
|
67
|
-
return namedType.name = `Object${++this.aliasCounters["Object"]}`;
|
|
68
|
-
} else if ((0, graphql.isUnionType)(namedType)) {
|
|
69
|
-
this.aliasCounters["Union"] ??= 0;
|
|
70
|
-
return namedType.name = `Union${++this.aliasCounters["Union"]}`;
|
|
71
|
-
} else if ((0, graphql.isEnumType)(namedType)) {
|
|
72
|
-
this.aliasCounters["Enum"] ??= 0;
|
|
73
|
-
return namedType.name = `Enum${++this.aliasCounters["Enum"]}`;
|
|
74
|
-
} else if ((0, graphql.isInterfaceType)(namedType)) {
|
|
75
|
-
this.aliasCounters["Interface"] ??= 0;
|
|
76
|
-
return namedType.name = `Interface${++this.aliasCounters["Interface"]}`;
|
|
77
|
-
} else if ((0, graphql.isScalarType)(namedType)) {
|
|
78
|
-
this.aliasCounters["Scalar"] ??= 0;
|
|
79
|
-
return namedType.name = `Scalar${++this.aliasCounters["Scalar"]}`;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
62
|
+
const aliases = this.ensureAliasStore(namedType);
|
|
63
|
+
if (alias) aliases.add(alias);
|
|
64
|
+
return this.pickAlias(namedType, aliases);
|
|
82
65
|
}
|
|
83
66
|
/**
|
|
84
67
|
* @returns -1 if a is better than b, 1 if b is better than a, 0 if they are equal
|
|
@@ -92,6 +75,56 @@ var WeaverContext = class WeaverContext {
|
|
|
92
75
|
if (compareLocale !== 0) return compareLocale;
|
|
93
76
|
return 0;
|
|
94
77
|
}
|
|
78
|
+
ensureAliasStore(namedType) {
|
|
79
|
+
const existing = this.aliasMap.get(namedType);
|
|
80
|
+
if (existing) return existing;
|
|
81
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
82
|
+
this.aliasMap.set(namedType, aliases);
|
|
83
|
+
Object.defineProperty(namedType, "name", {
|
|
84
|
+
get: () => this.pickAlias(namedType, aliases),
|
|
85
|
+
set: (value) => {
|
|
86
|
+
aliases.add(value);
|
|
87
|
+
},
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
return aliases;
|
|
92
|
+
}
|
|
93
|
+
pickAlias(namedType, aliases) {
|
|
94
|
+
const best = this.reduceAliases(aliases);
|
|
95
|
+
if (best && best !== require_parse_resolving_fields.AUTO_ALIASING) return best;
|
|
96
|
+
const fallback = this.createFallbackAlias(namedType);
|
|
97
|
+
aliases.add(fallback);
|
|
98
|
+
return this.reduceAliases(aliases) ?? fallback;
|
|
99
|
+
}
|
|
100
|
+
reduceAliases(aliases) {
|
|
101
|
+
let best;
|
|
102
|
+
for (const alias of aliases) if (best === void 0 || WeaverContext.higherPriorityThan(alias, best) < 0) best = alias;
|
|
103
|
+
return best;
|
|
104
|
+
}
|
|
105
|
+
createFallbackAlias(namedType) {
|
|
106
|
+
if ((0, graphql.isObjectType)(namedType) || (0, graphql.isInputObjectType)(namedType)) {
|
|
107
|
+
this.aliasCounters["Object"] ??= 0;
|
|
108
|
+
return `Object${++this.aliasCounters["Object"]}`;
|
|
109
|
+
}
|
|
110
|
+
if ((0, graphql.isUnionType)(namedType)) {
|
|
111
|
+
this.aliasCounters["Union"] ??= 0;
|
|
112
|
+
return `Union${++this.aliasCounters["Union"]}`;
|
|
113
|
+
}
|
|
114
|
+
if ((0, graphql.isEnumType)(namedType)) {
|
|
115
|
+
this.aliasCounters["Enum"] ??= 0;
|
|
116
|
+
return `Enum${++this.aliasCounters["Enum"]}`;
|
|
117
|
+
}
|
|
118
|
+
if ((0, graphql.isInterfaceType)(namedType)) {
|
|
119
|
+
this.aliasCounters["Interface"] ??= 0;
|
|
120
|
+
return `Interface${++this.aliasCounters["Interface"]}`;
|
|
121
|
+
}
|
|
122
|
+
if ((0, graphql.isScalarType)(namedType)) {
|
|
123
|
+
this.aliasCounters["Scalar"] ??= 0;
|
|
124
|
+
return `Scalar${++this.aliasCounters["Scalar"]}`;
|
|
125
|
+
}
|
|
126
|
+
return namedType.name;
|
|
127
|
+
}
|
|
95
128
|
static provide(func, value) {
|
|
96
129
|
const lastRef = WeaverContext._ref;
|
|
97
130
|
WeaverContext._ref = value;
|
|
@@ -169,7 +202,7 @@ var GlobalWeaverContext = class {
|
|
|
169
202
|
return gqlType;
|
|
170
203
|
}
|
|
171
204
|
setAlias(namedType, alias) {
|
|
172
|
-
return WeaverContext.ref?.setAlias(namedType, alias);
|
|
205
|
+
return WeaverContext.ref?.setAlias(namedType, alias) ?? namedType.name;
|
|
173
206
|
}
|
|
174
207
|
};
|
|
175
208
|
const weaverContext = new GlobalWeaverContext();
|
|
@@ -1581,7 +1614,10 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1581
1614
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1582
1615
|
if ((0, graphql.isObjectType)(gqlType)) {
|
|
1583
1616
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1584
|
-
if (gqlObject != null)
|
|
1617
|
+
if (gqlObject != null) {
|
|
1618
|
+
context.setAlias(gqlObject, getAlias());
|
|
1619
|
+
return gqlObject;
|
|
1620
|
+
}
|
|
1585
1621
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1586
1622
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1587
1623
|
context.setAlias(loomObject, getAlias());
|
|
@@ -1590,7 +1626,10 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1590
1626
|
else if ((0, graphql.isNonNullType)(gqlType)) return new graphql.GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
1591
1627
|
else if ((0, graphql.isUnionType)(gqlType)) {
|
|
1592
1628
|
const existing = context.loomUnionMap?.get(gqlType);
|
|
1593
|
-
if (existing != null)
|
|
1629
|
+
if (existing != null) {
|
|
1630
|
+
context.setAlias(existing, getAlias());
|
|
1631
|
+
return existing;
|
|
1632
|
+
}
|
|
1594
1633
|
const config = gqlType.toConfig();
|
|
1595
1634
|
const unionType = new graphql.GraphQLUnionType({
|
|
1596
1635
|
...config,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as subscription, $t as GraphQLSilk, A as getGraphQLType, An as FieldFactoryWithResolve, At as RequireKeys, B as ResolverFactory, Bn as StandardSchemaV1, Bt as getMemoizationMap, C as DirectiveRecord, Cn as Query, Ct as MiddlewareOptions, D as NonNullSilk, Dn as BaseChainFactory, Dt as MayGetter, E as ListSilk, En as types_loom_d_exports, Et as IsAny, F as parseSilk, Fn as QueryFactoryWithResolve, Ft as markErrorLocation, G as createQuery, Gt as getFieldOptions, H as ToExecutorProps, Ht as onlyMemoization, I as silk, In as ResolvableSubscription, It as markLocation, J as field, Jt as FieldFactory, K as createSubscription, Kt as getOperationOptions, L as ChainResolver, Ln as SubscriptionChainFactory, Lt as tryIn, M as listSilk, Mn as MutationChainFactory, Mt as BatchLoadFn, N as nonNullSilk, Nn as MutationFactoryWithResolve, Nt as EasyDataLoader, O as NullableSilk, On as ChainFactoryOptions, Ot as MayPromise, P as nullableSilk, Pn as QueryChainFactory, Pt as LoomDataLoader, Q as resolver, Qt as GraphQLFieldOptions, R as Executor, Rn as SubscriptionNeedResolve, Rt as OnlyMemoizationPayload, S as DirectiveItem, Sn as Operation, St as MiddlewareOperation, T as GQLoomExtensions, Tn as Subscription, Tt as filterMiddlewares, U as createField, Ut as AUTO_ALIASING, V as ResolverMeta, Vt as isOnlyMemoryPayload, W as createMutation, Wt as DERIVED_DEPENDENCIES, X as mutation, Xt as FieldOptions, Y as loom, Yt as FieldFactoryWithUtils, Z as query, Zt as FieldOrOperationType, _ as isSchemaVendorWeaver, _n as BaseField, _t as notNullish, a as LoomObjectType, an as OperationType, at as parseInputValue, b as ensureInputType, bn as FieldOrOperation, bt as Middleware, c as GlobalWeaverContext, cn as QueryOptions, ct as screamingSnakeCase, d as collectName, dn as ResolverOptionsWithParent, dt as getDeepResolvingFields, en as InferFieldInput, et as CallableInputParser, f as collectNames, fn as ResolverPayload, ft as getResolvingFields, g as SchemaWeaver, gn as SubscriptionOptions, gt as meta, h as weaverContext, hn as SubscriptionFactoryWithChain, ht as mapValue, i as CoreSchemaWeaverConfigOptions, in as MutationOptions, it as getStandardValue, j as isSilk, jn as IChainFactory, jt as ValueOf, k as getGraphQLArgumentConfig, kn as FieldChainFactory, kt as OmitInUnion, l as WeaverConfig, ln as ResolverOptions, lt as ResolvingFields, m as provideWeaverContext, mn as SubscriptionFactory, mt as deepMerge, n as weave, nn as MutationFactory, nt as InferInputO, o as OPERATION_OBJECT_NAMES, on as QueryFactory, ot as capitalize, p as initWeaverContext, pn as ResolvingOptions, pt as parseResolvingFields, q as defaultSubscriptionResolve, qt as getSubscriptionOptions, r as CoreSchemaWeaverConfig, rn as MutationFactoryWithChain, rt as createInputParser, s as getCacheType, sn as QueryFactoryWithChain, st as pascalCase, t as GraphQLSchemaLoom, tn as InferFieldOutput, tt as InferInputI, u as WeaverContext, un as ResolverOptionsWithExtensions, ut as ResolvingFieldsOptions, v as ensureInterfaceType, vn as Field, vt as toObjMap, w as GQLoomExtensionAttribute, wn as Resolver, wt as applyMiddlewares, x as inputToArgs, xn as Mutation, xt as MiddlewareConfig, y as ensureInputObjectType, yn as FieldMeta, yt as CallableMiddlewareOptions, z as ObjectChainResolver, zn as symbols_d_exports, zt as assignContextMap } from "./index-
|
|
1
|
+
import { $ as subscription, $t as GraphQLSilk, A as getGraphQLType, An as FieldFactoryWithResolve, At as RequireKeys, B as ResolverFactory, Bn as StandardSchemaV1, Bt as getMemoizationMap, C as DirectiveRecord, Cn as Query, Ct as MiddlewareOptions, D as NonNullSilk, Dn as BaseChainFactory, Dt as MayGetter, E as ListSilk, En as types_loom_d_exports, Et as IsAny, F as parseSilk, Fn as QueryFactoryWithResolve, Ft as markErrorLocation, G as createQuery, Gt as getFieldOptions, H as ToExecutorProps, Ht as onlyMemoization, I as silk, In as ResolvableSubscription, It as markLocation, J as field, Jt as FieldFactory, K as createSubscription, Kt as getOperationOptions, L as ChainResolver, Ln as SubscriptionChainFactory, Lt as tryIn, M as listSilk, Mn as MutationChainFactory, Mt as BatchLoadFn, N as nonNullSilk, Nn as MutationFactoryWithResolve, Nt as EasyDataLoader, O as NullableSilk, On as ChainFactoryOptions, Ot as MayPromise, P as nullableSilk, Pn as QueryChainFactory, Pt as LoomDataLoader, Q as resolver, Qt as GraphQLFieldOptions, R as Executor, Rn as SubscriptionNeedResolve, Rt as OnlyMemoizationPayload, S as DirectiveItem, Sn as Operation, St as MiddlewareOperation, T as GQLoomExtensions, Tn as Subscription, Tt as filterMiddlewares, U as createField, Ut as AUTO_ALIASING, V as ResolverMeta, Vt as isOnlyMemoryPayload, W as createMutation, Wt as DERIVED_DEPENDENCIES, X as mutation, Xt as FieldOptions, Y as loom, Yt as FieldFactoryWithUtils, Z as query, Zt as FieldOrOperationType, _ as isSchemaVendorWeaver, _n as BaseField, _t as notNullish, a as LoomObjectType, an as OperationType, at as parseInputValue, b as ensureInputType, bn as FieldOrOperation, bt as Middleware, c as GlobalWeaverContext, cn as QueryOptions, ct as screamingSnakeCase, d as collectName, dn as ResolverOptionsWithParent, dt as getDeepResolvingFields, en as InferFieldInput, et as CallableInputParser, f as collectNames, fn as ResolverPayload, ft as getResolvingFields, g as SchemaWeaver, gn as SubscriptionOptions, gt as meta, h as weaverContext, hn as SubscriptionFactoryWithChain, ht as mapValue, i as CoreSchemaWeaverConfigOptions, in as MutationOptions, it as getStandardValue, j as isSilk, jn as IChainFactory, jt as ValueOf, k as getGraphQLArgumentConfig, kn as FieldChainFactory, kt as OmitInUnion, l as WeaverConfig, ln as ResolverOptions, lt as ResolvingFields, m as provideWeaverContext, mn as SubscriptionFactory, mt as deepMerge, n as weave, nn as MutationFactory, nt as InferInputO, o as OPERATION_OBJECT_NAMES, on as QueryFactory, ot as capitalize, p as initWeaverContext, pn as ResolvingOptions, pt as parseResolvingFields, q as defaultSubscriptionResolve, qt as getSubscriptionOptions, r as CoreSchemaWeaverConfig, rn as MutationFactoryWithChain, rt as createInputParser, s as getCacheType, sn as QueryFactoryWithChain, st as pascalCase, t as GraphQLSchemaLoom, tn as InferFieldOutput, tt as InferInputI, u as WeaverContext, un as ResolverOptionsWithExtensions, ut as ResolvingFieldsOptions, v as ensureInterfaceType, vn as Field, vt as toObjMap, w as GQLoomExtensionAttribute, wn as Resolver, wt as applyMiddlewares, x as inputToArgs, xn as Mutation, xt as MiddlewareConfig, y as ensureInputObjectType, yn as FieldMeta, yt as CallableMiddlewareOptions, z as ObjectChainResolver, zn as symbols_d_exports, zt as assignContextMap } from "./index-DPuy3FIT.cjs";
|
|
2
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, MayGetter, 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, ResolvingFieldsOptions, 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, getGraphQLArgumentConfig, 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 { $ as subscription, $t as GraphQLSilk, A as getGraphQLType, An as FieldFactoryWithResolve, At as RequireKeys, B as ResolverFactory, Bn as StandardSchemaV1, Bt as getMemoizationMap, C as DirectiveRecord, Cn as Query, Ct as MiddlewareOptions, D as NonNullSilk, Dn as BaseChainFactory, Dt as MayGetter, E as ListSilk, En as types_loom_d_exports, Et as IsAny, F as parseSilk, Fn as QueryFactoryWithResolve, Ft as markErrorLocation, G as createQuery, Gt as getFieldOptions, H as ToExecutorProps, Ht as onlyMemoization, I as silk, In as ResolvableSubscription, It as markLocation, J as field, Jt as FieldFactory, K as createSubscription, Kt as getOperationOptions, L as ChainResolver, Ln as SubscriptionChainFactory, Lt as tryIn, M as listSilk, Mn as MutationChainFactory, Mt as BatchLoadFn, N as nonNullSilk, Nn as MutationFactoryWithResolve, Nt as EasyDataLoader, O as NullableSilk, On as ChainFactoryOptions, Ot as MayPromise, P as nullableSilk, Pn as QueryChainFactory, Pt as LoomDataLoader, Q as resolver, Qt as GraphQLFieldOptions, R as Executor, Rn as SubscriptionNeedResolve, Rt as OnlyMemoizationPayload, S as DirectiveItem, Sn as Operation, St as MiddlewareOperation, T as GQLoomExtensions, Tn as Subscription, Tt as filterMiddlewares, U as createField, Ut as AUTO_ALIASING, V as ResolverMeta, Vt as isOnlyMemoryPayload, W as createMutation, Wt as DERIVED_DEPENDENCIES, X as mutation, Xt as FieldOptions, Y as loom, Yt as FieldFactoryWithUtils, Z as query, Zt as FieldOrOperationType, _ as isSchemaVendorWeaver, _n as BaseField, _t as notNullish, a as LoomObjectType, an as OperationType, at as parseInputValue, b as ensureInputType, bn as FieldOrOperation, bt as Middleware, c as GlobalWeaverContext, cn as QueryOptions, ct as screamingSnakeCase, d as collectName, dn as ResolverOptionsWithParent, dt as getDeepResolvingFields, en as InferFieldInput, et as CallableInputParser, f as collectNames, fn as ResolverPayload, ft as getResolvingFields, g as SchemaWeaver, gn as SubscriptionOptions, gt as meta, h as weaverContext, hn as SubscriptionFactoryWithChain, ht as mapValue, i as CoreSchemaWeaverConfigOptions, in as MutationOptions, it as getStandardValue, j as isSilk, jn as IChainFactory, jt as ValueOf, k as getGraphQLArgumentConfig, kn as FieldChainFactory, kt as OmitInUnion, l as WeaverConfig, ln as ResolverOptions, lt as ResolvingFields, m as provideWeaverContext, mn as SubscriptionFactory, mt as deepMerge, n as weave, nn as MutationFactory, nt as InferInputO, o as OPERATION_OBJECT_NAMES, on as QueryFactory, ot as capitalize, p as initWeaverContext, pn as ResolvingOptions, pt as parseResolvingFields, q as defaultSubscriptionResolve, qt as getSubscriptionOptions, r as CoreSchemaWeaverConfig, rn as MutationFactoryWithChain, rt as createInputParser, s as getCacheType, sn as QueryFactoryWithChain, st as pascalCase, t as GraphQLSchemaLoom, tn as InferFieldOutput, tt as InferInputI, u as WeaverContext, un as ResolverOptionsWithExtensions, ut as ResolvingFieldsOptions, v as ensureInterfaceType, vn as Field, vt as toObjMap, w as GQLoomExtensionAttribute, wn as Resolver, wt as applyMiddlewares, x as inputToArgs, xn as Mutation, xt as MiddlewareConfig, y as ensureInputObjectType, yn as FieldMeta, yt as CallableMiddlewareOptions, z as ObjectChainResolver, zn as symbols_d_exports, zt as assignContextMap } from "./index-
|
|
1
|
+
import { $ as subscription, $t as GraphQLSilk, A as getGraphQLType, An as FieldFactoryWithResolve, At as RequireKeys, B as ResolverFactory, Bn as StandardSchemaV1, Bt as getMemoizationMap, C as DirectiveRecord, Cn as Query, Ct as MiddlewareOptions, D as NonNullSilk, Dn as BaseChainFactory, Dt as MayGetter, E as ListSilk, En as types_loom_d_exports, Et as IsAny, F as parseSilk, Fn as QueryFactoryWithResolve, Ft as markErrorLocation, G as createQuery, Gt as getFieldOptions, H as ToExecutorProps, Ht as onlyMemoization, I as silk, In as ResolvableSubscription, It as markLocation, J as field, Jt as FieldFactory, K as createSubscription, Kt as getOperationOptions, L as ChainResolver, Ln as SubscriptionChainFactory, Lt as tryIn, M as listSilk, Mn as MutationChainFactory, Mt as BatchLoadFn, N as nonNullSilk, Nn as MutationFactoryWithResolve, Nt as EasyDataLoader, O as NullableSilk, On as ChainFactoryOptions, Ot as MayPromise, P as nullableSilk, Pn as QueryChainFactory, Pt as LoomDataLoader, Q as resolver, Qt as GraphQLFieldOptions, R as Executor, Rn as SubscriptionNeedResolve, Rt as OnlyMemoizationPayload, S as DirectiveItem, Sn as Operation, St as MiddlewareOperation, T as GQLoomExtensions, Tn as Subscription, Tt as filterMiddlewares, U as createField, Ut as AUTO_ALIASING, V as ResolverMeta, Vt as isOnlyMemoryPayload, W as createMutation, Wt as DERIVED_DEPENDENCIES, X as mutation, Xt as FieldOptions, Y as loom, Yt as FieldFactoryWithUtils, Z as query, Zt as FieldOrOperationType, _ as isSchemaVendorWeaver, _n as BaseField, _t as notNullish, a as LoomObjectType, an as OperationType, at as parseInputValue, b as ensureInputType, bn as FieldOrOperation, bt as Middleware, c as GlobalWeaverContext, cn as QueryOptions, ct as screamingSnakeCase, d as collectName, dn as ResolverOptionsWithParent, dt as getDeepResolvingFields, en as InferFieldInput, et as CallableInputParser, f as collectNames, fn as ResolverPayload, ft as getResolvingFields, g as SchemaWeaver, gn as SubscriptionOptions, gt as meta, h as weaverContext, hn as SubscriptionFactoryWithChain, ht as mapValue, i as CoreSchemaWeaverConfigOptions, in as MutationOptions, it as getStandardValue, j as isSilk, jn as IChainFactory, jt as ValueOf, k as getGraphQLArgumentConfig, kn as FieldChainFactory, kt as OmitInUnion, l as WeaverConfig, ln as ResolverOptions, lt as ResolvingFields, m as provideWeaverContext, mn as SubscriptionFactory, mt as deepMerge, n as weave, nn as MutationFactory, nt as InferInputO, o as OPERATION_OBJECT_NAMES, on as QueryFactory, ot as capitalize, p as initWeaverContext, pn as ResolvingOptions, pt as parseResolvingFields, q as defaultSubscriptionResolve, qt as getSubscriptionOptions, r as CoreSchemaWeaverConfig, rn as MutationFactoryWithChain, rt as createInputParser, s as getCacheType, sn as QueryFactoryWithChain, st as pascalCase, t as GraphQLSchemaLoom, tn as InferFieldOutput, tt as InferInputI, u as WeaverContext, un as ResolverOptionsWithExtensions, ut as ResolvingFieldsOptions, v as ensureInterfaceType, vn as Field, vt as toObjMap, w as GQLoomExtensionAttribute, wn as Resolver, wt as applyMiddlewares, x as inputToArgs, xn as Mutation, xt as MiddlewareConfig, y as ensureInputObjectType, yn as FieldMeta, yt as CallableMiddlewareOptions, z as ObjectChainResolver, zn as symbols_d_exports, zt as assignContextMap } from "./index-DyGHE5li.js";
|
|
2
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, MayGetter, 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, ResolvingFieldsOptions, 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, getGraphQLArgumentConfig, 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
|
@@ -54,30 +54,13 @@ var WeaverContext = class WeaverContext {
|
|
|
54
54
|
Scalar: "Scalar"
|
|
55
55
|
};
|
|
56
56
|
aliasCounters = {};
|
|
57
|
+
aliasMap = /* @__PURE__ */ new WeakMap();
|
|
57
58
|
setAlias(namedType, alias) {
|
|
58
59
|
if (namedType.name === AUTO_ALIASING) WeaverContext.autoAliasTypes.add(namedType);
|
|
59
60
|
if (!WeaverContext.autoAliasTypes.has(namedType)) return namedType.name;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (namedType.name === AUTO_ALIASING) {
|
|
64
|
-
if (isObjectType(namedType) || isInputObjectType(namedType)) {
|
|
65
|
-
this.aliasCounters["Object"] ??= 0;
|
|
66
|
-
return namedType.name = `Object${++this.aliasCounters["Object"]}`;
|
|
67
|
-
} else if (isUnionType(namedType)) {
|
|
68
|
-
this.aliasCounters["Union"] ??= 0;
|
|
69
|
-
return namedType.name = `Union${++this.aliasCounters["Union"]}`;
|
|
70
|
-
} else if (isEnumType(namedType)) {
|
|
71
|
-
this.aliasCounters["Enum"] ??= 0;
|
|
72
|
-
return namedType.name = `Enum${++this.aliasCounters["Enum"]}`;
|
|
73
|
-
} else if (isInterfaceType(namedType)) {
|
|
74
|
-
this.aliasCounters["Interface"] ??= 0;
|
|
75
|
-
return namedType.name = `Interface${++this.aliasCounters["Interface"]}`;
|
|
76
|
-
} else if (isScalarType(namedType)) {
|
|
77
|
-
this.aliasCounters["Scalar"] ??= 0;
|
|
78
|
-
return namedType.name = `Scalar${++this.aliasCounters["Scalar"]}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
61
|
+
const aliases = this.ensureAliasStore(namedType);
|
|
62
|
+
if (alias) aliases.add(alias);
|
|
63
|
+
return this.pickAlias(namedType, aliases);
|
|
81
64
|
}
|
|
82
65
|
/**
|
|
83
66
|
* @returns -1 if a is better than b, 1 if b is better than a, 0 if they are equal
|
|
@@ -91,6 +74,56 @@ var WeaverContext = class WeaverContext {
|
|
|
91
74
|
if (compareLocale !== 0) return compareLocale;
|
|
92
75
|
return 0;
|
|
93
76
|
}
|
|
77
|
+
ensureAliasStore(namedType) {
|
|
78
|
+
const existing = this.aliasMap.get(namedType);
|
|
79
|
+
if (existing) return existing;
|
|
80
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
81
|
+
this.aliasMap.set(namedType, aliases);
|
|
82
|
+
Object.defineProperty(namedType, "name", {
|
|
83
|
+
get: () => this.pickAlias(namedType, aliases),
|
|
84
|
+
set: (value) => {
|
|
85
|
+
aliases.add(value);
|
|
86
|
+
},
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true
|
|
89
|
+
});
|
|
90
|
+
return aliases;
|
|
91
|
+
}
|
|
92
|
+
pickAlias(namedType, aliases) {
|
|
93
|
+
const best = this.reduceAliases(aliases);
|
|
94
|
+
if (best && best !== AUTO_ALIASING) return best;
|
|
95
|
+
const fallback = this.createFallbackAlias(namedType);
|
|
96
|
+
aliases.add(fallback);
|
|
97
|
+
return this.reduceAliases(aliases) ?? fallback;
|
|
98
|
+
}
|
|
99
|
+
reduceAliases(aliases) {
|
|
100
|
+
let best;
|
|
101
|
+
for (const alias of aliases) if (best === void 0 || WeaverContext.higherPriorityThan(alias, best) < 0) best = alias;
|
|
102
|
+
return best;
|
|
103
|
+
}
|
|
104
|
+
createFallbackAlias(namedType) {
|
|
105
|
+
if (isObjectType(namedType) || isInputObjectType(namedType)) {
|
|
106
|
+
this.aliasCounters["Object"] ??= 0;
|
|
107
|
+
return `Object${++this.aliasCounters["Object"]}`;
|
|
108
|
+
}
|
|
109
|
+
if (isUnionType(namedType)) {
|
|
110
|
+
this.aliasCounters["Union"] ??= 0;
|
|
111
|
+
return `Union${++this.aliasCounters["Union"]}`;
|
|
112
|
+
}
|
|
113
|
+
if (isEnumType(namedType)) {
|
|
114
|
+
this.aliasCounters["Enum"] ??= 0;
|
|
115
|
+
return `Enum${++this.aliasCounters["Enum"]}`;
|
|
116
|
+
}
|
|
117
|
+
if (isInterfaceType(namedType)) {
|
|
118
|
+
this.aliasCounters["Interface"] ??= 0;
|
|
119
|
+
return `Interface${++this.aliasCounters["Interface"]}`;
|
|
120
|
+
}
|
|
121
|
+
if (isScalarType(namedType)) {
|
|
122
|
+
this.aliasCounters["Scalar"] ??= 0;
|
|
123
|
+
return `Scalar${++this.aliasCounters["Scalar"]}`;
|
|
124
|
+
}
|
|
125
|
+
return namedType.name;
|
|
126
|
+
}
|
|
94
127
|
static provide(func, value) {
|
|
95
128
|
const lastRef = WeaverContext._ref;
|
|
96
129
|
WeaverContext._ref = value;
|
|
@@ -168,7 +201,7 @@ var GlobalWeaverContext = class {
|
|
|
168
201
|
return gqlType;
|
|
169
202
|
}
|
|
170
203
|
setAlias(namedType, alias) {
|
|
171
|
-
return WeaverContext.ref?.setAlias(namedType, alias);
|
|
204
|
+
return WeaverContext.ref?.setAlias(namedType, alias) ?? namedType.name;
|
|
172
205
|
}
|
|
173
206
|
};
|
|
174
207
|
const weaverContext = new GlobalWeaverContext();
|
|
@@ -1580,7 +1613,10 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1580
1613
|
if (gqlType instanceof LoomObjectType) return gqlType;
|
|
1581
1614
|
if (isObjectType(gqlType)) {
|
|
1582
1615
|
const gqlObject = context.loomObjectMap?.get(gqlType);
|
|
1583
|
-
if (gqlObject != null)
|
|
1616
|
+
if (gqlObject != null) {
|
|
1617
|
+
context.setAlias(gqlObject, getAlias());
|
|
1618
|
+
return gqlObject;
|
|
1619
|
+
}
|
|
1584
1620
|
const loomObject = new LoomObjectType(gqlType, options);
|
|
1585
1621
|
context.loomObjectMap?.set(gqlType, loomObject);
|
|
1586
1622
|
context.setAlias(loomObject, getAlias());
|
|
@@ -1589,7 +1625,10 @@ function getCacheType(gqlType, options = {}) {
|
|
|
1589
1625
|
else if (isNonNullType(gqlType)) return new GraphQLNonNull(getCacheType(gqlType.ofType, options));
|
|
1590
1626
|
else if (isUnionType(gqlType)) {
|
|
1591
1627
|
const existing = context.loomUnionMap?.get(gqlType);
|
|
1592
|
-
if (existing != null)
|
|
1628
|
+
if (existing != null) {
|
|
1629
|
+
context.setAlias(existing, getAlias());
|
|
1630
|
+
return existing;
|
|
1631
|
+
}
|
|
1593
1632
|
const config = gqlType.toConfig();
|
|
1594
1633
|
const unionType = new GraphQLUnionType({
|
|
1595
1634
|
...config,
|