@gqloom/core 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -192,7 +192,7 @@ function listSilk(origin) {
192
192
  [GET_GRAPHQL_TYPE]: () => {
193
193
  let originType = getGraphQLType(origin);
194
194
  if (originType instanceof GraphQLNonNull && originType.ofType instanceof GraphQLList) {
195
- originType = originType.ofType;
195
+ originType = originType.ofType.ofType;
196
196
  }
197
197
  if (originType instanceof GraphQLList) {
198
198
  originType = originType.ofType;
@@ -426,6 +426,16 @@ function deepMerge(...objects) {
426
426
  return result;
427
427
  }
428
428
 
429
+ // src/utils/string.ts
430
+ function pascalCase(str) {
431
+ return str.split(/[\s-_]+/).map(
432
+ (word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)
433
+ ).join("");
434
+ }
435
+ function capitalize(str) {
436
+ return str.slice(0, 1).toUpperCase() + str.slice(1);
437
+ }
438
+
429
439
  // src/utils/error.ts
430
440
  function markErrorLocation(error, ...locations) {
431
441
  if (error instanceof Error) {
@@ -454,6 +464,72 @@ function markLocation(message, ...locations) {
454
464
  return `[${combinedLocation}] ${newMessage}`;
455
465
  }
456
466
 
467
+ // src/utils/loader.ts
468
+ var EasyDataLoader = class _EasyDataLoader {
469
+ constructor(batchLoadFn) {
470
+ this.batchLoadFn = batchLoadFn;
471
+ this.queue = [];
472
+ this.cache = /* @__PURE__ */ new Map();
473
+ this.resolvers = /* @__PURE__ */ new Map();
474
+ }
475
+ queue;
476
+ cache;
477
+ resolvers;
478
+ load(key) {
479
+ const existing = this.cache.get(key);
480
+ if (existing) return existing;
481
+ const promise = new Promise((resolve, reject) => {
482
+ this.queue.push(key);
483
+ this.resolvers.set(key, [resolve, reject]);
484
+ this.nextTickBatchLoad();
485
+ });
486
+ this.cache.set(key, promise);
487
+ return promise;
488
+ }
489
+ clear() {
490
+ this.queue = [];
491
+ this.cache = /* @__PURE__ */ new Map();
492
+ this.resolvers = /* @__PURE__ */ new Map();
493
+ }
494
+ clearByKey(key) {
495
+ this.queue = this.queue.filter((k) => k !== key);
496
+ this.cache.delete(key);
497
+ this.resolvers.delete(key);
498
+ }
499
+ async executeBatchLoad() {
500
+ if (this.queue.length === 0) return;
501
+ const [keys, resolvers] = [this.queue, this.resolvers];
502
+ this.queue = [];
503
+ this.resolvers = /* @__PURE__ */ new Map();
504
+ try {
505
+ const list = await this.batchLoadFn(keys);
506
+ for (let i = 0; i < list.length; i++) {
507
+ const data = list[i];
508
+ const resolve = resolvers.get(keys[i])?.[0];
509
+ const reject = resolvers.get(keys[i])?.[1];
510
+ if (data instanceof Error) {
511
+ reject?.(data);
512
+ } else {
513
+ resolve?.(data);
514
+ }
515
+ }
516
+ } catch (error) {
517
+ for (const key of keys) {
518
+ const reject = resolvers.get(key)?.[1];
519
+ reject?.(error);
520
+ }
521
+ }
522
+ }
523
+ nextTickPromise;
524
+ nextTickBatchLoad() {
525
+ this.nextTickPromise ??= _EasyDataLoader.nextTick().then(() => this.executeBatchLoad()).finally(() => this.nextTickPromise = void 0);
526
+ return this.nextTickPromise;
527
+ }
528
+ static nextTick() {
529
+ return new Promise((resolve) => setTimeout(resolve));
530
+ }
531
+ };
532
+
457
533
  // src/resolver/input.ts
458
534
  import { GraphQLError } from "graphql";
459
535
  function createInputParser(schema, value) {
@@ -507,8 +583,168 @@ function getStandardValue(result) {
507
583
  else throw new GraphQLError("Invalid input");
508
584
  }
509
585
 
586
+ // src/resolver/resolver-chain-factory.ts
587
+ var BaseChainFactory = class _BaseChainFactory {
588
+ constructor(options) {
589
+ this.options = options;
590
+ }
591
+ static methods() {
592
+ return {
593
+ description: _BaseChainFactory.prototype.description,
594
+ deprecationReason: _BaseChainFactory.prototype.deprecationReason,
595
+ extensions: _BaseChainFactory.prototype.extensions
596
+ };
597
+ }
598
+ description(description) {
599
+ return this.clone({ description });
600
+ }
601
+ deprecationReason(deprecationReason) {
602
+ return this.clone({ deprecationReason });
603
+ }
604
+ extensions(extensions) {
605
+ return this.clone({ extensions });
606
+ }
607
+ use(...middlewares) {
608
+ return this.clone({
609
+ middlewares: [...this.options?.middlewares ?? [], ...middlewares]
610
+ });
611
+ }
612
+ };
613
+ var FieldChainFactory = class _FieldChainFactory extends BaseChainFactory {
614
+ static methods() {
615
+ return {
616
+ ...BaseChainFactory.methods(),
617
+ output: _FieldChainFactory.prototype.output,
618
+ input: _FieldChainFactory.prototype.input,
619
+ resolve: _FieldChainFactory.prototype.resolve,
620
+ clone: _FieldChainFactory.prototype.clone
621
+ };
622
+ }
623
+ clone(options) {
624
+ return new _FieldChainFactory({ ...this.options, ...options });
625
+ }
626
+ use(...middlewares) {
627
+ return super.use(...middlewares);
628
+ }
629
+ output(output) {
630
+ return new _FieldChainFactory({ ...this.options, output });
631
+ }
632
+ input(input) {
633
+ return new _FieldChainFactory({ ...this.options, input });
634
+ }
635
+ resolve(resolve) {
636
+ return createField(this.options?.output, {
637
+ ...this.options,
638
+ resolve
639
+ });
640
+ }
641
+ };
642
+ var QueryChainFactory = class _QueryChainFactory extends BaseChainFactory {
643
+ static methods() {
644
+ return {
645
+ ...BaseChainFactory.methods(),
646
+ output: _QueryChainFactory.prototype.output,
647
+ input: _QueryChainFactory.prototype.input,
648
+ resolve: _QueryChainFactory.prototype.resolve,
649
+ clone: _QueryChainFactory.prototype.clone
650
+ };
651
+ }
652
+ clone(options) {
653
+ return new _QueryChainFactory({ ...this.options, ...options });
654
+ }
655
+ use(...middlewares) {
656
+ return super.use(...middlewares);
657
+ }
658
+ output(output) {
659
+ return new _QueryChainFactory({ ...this.options, output });
660
+ }
661
+ input(input) {
662
+ return new _QueryChainFactory({ ...this.options, input });
663
+ }
664
+ resolve(resolve) {
665
+ return createQuery(this.options?.output, {
666
+ ...this.options,
667
+ resolve
668
+ });
669
+ }
670
+ };
671
+ var MutationChainFactory = class _MutationChainFactory extends BaseChainFactory {
672
+ static methods() {
673
+ return {
674
+ ...BaseChainFactory.methods(),
675
+ output: _MutationChainFactory.prototype.output,
676
+ input: _MutationChainFactory.prototype.input,
677
+ resolve: _MutationChainFactory.prototype.resolve,
678
+ clone: _MutationChainFactory.prototype.clone
679
+ };
680
+ }
681
+ clone(options) {
682
+ return new _MutationChainFactory({ ...this.options, ...options });
683
+ }
684
+ use(...middlewares) {
685
+ return super.use(...middlewares);
686
+ }
687
+ output(output) {
688
+ return new _MutationChainFactory({ ...this.options, output });
689
+ }
690
+ input(input) {
691
+ return new _MutationChainFactory({ ...this.options, input });
692
+ }
693
+ resolve(resolve) {
694
+ return createMutation(this.options?.output, {
695
+ ...this.options,
696
+ resolve
697
+ });
698
+ }
699
+ };
700
+ var SubscriptionChainFactory = class _SubscriptionChainFactory extends BaseChainFactory {
701
+ static methods() {
702
+ return {
703
+ ...BaseChainFactory.methods(),
704
+ output: _SubscriptionChainFactory.prototype.output,
705
+ input: _SubscriptionChainFactory.prototype.input,
706
+ subscribe: _SubscriptionChainFactory.prototype.subscribe,
707
+ clone: _SubscriptionChainFactory.prototype.clone
708
+ };
709
+ }
710
+ clone(options) {
711
+ return new _SubscriptionChainFactory({ ...this.options, ...options });
712
+ }
713
+ use(...middlewares) {
714
+ return super.use(...middlewares);
715
+ }
716
+ output(output) {
717
+ return new _SubscriptionChainFactory({ ...this.options, output });
718
+ }
719
+ input(input) {
720
+ return new _SubscriptionChainFactory({ ...this.options, input });
721
+ }
722
+ subscribe(subscribe) {
723
+ const options = this.options;
724
+ const subscription2 = createSubscription(options?.output, {
725
+ ...options,
726
+ subscribe
727
+ });
728
+ const subscriptionResolve = subscription2.resolve;
729
+ const resolve = (...args) => {
730
+ if (args.length === 1 && typeof args[0] === "function") {
731
+ return createSubscription(options?.output, {
732
+ ...options,
733
+ resolve: args[0],
734
+ subscribe
735
+ });
736
+ }
737
+ return subscriptionResolve(...args);
738
+ };
739
+ return Object.assign(subscription2, { resolve });
740
+ }
741
+ };
742
+
510
743
  // src/resolver/resolver.ts
511
- var query = (output, resolveOrOptions) => {
744
+ var createQuery = (output, resolveOrOptions) => {
745
+ if (resolveOrOptions == null) {
746
+ return new QueryChainFactory({ output });
747
+ }
512
748
  const options = getOperationOptions(resolveOrOptions);
513
749
  const type = "query";
514
750
  return {
@@ -526,7 +762,14 @@ var query = (output, resolveOrOptions) => {
526
762
  type
527
763
  };
528
764
  };
529
- var mutation = (output, resolveOrOptions) => {
765
+ var query = Object.assign(
766
+ createQuery,
767
+ QueryChainFactory.methods()
768
+ );
769
+ var createMutation = (output, resolveOrOptions) => {
770
+ if (resolveOrOptions == null) {
771
+ return new MutationChainFactory({ output });
772
+ }
530
773
  const options = getOperationOptions(resolveOrOptions);
531
774
  const type = "mutation";
532
775
  return {
@@ -544,7 +787,14 @@ var mutation = (output, resolveOrOptions) => {
544
787
  type
545
788
  };
546
789
  };
547
- var baseSilkField = (output, resolveOrOptions) => {
790
+ var mutation = Object.assign(
791
+ createMutation,
792
+ MutationChainFactory.methods()
793
+ );
794
+ var createField = (output, resolveOrOptions) => {
795
+ if (resolveOrOptions == null) {
796
+ return new FieldChainFactory({ output });
797
+ }
548
798
  const options = getOperationOptions(resolveOrOptions);
549
799
  const type = "field";
550
800
  return {
@@ -563,13 +813,15 @@ var baseSilkField = (output, resolveOrOptions) => {
563
813
  };
564
814
  };
565
815
  var field = Object.assign(
566
- baseSilkField,
567
- {
568
- hidden: FIELD_HIDDEN
569
- }
816
+ createField,
817
+ { hidden: FIELD_HIDDEN },
818
+ FieldChainFactory.methods()
570
819
  );
571
820
  var defaultSubscriptionResolve = (source) => source;
572
- var subscription = (output, subscribeOrOptions) => {
821
+ var createSubscription = (output, subscribeOrOptions) => {
822
+ if (subscribeOrOptions == null) {
823
+ return new SubscriptionChainFactory({ output });
824
+ }
573
825
  const options = getSubscriptionOptions(subscribeOrOptions);
574
826
  const type = "subscription";
575
827
  return {
@@ -591,6 +843,10 @@ var subscription = (output, subscribeOrOptions) => {
591
843
  type
592
844
  };
593
845
  };
846
+ var subscription = Object.assign(
847
+ createSubscription,
848
+ SubscriptionChainFactory.methods()
849
+ );
594
850
  var ResolverOptionsMap = /* @__PURE__ */ new WeakMap();
595
851
  function baseResolver(operations, options) {
596
852
  const record = {};
@@ -671,6 +927,9 @@ function createResolverFactory(toSilk) {
671
927
  }
672
928
  function createFieldFactory(toSilk, isSchema) {
673
929
  const baseFieldFunc = (output, resolveOrOptions) => {
930
+ if (resolveOrOptions == null) {
931
+ return new FieldChainFactory({ output: toSilk(output) });
932
+ }
674
933
  const options = getOperationOptions(
675
934
  resolveOrOptions
676
935
  );
@@ -679,12 +938,17 @@ function createFieldFactory(toSilk, isSchema) {
679
938
  input: toSilkInput(options.input, toSilk, isSchema)
680
939
  });
681
940
  };
682
- return Object.assign(baseFieldFunc, {
683
- hidden: FIELD_HIDDEN
684
- });
941
+ return Object.assign(
942
+ baseFieldFunc,
943
+ { hidden: FIELD_HIDDEN },
944
+ FieldChainFactory.methods()
945
+ );
685
946
  }
686
947
  function createQueryFactory(toSilk, isSchema) {
687
948
  return (output, resolveOrOptions) => {
949
+ if (resolveOrOptions == null) {
950
+ return new QueryChainFactory({ output: toSilk(output) });
951
+ }
688
952
  const options = getOperationOptions(resolveOrOptions);
689
953
  return query(toSilk(output), {
690
954
  ...options,
@@ -694,6 +958,9 @@ function createQueryFactory(toSilk, isSchema) {
694
958
  }
695
959
  function createMutationFactory(toSilk, isSchema) {
696
960
  return (output, resolveOrOptions) => {
961
+ if (resolveOrOptions == null) {
962
+ return new MutationChainFactory({ output: toSilk(output) });
963
+ }
697
964
  const options = getOperationOptions(resolveOrOptions);
698
965
  return mutation(toSilk(output), {
699
966
  ...options,
@@ -703,6 +970,9 @@ function createMutationFactory(toSilk, isSchema) {
703
970
  }
704
971
  function createSubscriptionFactory(toSilk, isSchema) {
705
972
  return (output, resolveOrOptions) => {
973
+ if (resolveOrOptions == null) {
974
+ return new SubscriptionChainFactory({ output: toSilk(output) });
975
+ }
706
976
  const options = getSubscriptionOptions(resolveOrOptions);
707
977
  return subscription(toSilk(output), {
708
978
  ...options,
@@ -746,31 +1016,38 @@ import {
746
1016
  isObjectType as isObjectType2,
747
1017
  isUnionType as isUnionType2
748
1018
  } from "graphql";
749
- function inputToArgs(input) {
1019
+ function inputToArgs(input, options) {
750
1020
  if (input === void 0) return void 0;
751
1021
  if (isSilk(input)) {
752
1022
  let inputType = getGraphQLType(input);
753
1023
  if (isNonNullType(inputType)) inputType = inputType.ofType;
754
1024
  if (isObjectType2(inputType)) {
755
- return mapValue(
756
- inputType.toConfig().fields,
757
- (it) => toInputFieldConfig(it)
758
- );
1025
+ return mapValue(inputType.toConfig().fields, (it, key) => {
1026
+ let fieldName;
1027
+ if (options?.fieldName) {
1028
+ fieldName = `${pascalCase(options.fieldName)}${pascalCase(key)}`;
1029
+ }
1030
+ return toInputFieldConfig(it, { fieldName });
1031
+ });
759
1032
  }
760
1033
  throw new Error(`Cannot convert ${inputType.toString()} to input type`);
761
1034
  }
762
1035
  const args = {};
763
1036
  Object.entries(input).forEach(([name, field2]) => {
764
1037
  tryIn(() => {
1038
+ let fieldName;
1039
+ if (options?.fieldName) {
1040
+ fieldName = `${pascalCase(options.fieldName)}${pascalCase(name)}`;
1041
+ }
765
1042
  args[name] = {
766
1043
  ...field2,
767
- type: ensureInputType(field2)
1044
+ type: ensureInputType(field2, { fieldName })
768
1045
  };
769
1046
  }, name);
770
1047
  });
771
1048
  return args;
772
1049
  }
773
- function ensureInputType(silkOrType) {
1050
+ function ensureInputType(silkOrType, options) {
774
1051
  const gqlType = (() => {
775
1052
  if (isSilk(silkOrType)) {
776
1053
  return getGraphQLType(silkOrType);
@@ -780,48 +1057,56 @@ function ensureInputType(silkOrType) {
780
1057
  if (isUnionType2(gqlType))
781
1058
  throw new Error(`Cannot convert union type ${gqlType.name} to input type`);
782
1059
  if (isNonNullType(gqlType)) {
783
- return new GraphQLNonNull2(ensureInputType(gqlType.ofType));
1060
+ return new GraphQLNonNull2(ensureInputType(gqlType.ofType, options));
784
1061
  }
785
1062
  if (isListType(gqlType)) {
786
- return new GraphQLList2(ensureInputType(gqlType.ofType));
1063
+ return new GraphQLList2(ensureInputType(gqlType.ofType, options));
787
1064
  }
788
1065
  if (isObjectType2(gqlType) || isInterfaceType(gqlType))
789
- return ensureInputObjectType(gqlType);
1066
+ return ensureInputObjectType(gqlType, options);
790
1067
  return gqlType;
791
1068
  }
792
- function ensureInputObjectType(object) {
1069
+ function ensureInputObjectType(object, options) {
793
1070
  if (isInputObjectType(object)) return object;
794
1071
  const existing = weaverContext.inputMap?.get(object);
795
1072
  if (existing != null) return existing;
796
- const {
797
- astNode: _,
798
- extensionASTNodes: __,
799
- fields,
800
- ...config
801
- } = object.toConfig();
802
- const getInputObjectName = weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((name) => name);
1073
+ const { astNode, extensionASTNodes, fields, ...config } = object.toConfig();
1074
+ let name = object.name;
1075
+ if (name === LoomObjectType.AUTO_ALIASING) {
1076
+ name = `${pascalCase(options?.fieldName ?? "")}Input`;
1077
+ }
1078
+ const getInputObjectName = weaverContext.getConfig("gqloom.core.schema")?.getInputObjectName ?? ((n) => n);
1079
+ name = getInputObjectName(name);
803
1080
  const input = new GraphQLInputObjectType({
804
1081
  ...config,
805
- name: getInputObjectName(object.name),
1082
+ name,
806
1083
  fields: provideWeaverContext.inherit(
807
- () => mapValue(fields, (it) => toInputFieldConfig(it))
1084
+ () => mapValue(
1085
+ fields,
1086
+ (it, key) => toInputFieldConfig(it, {
1087
+ fieldName: inputFieldName(name) + pascalCase(key)
1088
+ })
1089
+ )
808
1090
  )
809
1091
  });
810
1092
  weaverContext.inputMap?.set(object, input);
811
1093
  return input;
812
1094
  }
813
- function toInputFieldConfig({
814
- astNode: _,
815
- resolve: _1,
816
- ...config
817
- }) {
818
- return { ...config, type: ensureInputType(config.type) };
1095
+ function toInputFieldConfig({ astNode, resolve, ...config }, options) {
1096
+ return { ...config, type: ensureInputType(config.type, options) };
1097
+ }
1098
+ function inputFieldName(name) {
1099
+ while (name.endsWith("Input")) {
1100
+ name = name.slice(0, -"Input".length);
1101
+ }
1102
+ return name;
819
1103
  }
820
1104
 
821
1105
  // src/schema/object.ts
822
- var LoomObjectType = class extends GraphQLObjectType {
1106
+ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
823
1107
  extraFields = /* @__PURE__ */ new Map();
824
1108
  hiddenFields = /* @__PURE__ */ new Set();
1109
+ static AUTO_ALIASING = "__gqloom_auto_aliasing";
825
1110
  weaverContext;
826
1111
  resolverOptions;
827
1112
  constructor(objectOrGetter, options = {}) {
@@ -838,6 +1123,28 @@ var LoomObjectType = class extends GraphQLObjectType {
838
1123
  super(config);
839
1124
  this.resolverOptions = options.resolverOptions;
840
1125
  this.weaverContext = options.weaverContext ?? initWeaverContext();
1126
+ if (this.name !== _LoomObjectType.AUTO_ALIASING) {
1127
+ this.hasExplicitName = true;
1128
+ }
1129
+ }
1130
+ hasExplicitName;
1131
+ _aliases = [];
1132
+ get aliases() {
1133
+ return this._aliases;
1134
+ }
1135
+ addAlias(name) {
1136
+ if (this.hasExplicitName) return;
1137
+ this._aliases.push(name);
1138
+ this.renameByAliases();
1139
+ }
1140
+ renameByAliases() {
1141
+ let name;
1142
+ for (const alias of this.aliases) {
1143
+ if (name === void 0 || alias.length < name.length) {
1144
+ name = alias;
1145
+ }
1146
+ }
1147
+ if (name) this.name = name;
841
1148
  }
842
1149
  hideField(name) {
843
1150
  this.hiddenFields.add(name);
@@ -855,8 +1162,8 @@ var LoomObjectType = class extends GraphQLObjectType {
855
1162
  extraFieldMap;
856
1163
  getFields() {
857
1164
  const fieldsBySuper = super.getFields();
858
- Object.values(fieldsBySuper).forEach(
859
- (field2) => field2.type = this.getCacheType(field2.type)
1165
+ Object.entries(fieldsBySuper).forEach(
1166
+ ([fieldName, field2]) => field2.type = this.getCacheType(field2.type, fieldName)
860
1167
  );
861
1168
  const extraFields = provideWeaverContext(
862
1169
  () => defineFieldMap(this.mapToFieldConfig(this.extraFields)),
@@ -877,17 +1184,22 @@ var LoomObjectType = class extends GraphQLObjectType {
877
1184
  mapToFieldConfig(map) {
878
1185
  const record = {};
879
1186
  for (const [name, field2] of map.entries()) {
880
- record[name] = this.toFieldConfig(field2);
1187
+ record[name] = this.toFieldConfig(field2, name);
881
1188
  }
882
1189
  return record;
883
1190
  }
884
- toFieldConfig(field2) {
1191
+ toFieldConfig(field2, fieldName) {
885
1192
  try {
886
- const outputType = this.getCacheType(getGraphQLType(field2.output));
1193
+ const outputType = this.getCacheType(
1194
+ getGraphQLType(field2.output),
1195
+ fieldName
1196
+ );
887
1197
  return {
888
1198
  ...extract(field2),
889
1199
  type: outputType,
890
- args: inputToArgs(field2.input),
1200
+ args: inputToArgs(field2.input, {
1201
+ fieldName: fieldName ? parentName(this.name) + fieldName : void 0
1202
+ }),
891
1203
  ...this.provideForResolve(field2),
892
1204
  ...this.provideForSubscribe(field2)
893
1205
  };
@@ -920,8 +1232,8 @@ var LoomObjectType = class extends GraphQLObjectType {
920
1232
  )
921
1233
  };
922
1234
  }
923
- getCacheType(gqlType) {
924
- return getCacheType(gqlType, this.options);
1235
+ getCacheType(gqlType, fieldName) {
1236
+ return getCacheType(gqlType, { ...this.options, fieldName, parent: this });
925
1237
  }
926
1238
  get options() {
927
1239
  const { resolverOptions, weaverContext: weaverContext2 } = this;
@@ -967,6 +1279,11 @@ function defineArguments(args) {
967
1279
  astNode: argConfig.astNode
968
1280
  }));
969
1281
  }
1282
+ var OPERATION_OBJECT_NAMES = /* @__PURE__ */ new Set([
1283
+ "Query",
1284
+ "Mutation",
1285
+ "Subscription"
1286
+ ]);
970
1287
  function getCacheType(gqlType, options = {}) {
971
1288
  const context = options.weaverContext ?? weaverContext;
972
1289
  if (gqlType instanceof LoomObjectType) return gqlType;
@@ -975,6 +1292,11 @@ function getCacheType(gqlType, options = {}) {
975
1292
  if (gqlObject != null) return gqlObject;
976
1293
  const loomObject = new LoomObjectType(gqlType, options);
977
1294
  context.loomObjectMap?.set(gqlType, loomObject);
1295
+ if (options.fieldName && options.parent) {
1296
+ loomObject.addAlias(
1297
+ parentName(options.parent.name) + pascalCase(options.fieldName)
1298
+ );
1299
+ }
978
1300
  return loomObject;
979
1301
  } else if (isListType2(gqlType)) {
980
1302
  return new GraphQLList3(getCacheType(gqlType.ofType, options));
@@ -995,8 +1317,12 @@ function getCacheType(gqlType, options = {}) {
995
1317
  }
996
1318
  return gqlType;
997
1319
  }
1320
+ function parentName(name) {
1321
+ if (OPERATION_OBJECT_NAMES.has(name)) name = "";
1322
+ return name;
1323
+ }
998
1324
 
999
- // src/schema/schema-vendor-weaver.ts
1325
+ // src/schema/schema-weaver.ts
1000
1326
  function isSchemaVendorWeaver(some) {
1001
1327
  if (typeof some !== "object" && typeof some !== "function") return false;
1002
1328
  if (!("getGraphQLType" in some) || typeof some.getGraphQLType !== "function")
@@ -1005,7 +1331,7 @@ function isSchemaVendorWeaver(some) {
1005
1331
  return true;
1006
1332
  }
1007
1333
 
1008
- // src/schema/schema-weaver.ts
1334
+ // src/schema/schema-loom.ts
1009
1335
  import {
1010
1336
  GraphQLSchema,
1011
1337
  isEnumType as isEnumType2,
@@ -1013,7 +1339,7 @@ import {
1013
1339
  isObjectType as isObjectType4,
1014
1340
  isUnionType as isUnionType4
1015
1341
  } from "graphql";
1016
- var SchemaWeaver = class _SchemaWeaver {
1342
+ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
1017
1343
  query;
1018
1344
  mutation;
1019
1345
  subscription;
@@ -1180,12 +1506,12 @@ var SchemaWeaver = class _SchemaWeaver {
1180
1506
  }
1181
1507
  /**
1182
1508
  * Weave a GraphQL Schema from resolvers
1183
- * @param inputs Resolvers, Global Middlewares or WeaverConfigs
1184
- * @returns GraphQ LSchema
1509
+ * @param inputs Resolvers, Global Middlewares, WeaverConfigs Or SchemaWeaver
1510
+ * @returns GraphQL Schema
1185
1511
  */
1186
1512
  static weave(...inputs) {
1187
- const { context, configs, middlewares, resolvers, silks, weavers } = _SchemaWeaver.optionsFrom(...inputs);
1188
- const weaver = new _SchemaWeaver({}, context);
1513
+ const { context, configs, middlewares, resolvers, silks, weavers } = _GraphQLSchemaLoom.optionsFrom(...inputs);
1514
+ const weaver = new _GraphQLSchemaLoom({}, context);
1189
1515
  configs.forEach((it) => weaver.setConfig(it));
1190
1516
  weavers.forEach((it) => weaver.addVendor(it));
1191
1517
  middlewares.forEach((it) => weaver.use(it));
@@ -1194,7 +1520,7 @@ var SchemaWeaver = class _SchemaWeaver {
1194
1520
  return weaver.weaveGraphQLSchema();
1195
1521
  }
1196
1522
  };
1197
- var weave = SchemaWeaver.weave;
1523
+ var weave = GraphQLSchemaLoom.weave;
1198
1524
 
1199
1525
  // src/schema/interface.ts
1200
1526
  import {
@@ -1227,22 +1553,29 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
1227
1553
  }
1228
1554
  export {
1229
1555
  ContextMemoization,
1556
+ EasyDataLoader,
1557
+ GraphQLSchemaLoom,
1230
1558
  LoomObjectType,
1559
+ OPERATION_OBJECT_NAMES,
1231
1560
  ResolverOptionsMap,
1232
1561
  symbols_exports as SYMBOLS,
1233
- SchemaWeaver,
1234
1562
  applyMiddlewares,
1235
1563
  baseResolver,
1564
+ capitalize,
1236
1565
  collectName,
1237
1566
  collectNames,
1238
1567
  compose,
1568
+ createField,
1239
1569
  createFieldFactory,
1240
1570
  createInputParser,
1241
1571
  createLoom,
1242
1572
  createMemoization,
1573
+ createMutation,
1243
1574
  createMutationFactory,
1575
+ createQuery,
1244
1576
  createQueryFactory,
1245
1577
  createResolverFactory,
1578
+ createSubscription,
1246
1579
  createSubscriptionFactory,
1247
1580
  deepMerge,
1248
1581
  defaultSubscriptionResolve,
@@ -1273,6 +1606,7 @@ export {
1273
1606
  onlyMemoization,
1274
1607
  parseInputValue,
1275
1608
  parseSilk,
1609
+ pascalCase,
1276
1610
  provideWeaverContext,
1277
1611
  query,
1278
1612
  resolver,