@gqloom/core 0.11.0 → 0.11.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.
@@ -1,10 +1,12 @@
1
1
  //#region rolldown:runtime
2
2
  var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
3
+ var __export = (all) => {
4
+ let target = {};
4
5
  for (var name in all) __defProp(target, name, {
5
6
  get: all[name],
6
7
  enumerable: true
7
8
  });
9
+ return target;
8
10
  };
9
11
 
10
12
  //#endregion
@@ -1,4 +1,4 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
1
+ import { __export } from "./chunk-CTAAG5j7.js";
2
2
  import { Kind, isInterfaceType, isListType, isNonNullType, isObjectType } from "graphql";
3
3
 
4
4
  //#region src/utils/constants.ts
@@ -182,8 +182,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
182
182
  case Kind.FIELD: {
183
183
  const fieldName = selection.name.value;
184
184
  currentFields.add(fieldName);
185
- const hasSelectionSet = selection.selectionSet != null;
186
- if (hasSelectionSet) {
185
+ if (selection.selectionSet != null) {
187
186
  const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
188
187
  this.collectFields(selection.selectionSet, fieldPath, currentDepth + 1);
189
188
  }
@@ -217,8 +216,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
217
216
  if (value.kind === Kind.BOOLEAN) return value.value;
218
217
  if (value.kind === Kind.VARIABLE) {
219
218
  const variableName = value.name.value;
220
- const variableValue = this.info.variableValues?.[variableName];
221
- return variableValue === true;
219
+ return this.info.variableValues?.[variableName] === true;
222
220
  }
223
221
  return true;
224
222
  }
@@ -232,8 +230,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
232
230
  shouldIncludeNode(node) {
233
231
  if (!node.directives?.length) return true;
234
232
  return node.directives.every((directive) => {
235
- const isIncludeDirective = directive.name.value === "include";
236
- if (isIncludeDirective) return this.getDirectiveValue(directive);
233
+ if (directive.name.value === "include") return this.getDirectiveValue(directive);
237
234
  if (directive.name.value === "skip") return !this.getDirectiveValue(directive);
238
235
  return true;
239
236
  });
@@ -242,8 +239,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
242
239
 
243
240
  //#endregion
244
241
  //#region src/utils/symbols.ts
245
- var symbols_exports = {};
246
- __export(symbols_exports, {
242
+ var symbols_exports = /* @__PURE__ */ __export({
247
243
  CONTEXT_MAP_KEY: () => CONTEXT_MAP_KEY,
248
244
  FIELD_HIDDEN: () => FIELD_HIDDEN,
249
245
  GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
@@ -5,11 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
8
+ var __export = (all) => {
9
+ let target = {};
9
10
  for (var name in all) __defProp(target, name, {
10
11
  get: all[name],
11
12
  enumerable: true
12
13
  });
14
+ return target;
13
15
  };
14
16
  var __copyProps = (to, from, except, desc) => {
15
17
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -211,8 +213,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
211
213
  case graphql.Kind.FIELD: {
212
214
  const fieldName = selection.name.value;
213
215
  currentFields.add(fieldName);
214
- const hasSelectionSet = selection.selectionSet != null;
215
- if (hasSelectionSet) {
216
+ if (selection.selectionSet != null) {
216
217
  const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;
217
218
  this.collectFields(selection.selectionSet, fieldPath, currentDepth + 1);
218
219
  }
@@ -246,8 +247,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
246
247
  if (value.kind === graphql.Kind.BOOLEAN) return value.value;
247
248
  if (value.kind === graphql.Kind.VARIABLE) {
248
249
  const variableName = value.name.value;
249
- const variableValue = this.info.variableValues?.[variableName];
250
- return variableValue === true;
250
+ return this.info.variableValues?.[variableName] === true;
251
251
  }
252
252
  return true;
253
253
  }
@@ -261,8 +261,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
261
261
  shouldIncludeNode(node) {
262
262
  if (!node.directives?.length) return true;
263
263
  return node.directives.every((directive) => {
264
- const isIncludeDirective = directive.name.value === "include";
265
- if (isIncludeDirective) return this.getDirectiveValue(directive);
264
+ if (directive.name.value === "include") return this.getDirectiveValue(directive);
266
265
  if (directive.name.value === "skip") return !this.getDirectiveValue(directive);
267
266
  return true;
268
267
  });
@@ -271,8 +270,7 @@ var ResolvingFieldsParser = class ResolvingFieldsParser {
271
270
 
272
271
  //#endregion
273
272
  //#region src/utils/symbols.ts
274
- var symbols_exports = {};
275
- __export(symbols_exports, {
273
+ var symbols_exports = /* @__PURE__ */ __export({
276
274
  CONTEXT_MAP_KEY: () => CONTEXT_MAP_KEY,
277
275
  FIELD_HIDDEN: () => FIELD_HIDDEN,
278
276
  GET_GRAPHQL_TYPE: () => GET_GRAPHQL_TYPE,
package/dist/context.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_context = require('./context-3UlS1xGQ.cjs');
1
+ const require_context = require('./context-CnY_BFnk.cjs');
2
2
  let node_async_hooks = require("node:async_hooks");
3
3
  node_async_hooks = require_context.__toESM(node_async_hooks);
4
4
 
@@ -1,4 +1,4 @@
1
- import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-DUqXX1Tm.cjs";
1
+ import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-DXUAbzqx.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-GSWAHvDy.js";
1
+ import { BaseField, Middleware, OnlyMemoizationPayload, ResolverPayload, ResolvingFields } from "./index-t3pO8DK2.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-CpbCknos.js";
1
+ import { getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization } from "./context-BtR7FTYT.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;
@@ -679,7 +681,7 @@ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<
679
681
  * Non-nullable Silk.
680
682
  */
681
683
  declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
682
- type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<StandardSchemaV1.InferOutput<TSilk>>, EnsureArray<StandardSchemaV1.InferOutput<TSilk>>>;
684
+ type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<Array<StandardSchemaV1.InferOutput<TSilk>>, Array<StandardSchemaV1.InferOutput<TSilk>>>;
683
685
  /**
684
686
  * List Silk.
685
687
  */
@@ -707,7 +709,6 @@ type GraphQLVariants<TSource extends GraphQLNullableType> = TSource | GraphQLLis
707
709
  type InferScalarInternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarInternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarInternalByVariants<U>[] : never : T extends GraphQLScalarType<infer TInternal, any> ? TInternal | null | undefined : never;
708
710
  type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarExternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarExternalByVariants<U>[] : never : T extends GraphQLScalarType<any, infer TExternal> ? TExternal | null | undefined : never;
709
711
  type InferObjectSourceByVariants<T extends GraphQLVariants<GraphQLObjectType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? NonNullable<InferObjectSourceByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? InferObjectSourceByVariants<U>[] : never : T extends GraphQLObjectType<infer TSource> ? TSource | null | undefined : never;
710
- type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
711
712
  //#endregion
712
713
  //#region src/resolver/resolver.d.ts
713
714
  /**
@@ -738,7 +739,7 @@ declare const mutation$1: MutationFactoryWithChain;
738
739
  * @param resolveOrOptions - Either a resolve function or options object
739
740
  * @returns A GraphQL field resolver
740
741
  */
741
- declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => FieldChainFactory<never, undefined, undefined> | Field<any, any, any, any>;
742
+ declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => Field<any, any, any, any> | FieldChainFactory<never, undefined, undefined>;
742
743
  /**
743
744
  * Factory function for creating GraphQL fields with chainable configuration
744
745
  */
@@ -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;
@@ -681,7 +679,7 @@ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<
681
679
  * Non-nullable Silk.
682
680
  */
683
681
  declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
684
- type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<StandardSchemaV1.InferOutput<TSilk>>, EnsureArray<StandardSchemaV1.InferOutput<TSilk>>>;
682
+ type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<Array<StandardSchemaV1.InferOutput<TSilk>>, Array<StandardSchemaV1.InferOutput<TSilk>>>;
685
683
  /**
686
684
  * List Silk.
687
685
  */
@@ -709,7 +707,6 @@ type GraphQLVariants<TSource extends GraphQLNullableType> = TSource | GraphQLLis
709
707
  type InferScalarInternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarInternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarInternalByVariants<U>[] : never : T extends GraphQLScalarType<infer TInternal, any> ? TInternal | null | undefined : never;
710
708
  type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarExternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarExternalByVariants<U>[] : never : T extends GraphQLScalarType<any, infer TExternal> ? TExternal | null | undefined : never;
711
709
  type InferObjectSourceByVariants<T extends GraphQLVariants<GraphQLObjectType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? NonNullable<InferObjectSourceByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? InferObjectSourceByVariants<U>[] : never : T extends GraphQLObjectType<infer TSource> ? TSource | null | undefined : never;
712
- type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
713
710
  //#endregion
714
711
  //#region src/resolver/resolver.d.ts
715
712
  /**
@@ -740,7 +737,7 @@ declare const mutation$1: MutationFactoryWithChain;
740
737
  * @param resolveOrOptions - Either a resolve function or options object
741
738
  * @returns A GraphQL field resolver
742
739
  */
743
- declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => FieldChainFactory<never, undefined, undefined> | Field<any, any, any, any>;
740
+ declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => Field<any, any, any, any> | FieldChainFactory<never, undefined, undefined>;
744
741
  /**
745
742
  * Factory function for creating GraphQL fields with chainable configuration
746
743
  */
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_context = require('./context-3UlS1xGQ.cjs');
1
+ const require_context = require('./context-CnY_BFnk.cjs');
2
2
  let graphql = require("graphql");
3
3
  graphql = require_context.__toESM(graphql);
4
4
 
@@ -46,8 +46,7 @@ function filterMiddlewares(operation, ...middlewareList) {
46
46
  return middlewareList.reduce((acc, m) => {
47
47
  if (!m) return acc;
48
48
  acc.push(...ensureArray(m).filter((m$1) => {
49
- const ops = m$1.operations ?? defaultOperations;
50
- return ops.includes(operation);
49
+ return (m$1.operations ?? defaultOperations).includes(operation);
51
50
  }));
52
51
  return acc;
53
52
  }, []);
@@ -149,13 +148,11 @@ function tryIn(func, ...locations) {
149
148
  function markLocation(message, ...locations) {
150
149
  if (locations.length === 0) return message;
151
150
  const [existingPrefix, newMessage] = (() => {
152
- const existingPrefixPattern = /^\[(.*?)\]/;
153
- const match = existingPrefixPattern.exec(message);
151
+ const match = /^\[(.*?)\]/.exec(message);
154
152
  if (match) return [match[1], message.slice(match[0].length).trim()];
155
153
  return [void 0, message];
156
154
  })();
157
- const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
158
- return `[${combinedLocation}] ${newMessage}`;
155
+ return `[${locations.concat(existingPrefix ? [existingPrefix] : []).join(".")}] ${newMessage}`;
159
156
  }
160
157
 
161
158
  //#endregion
@@ -451,7 +448,7 @@ function parseSilk(silk$1, input) {
451
448
  return silk$1["~standard"].validate(input);
452
449
  }
453
450
  function isSilk(target) {
454
- if (typeof target !== "object") return false;
451
+ if (typeof target !== "object" && typeof target !== "function") return false;
455
452
  if (target == null) return false;
456
453
  if (require_context.GET_GRAPHQL_TYPE in target) return true;
457
454
  if (!("~standard" in target)) return false;
@@ -676,8 +673,7 @@ var FieldChainFactory = class FieldChainFactory extends BaseChainFactory {
676
673
  return createField(this.options.output, {
677
674
  ...this.options,
678
675
  resolve: (parent, input, payload) => {
679
- const loader = FieldLoader.getByPath(payload, resolve, this.options?.input != null);
680
- return loader.load([
676
+ return FieldLoader.getByPath(payload, resolve, this.options?.input != null).load([
681
677
  parent,
682
678
  input,
683
679
  payload
@@ -1131,11 +1127,10 @@ var ChainResolver = class {
1131
1127
  return this;
1132
1128
  }
1133
1129
  toExecutor(...middlewares) {
1134
- const executor = mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
1135
- return executor;
1130
+ return mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
1136
1131
  }
1137
1132
  toExecutorOperation(field$1, executorMiddlewares) {
1138
- if (field$1 === require_context.FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return void 0;
1133
+ if (field$1 === require_context.FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return;
1139
1134
  const operation = field$1["~meta"].operation;
1140
1135
  const middlewares = filterMiddlewares(operation, executorMiddlewares, this.meta.options?.middlewares, field$1["~meta"].middlewares);
1141
1136
  if (field$1["~meta"].operation === "field") {
@@ -1253,8 +1248,7 @@ function ensureInputObjectType(object, options) {
1253
1248
  const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
1254
1249
  let name = object.name;
1255
1250
  if (name === LoomObjectType.AUTO_ALIASING) name = `${pascalCase(options?.fieldName ?? "")}Input`;
1256
- const getInputObjectName = weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n);
1257
- name = getInputObjectName(name);
1251
+ name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
1258
1252
  const input = new graphql.GraphQLInputObjectType({
1259
1253
  ...config,
1260
1254
  name,
@@ -1608,14 +1602,13 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
1608
1602
  weaveGraphQLSchema() {
1609
1603
  const { query: query$1, mutation: mutation$1, subscription: subscription$1, types } = this;
1610
1604
  const config = this.context.getConfig("gqloom.core.schema");
1611
- const schema = new graphql.GraphQLSchema({
1605
+ return new graphql.GraphQLSchema({
1612
1606
  query: query$1,
1613
1607
  mutation: mutation$1,
1614
1608
  subscription: subscription$1,
1615
1609
  types: [...types ?? [], ...config?.types ?? []],
1616
1610
  ...config
1617
1611
  });
1618
- return schema;
1619
1612
  }
1620
1613
  addResolver(resolver$1, modifyParent) {
1621
1614
  const resolverOptions = resolver$1["~meta"].options;
@@ -1641,10 +1634,7 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
1641
1634
  } else if (field$1["~meta"].operation === "field") {
1642
1635
  if (parentObject == null) return;
1643
1636
  parentObject.addField(name, field$1, resolver$1);
1644
- } else {
1645
- const operationObject = this.getOperationObject(field$1["~meta"].operation);
1646
- operationObject.addField(name, field$1, resolver$1);
1647
- }
1637
+ } else this.getOperationObject(field$1["~meta"].operation).addField(name, field$1, resolver$1);
1648
1638
  });
1649
1639
  return this;
1650
1640
  }
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-DUqXX1Tm.cjs";
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-DXUAbzqx.cjs";
2
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 };
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-GSWAHvDy.js";
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-t3pO8DK2.js";
2
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 };
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-CpbCknos.js";
1
+ import { DERIVED_DEPENDENCIES, FIELD_HIDDEN, GET_GRAPHQL_TYPE, IS_RESOLVER, WEAVER_CONFIG, assignContextMap, getDeepResolvingFields, getMemoizationMap, getResolvingFields, isOnlyMemoryPayload, onlyMemoization, parseResolvingFields, symbols_exports } from "./context-BtR7FTYT.js";
2
2
  import { GraphQLError, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLUnionType, assertName, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, resolveObjMapThunk } from "graphql";
3
3
 
4
4
  //#region src/utils/args.ts
@@ -45,8 +45,7 @@ function filterMiddlewares(operation, ...middlewareList) {
45
45
  return middlewareList.reduce((acc, m) => {
46
46
  if (!m) return acc;
47
47
  acc.push(...ensureArray(m).filter((m$1) => {
48
- const ops = m$1.operations ?? defaultOperations;
49
- return ops.includes(operation);
48
+ return (m$1.operations ?? defaultOperations).includes(operation);
50
49
  }));
51
50
  return acc;
52
51
  }, []);
@@ -148,13 +147,11 @@ function tryIn(func, ...locations) {
148
147
  function markLocation(message, ...locations) {
149
148
  if (locations.length === 0) return message;
150
149
  const [existingPrefix, newMessage] = (() => {
151
- const existingPrefixPattern = /^\[(.*?)\]/;
152
- const match = existingPrefixPattern.exec(message);
150
+ const match = /^\[(.*?)\]/.exec(message);
153
151
  if (match) return [match[1], message.slice(match[0].length).trim()];
154
152
  return [void 0, message];
155
153
  })();
156
- const combinedLocation = locations.concat(existingPrefix ? [existingPrefix] : []).join(".");
157
- return `[${combinedLocation}] ${newMessage}`;
154
+ return `[${locations.concat(existingPrefix ? [existingPrefix] : []).join(".")}] ${newMessage}`;
158
155
  }
159
156
 
160
157
  //#endregion
@@ -450,7 +447,7 @@ function parseSilk(silk$1, input) {
450
447
  return silk$1["~standard"].validate(input);
451
448
  }
452
449
  function isSilk(target) {
453
- if (typeof target !== "object") return false;
450
+ if (typeof target !== "object" && typeof target !== "function") return false;
454
451
  if (target == null) return false;
455
452
  if (GET_GRAPHQL_TYPE in target) return true;
456
453
  if (!("~standard" in target)) return false;
@@ -675,8 +672,7 @@ var FieldChainFactory = class FieldChainFactory extends BaseChainFactory {
675
672
  return createField(this.options.output, {
676
673
  ...this.options,
677
674
  resolve: (parent, input, payload) => {
678
- const loader = FieldLoader.getByPath(payload, resolve, this.options?.input != null);
679
- return loader.load([
675
+ return FieldLoader.getByPath(payload, resolve, this.options?.input != null).load([
680
676
  parent,
681
677
  input,
682
678
  payload
@@ -1130,11 +1126,10 @@ var ChainResolver = class {
1130
1126
  return this;
1131
1127
  }
1132
1128
  toExecutor(...middlewares) {
1133
- const executor = mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
1134
- return executor;
1129
+ return mapValue(this["~meta"].fields, (field$1) => this.toExecutorOperation(field$1, middlewares) ?? mapValue.SKIP);
1135
1130
  }
1136
1131
  toExecutorOperation(field$1, executorMiddlewares) {
1137
- if (field$1 === FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return void 0;
1132
+ if (field$1 === FIELD_HIDDEN || field$1["~meta"].operation === "subscription") return;
1138
1133
  const operation = field$1["~meta"].operation;
1139
1134
  const middlewares = filterMiddlewares(operation, executorMiddlewares, this.meta.options?.middlewares, field$1["~meta"].middlewares);
1140
1135
  if (field$1["~meta"].operation === "field") {
@@ -1252,8 +1247,7 @@ function ensureInputObjectType(object, options) {
1252
1247
  const { astNode, extensionASTNodes, fields,...config } = object.toConfig();
1253
1248
  let name = object.name;
1254
1249
  if (name === LoomObjectType.AUTO_ALIASING) name = `${pascalCase(options?.fieldName ?? "")}Input`;
1255
- const getInputObjectName = weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n);
1256
- name = getInputObjectName(name);
1250
+ name = (weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n))(name);
1257
1251
  const input = new GraphQLInputObjectType({
1258
1252
  ...config,
1259
1253
  name,
@@ -1607,14 +1601,13 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
1607
1601
  weaveGraphQLSchema() {
1608
1602
  const { query: query$1, mutation: mutation$1, subscription: subscription$1, types } = this;
1609
1603
  const config = this.context.getConfig("gqloom.core.schema");
1610
- const schema = new GraphQLSchema({
1604
+ return new GraphQLSchema({
1611
1605
  query: query$1,
1612
1606
  mutation: mutation$1,
1613
1607
  subscription: subscription$1,
1614
1608
  types: [...types ?? [], ...config?.types ?? []],
1615
1609
  ...config
1616
1610
  });
1617
- return schema;
1618
1611
  }
1619
1612
  addResolver(resolver$1, modifyParent) {
1620
1613
  const resolverOptions = resolver$1["~meta"].options;
@@ -1640,10 +1633,7 @@ var GraphQLSchemaLoom = class GraphQLSchemaLoom {
1640
1633
  } else if (field$1["~meta"].operation === "field") {
1641
1634
  if (parentObject == null) return;
1642
1635
  parentObject.addField(name, field$1, resolver$1);
1643
- } else {
1644
- const operationObject = this.getOperationObject(field$1["~meta"].operation);
1645
- operationObject.addField(name, field$1, resolver$1);
1646
- }
1636
+ } else this.getOperationObject(field$1["~meta"].operation).addField(name, field$1, resolver$1);
1647
1637
  });
1648
1638
  return this;
1649
1639
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gqloom/core",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Create GraphQL schema and resolvers with TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",