@graphql-codegen/visitor-plugin-common 6.0.0-alpha-20250509134235-30ac8930f49f44ab10e6b7dcdd7f12a67bfa9fc4 → 6.0.0-alpha-20250522111047-b446e84383ba57bc9f768b55db1e0ccf958a27c3

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.
@@ -599,6 +599,9 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
599
599
  }
600
600
  return '';
601
601
  }
602
+ // FIXME: this Name method causes a lot of type inconsistencies
603
+ // because the type of nodes no longer matches the `graphql-js` types
604
+ // So, we should update this and remove any relevant `as any as string` or `as unknown as string`
602
605
  Name(node) {
603
606
  return node.value;
604
607
  }
@@ -640,88 +643,96 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
640
643
  FieldDefinition(node, key, parent) {
641
644
  const hasArguments = node.arguments && node.arguments.length > 0;
642
645
  const declarationKind = 'type';
643
- return (parentName, avoidResolverOptionals) => {
644
- const original = parent[key];
645
- const parentType = this.schema.getType(parentName);
646
- const meta = {};
647
- if (this._federation.skipField({ fieldNode: original, parentType })) {
648
- return { value: null, meta };
649
- }
650
- const contextType = this.getContextType(parentName, node);
651
- let argsType = hasArguments
652
- ? this.convertName(parentName +
653
- (this.config.addUnderscoreToArgsType ? '_' : '') +
654
- this.convertName(node.name, {
655
- useTypesPrefix: false,
656
- useTypesSuffix: false,
657
- }) +
658
- 'Args', {
659
- useTypesPrefix: true,
660
- }, true)
661
- : null;
662
- const avoidInputsOptionals = this.config.avoidOptionals.inputValue;
663
- if (argsType !== null) {
664
- const argsToForceRequire = original.arguments.filter(arg => !!arg.defaultValue || arg.type.kind === 'NonNullType');
665
- if (argsToForceRequire.length > 0) {
666
- argsType = this.applyRequireFields(argsType, argsToForceRequire);
646
+ const original = parent[key];
647
+ return {
648
+ node: original,
649
+ printContent: (parentNode, avoidResolverOptionals) => {
650
+ const parentName = parentNode.name;
651
+ const parentType = this.schema.getType(parentName);
652
+ const meta = {};
653
+ const typeName = node.name;
654
+ const fieldsToGenerate = this._federation.findFieldNodesToGenerate({ node: parentNode });
655
+ const shouldGenerateField = fieldsToGenerate.some(field => field.name.value === typeName) ||
656
+ this._federation.isResolveReferenceField(node);
657
+ if (!shouldGenerateField) {
658
+ return { value: null, meta };
667
659
  }
668
- else if (original.arguments.length > 0 && avoidInputsOptionals !== true) {
669
- argsType = this.applyOptionalFields(argsType, original.arguments);
660
+ const contextType = this.getContextType(parentName, node);
661
+ let argsType = hasArguments
662
+ ? this.convertName(parentName +
663
+ (this.config.addUnderscoreToArgsType ? '_' : '') +
664
+ this.convertName(typeName, {
665
+ useTypesPrefix: false,
666
+ useTypesSuffix: false,
667
+ }) +
668
+ 'Args', {
669
+ useTypesPrefix: true,
670
+ }, true)
671
+ : null;
672
+ const avoidInputsOptionals = this.config.avoidOptionals.inputValue;
673
+ if (argsType !== null) {
674
+ const argsToForceRequire = original.arguments.filter(arg => !!arg.defaultValue || arg.type.kind === 'NonNullType');
675
+ if (argsToForceRequire.length > 0) {
676
+ argsType = this.applyRequireFields(argsType, argsToForceRequire);
677
+ }
678
+ else if (original.arguments.length > 0 && avoidInputsOptionals !== true) {
679
+ argsType = this.applyOptionalFields(argsType, original.arguments);
680
+ }
670
681
  }
671
- }
672
- const parentTypeSignature = this._federation.transformFieldParentType({
673
- fieldNode: original,
674
- parentType,
675
- parentTypeSignature: this.getParentTypeForSignature(node),
676
- federationTypeSignature: 'FederationType',
677
- });
678
- const { mappedTypeKey, resolverType } = (() => {
679
- const baseType = (0, utils_js_1.getBaseTypeNode)(original.type);
680
- const realType = baseType.name.value;
681
- const typeToUse = this.getTypeToUse(realType);
682
- /**
683
- * Turns GraphQL type to TypeScript types (`mappedType`) e.g.
684
- * - String! -> ResolversTypes['String']>
685
- * - String -> Maybe<ResolversTypes['String']>
686
- * - [String] -> Maybe<Array<Maybe<ResolversTypes['String']>>>
687
- * - [String!]! -> Array<ResolversTypes['String']>
688
- */
689
- const mappedType = this._variablesTransformer.wrapAstTypeWithModifiers(typeToUse, original.type);
690
- const subscriptionType = this._schema.getSubscriptionType();
691
- const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
692
- if (isSubscriptionType) {
682
+ const parentTypeSignature = this._federation.transformFieldParentType({
683
+ fieldNode: original,
684
+ parentType,
685
+ parentTypeSignature: this.getParentTypeForSignature(node),
686
+ federationTypeSignature: 'FederationType',
687
+ });
688
+ const { mappedTypeKey, resolverType } = (() => {
689
+ const baseType = (0, utils_js_1.getBaseTypeNode)(original.type);
690
+ const realType = baseType.name.value;
691
+ const typeToUse = this.getTypeToUse(realType);
692
+ /**
693
+ * Turns GraphQL type to TypeScript types (`mappedType`) e.g.
694
+ * - String! -> ResolversTypes['String']>
695
+ * - String -> Maybe<ResolversTypes['String']>
696
+ * - [String] -> Maybe<Array<Maybe<ResolversTypes['String']>>>
697
+ * - [String!]! -> Array<ResolversTypes['String']>
698
+ */
699
+ const mappedType = this._variablesTransformer.wrapAstTypeWithModifiers(typeToUse, original.type);
700
+ const subscriptionType = this._schema.getSubscriptionType();
701
+ const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
702
+ if (isSubscriptionType) {
703
+ return {
704
+ mappedTypeKey: `${mappedType}, "${typeName}"`,
705
+ resolverType: 'SubscriptionResolver',
706
+ };
707
+ }
708
+ const directiveMappings = node.directives
709
+ ?.map(directive => this._directiveResolverMappings[directive.name])
710
+ .filter(Boolean)
711
+ .reverse() ?? [];
693
712
  return {
694
- mappedTypeKey: `${mappedType}, "${node.name}"`,
695
- resolverType: 'SubscriptionResolver',
713
+ mappedTypeKey: mappedType,
714
+ resolverType: directiveMappings[0] ?? 'Resolver',
696
715
  };
716
+ })();
717
+ const signature = {
718
+ name: typeName,
719
+ modifier: avoidResolverOptionals ? '' : '?',
720
+ type: resolverType,
721
+ genericTypes: [mappedTypeKey, parentTypeSignature, contextType, argsType].filter(f => f),
722
+ };
723
+ if (this._federation.isResolveReferenceField(node)) {
724
+ if (!this._federation.getMeta()[parentType.name].hasResolveReference) {
725
+ return { value: '', meta };
726
+ }
727
+ signature.type = 'ReferenceResolver';
728
+ signature.genericTypes = [mappedTypeKey, parentTypeSignature, contextType];
729
+ meta.federation = { isResolveReference: true };
697
730
  }
698
- const directiveMappings = node.directives
699
- ?.map(directive => this._directiveResolverMappings[directive.name])
700
- .filter(Boolean)
701
- .reverse() ?? [];
702
731
  return {
703
- mappedTypeKey: mappedType,
704
- resolverType: directiveMappings[0] ?? 'Resolver',
732
+ value: (0, utils_js_1.indent)(`${signature.name}${signature.modifier}: ${signature.type}<${signature.genericTypes.join(', ')}>${this.getPunctuation(declarationKind)}`),
733
+ meta,
705
734
  };
706
- })();
707
- const signature = {
708
- name: node.name,
709
- modifier: avoidResolverOptionals ? '' : '?',
710
- type: resolverType,
711
- genericTypes: [mappedTypeKey, parentTypeSignature, contextType, argsType].filter(f => f),
712
- };
713
- if (this._federation.isResolveReferenceField(node)) {
714
- if (!this._federation.getMeta()[parentType.name].hasResolveReference) {
715
- return { value: '', meta };
716
- }
717
- signature.type = 'ReferenceResolver';
718
- signature.genericTypes = [mappedTypeKey, parentTypeSignature, contextType];
719
- meta.federation = { isResolveReference: true };
720
- }
721
- return {
722
- value: (0, utils_js_1.indent)(`${signature.name}${signature.modifier}: ${signature.type}<${signature.genericTypes.join(', ')}>${this.getPunctuation(declarationKind)}`),
723
- meta,
724
- };
735
+ },
725
736
  };
726
737
  }
727
738
  getFieldContextType(parentName, node) {
@@ -782,11 +793,15 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
782
793
  return `Partial<${argsType}>`;
783
794
  }
784
795
  ObjectTypeDefinition(node) {
796
+ const typeName = node.name;
797
+ const fieldsToGenerate = this._federation.findFieldNodesToGenerate({ node });
798
+ if (fieldsToGenerate.length === 0) {
799
+ return null;
800
+ }
785
801
  const declarationKind = 'type';
786
802
  const name = this.convertName(node, {
787
803
  suffix: this.config.resolverTypeSuffix,
788
804
  });
789
- const typeName = node.name;
790
805
  const parentType = this.getParentTypeToUse(typeName);
791
806
  const rootType = (() => {
792
807
  if (this.schema.getQueryType()?.name === typeName) {
@@ -800,15 +815,20 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
800
815
  }
801
816
  return false;
802
817
  })();
803
- const fieldsContent = node.fields.map(f => {
804
- return f(typeName, (rootType === 'query' && this.config.avoidOptionals.query) ||
818
+ const fieldsContent = node.fields
819
+ .map(({ printContent }) => {
820
+ return printContent(node, (rootType === 'query' && this.config.avoidOptionals.query) ||
805
821
  (rootType === 'mutation' && this.config.avoidOptionals.mutation) ||
806
822
  (rootType === 'subscription' && this.config.avoidOptionals.subscription) ||
807
823
  (rootType === false && this.config.avoidOptionals.resolvers)).value;
808
- });
824
+ })
825
+ .filter(v => v);
809
826
  if (!rootType && this._parsedSchemaMeta.typesWithIsTypeOf[typeName]) {
810
827
  fieldsContent.push((0, utils_js_1.indent)(`${this.config.internalResolversPrefix}isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>${this.getPunctuation(declarationKind)}`));
811
828
  }
829
+ if (fieldsContent.length === 0) {
830
+ return null;
831
+ }
812
832
  const genericTypes = [
813
833
  `ContextType = ${this.config.contextType.type}`,
814
834
  this.transformParentGenericType(parentType),
@@ -968,7 +988,7 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
968
988
  ];
969
989
  // An Interface in Federation may have the additional __resolveReference resolver, if resolvable.
970
990
  // So, we filter out the normal fields declared on the Interface and add the __resolveReference resolver.
971
- const fields = node.fields.map(f => f(typeName, this.config.avoidOptionals.resolvers));
991
+ const fields = node.fields.map(({ printContent }) => printContent(node, this.config.avoidOptionals.resolvers));
972
992
  for (const field of fields) {
973
993
  if (field.meta.federation?.isResolveReference) {
974
994
  blockFields.push(field.value);
@@ -595,6 +595,9 @@ export class BaseResolversVisitor extends BaseVisitor {
595
595
  }
596
596
  return '';
597
597
  }
598
+ // FIXME: this Name method causes a lot of type inconsistencies
599
+ // because the type of nodes no longer matches the `graphql-js` types
600
+ // So, we should update this and remove any relevant `as any as string` or `as unknown as string`
598
601
  Name(node) {
599
602
  return node.value;
600
603
  }
@@ -636,88 +639,96 @@ export class BaseResolversVisitor extends BaseVisitor {
636
639
  FieldDefinition(node, key, parent) {
637
640
  const hasArguments = node.arguments && node.arguments.length > 0;
638
641
  const declarationKind = 'type';
639
- return (parentName, avoidResolverOptionals) => {
640
- const original = parent[key];
641
- const parentType = this.schema.getType(parentName);
642
- const meta = {};
643
- if (this._federation.skipField({ fieldNode: original, parentType })) {
644
- return { value: null, meta };
645
- }
646
- const contextType = this.getContextType(parentName, node);
647
- let argsType = hasArguments
648
- ? this.convertName(parentName +
649
- (this.config.addUnderscoreToArgsType ? '_' : '') +
650
- this.convertName(node.name, {
651
- useTypesPrefix: false,
652
- useTypesSuffix: false,
653
- }) +
654
- 'Args', {
655
- useTypesPrefix: true,
656
- }, true)
657
- : null;
658
- const avoidInputsOptionals = this.config.avoidOptionals.inputValue;
659
- if (argsType !== null) {
660
- const argsToForceRequire = original.arguments.filter(arg => !!arg.defaultValue || arg.type.kind === 'NonNullType');
661
- if (argsToForceRequire.length > 0) {
662
- argsType = this.applyRequireFields(argsType, argsToForceRequire);
642
+ const original = parent[key];
643
+ return {
644
+ node: original,
645
+ printContent: (parentNode, avoidResolverOptionals) => {
646
+ const parentName = parentNode.name;
647
+ const parentType = this.schema.getType(parentName);
648
+ const meta = {};
649
+ const typeName = node.name;
650
+ const fieldsToGenerate = this._federation.findFieldNodesToGenerate({ node: parentNode });
651
+ const shouldGenerateField = fieldsToGenerate.some(field => field.name.value === typeName) ||
652
+ this._federation.isResolveReferenceField(node);
653
+ if (!shouldGenerateField) {
654
+ return { value: null, meta };
663
655
  }
664
- else if (original.arguments.length > 0 && avoidInputsOptionals !== true) {
665
- argsType = this.applyOptionalFields(argsType, original.arguments);
656
+ const contextType = this.getContextType(parentName, node);
657
+ let argsType = hasArguments
658
+ ? this.convertName(parentName +
659
+ (this.config.addUnderscoreToArgsType ? '_' : '') +
660
+ this.convertName(typeName, {
661
+ useTypesPrefix: false,
662
+ useTypesSuffix: false,
663
+ }) +
664
+ 'Args', {
665
+ useTypesPrefix: true,
666
+ }, true)
667
+ : null;
668
+ const avoidInputsOptionals = this.config.avoidOptionals.inputValue;
669
+ if (argsType !== null) {
670
+ const argsToForceRequire = original.arguments.filter(arg => !!arg.defaultValue || arg.type.kind === 'NonNullType');
671
+ if (argsToForceRequire.length > 0) {
672
+ argsType = this.applyRequireFields(argsType, argsToForceRequire);
673
+ }
674
+ else if (original.arguments.length > 0 && avoidInputsOptionals !== true) {
675
+ argsType = this.applyOptionalFields(argsType, original.arguments);
676
+ }
666
677
  }
667
- }
668
- const parentTypeSignature = this._federation.transformFieldParentType({
669
- fieldNode: original,
670
- parentType,
671
- parentTypeSignature: this.getParentTypeForSignature(node),
672
- federationTypeSignature: 'FederationType',
673
- });
674
- const { mappedTypeKey, resolverType } = (() => {
675
- const baseType = getBaseTypeNode(original.type);
676
- const realType = baseType.name.value;
677
- const typeToUse = this.getTypeToUse(realType);
678
- /**
679
- * Turns GraphQL type to TypeScript types (`mappedType`) e.g.
680
- * - String! -> ResolversTypes['String']>
681
- * - String -> Maybe<ResolversTypes['String']>
682
- * - [String] -> Maybe<Array<Maybe<ResolversTypes['String']>>>
683
- * - [String!]! -> Array<ResolversTypes['String']>
684
- */
685
- const mappedType = this._variablesTransformer.wrapAstTypeWithModifiers(typeToUse, original.type);
686
- const subscriptionType = this._schema.getSubscriptionType();
687
- const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
688
- if (isSubscriptionType) {
678
+ const parentTypeSignature = this._federation.transformFieldParentType({
679
+ fieldNode: original,
680
+ parentType,
681
+ parentTypeSignature: this.getParentTypeForSignature(node),
682
+ federationTypeSignature: 'FederationType',
683
+ });
684
+ const { mappedTypeKey, resolverType } = (() => {
685
+ const baseType = getBaseTypeNode(original.type);
686
+ const realType = baseType.name.value;
687
+ const typeToUse = this.getTypeToUse(realType);
688
+ /**
689
+ * Turns GraphQL type to TypeScript types (`mappedType`) e.g.
690
+ * - String! -> ResolversTypes['String']>
691
+ * - String -> Maybe<ResolversTypes['String']>
692
+ * - [String] -> Maybe<Array<Maybe<ResolversTypes['String']>>>
693
+ * - [String!]! -> Array<ResolversTypes['String']>
694
+ */
695
+ const mappedType = this._variablesTransformer.wrapAstTypeWithModifiers(typeToUse, original.type);
696
+ const subscriptionType = this._schema.getSubscriptionType();
697
+ const isSubscriptionType = subscriptionType && subscriptionType.name === parentName;
698
+ if (isSubscriptionType) {
699
+ return {
700
+ mappedTypeKey: `${mappedType}, "${typeName}"`,
701
+ resolverType: 'SubscriptionResolver',
702
+ };
703
+ }
704
+ const directiveMappings = node.directives
705
+ ?.map(directive => this._directiveResolverMappings[directive.name])
706
+ .filter(Boolean)
707
+ .reverse() ?? [];
689
708
  return {
690
- mappedTypeKey: `${mappedType}, "${node.name}"`,
691
- resolverType: 'SubscriptionResolver',
709
+ mappedTypeKey: mappedType,
710
+ resolverType: directiveMappings[0] ?? 'Resolver',
692
711
  };
712
+ })();
713
+ const signature = {
714
+ name: typeName,
715
+ modifier: avoidResolverOptionals ? '' : '?',
716
+ type: resolverType,
717
+ genericTypes: [mappedTypeKey, parentTypeSignature, contextType, argsType].filter(f => f),
718
+ };
719
+ if (this._federation.isResolveReferenceField(node)) {
720
+ if (!this._federation.getMeta()[parentType.name].hasResolveReference) {
721
+ return { value: '', meta };
722
+ }
723
+ signature.type = 'ReferenceResolver';
724
+ signature.genericTypes = [mappedTypeKey, parentTypeSignature, contextType];
725
+ meta.federation = { isResolveReference: true };
693
726
  }
694
- const directiveMappings = node.directives
695
- ?.map(directive => this._directiveResolverMappings[directive.name])
696
- .filter(Boolean)
697
- .reverse() ?? [];
698
727
  return {
699
- mappedTypeKey: mappedType,
700
- resolverType: directiveMappings[0] ?? 'Resolver',
728
+ value: indent(`${signature.name}${signature.modifier}: ${signature.type}<${signature.genericTypes.join(', ')}>${this.getPunctuation(declarationKind)}`),
729
+ meta,
701
730
  };
702
- })();
703
- const signature = {
704
- name: node.name,
705
- modifier: avoidResolverOptionals ? '' : '?',
706
- type: resolverType,
707
- genericTypes: [mappedTypeKey, parentTypeSignature, contextType, argsType].filter(f => f),
708
- };
709
- if (this._federation.isResolveReferenceField(node)) {
710
- if (!this._federation.getMeta()[parentType.name].hasResolveReference) {
711
- return { value: '', meta };
712
- }
713
- signature.type = 'ReferenceResolver';
714
- signature.genericTypes = [mappedTypeKey, parentTypeSignature, contextType];
715
- meta.federation = { isResolveReference: true };
716
- }
717
- return {
718
- value: indent(`${signature.name}${signature.modifier}: ${signature.type}<${signature.genericTypes.join(', ')}>${this.getPunctuation(declarationKind)}`),
719
- meta,
720
- };
731
+ },
721
732
  };
722
733
  }
723
734
  getFieldContextType(parentName, node) {
@@ -778,11 +789,15 @@ export class BaseResolversVisitor extends BaseVisitor {
778
789
  return `Partial<${argsType}>`;
779
790
  }
780
791
  ObjectTypeDefinition(node) {
792
+ const typeName = node.name;
793
+ const fieldsToGenerate = this._federation.findFieldNodesToGenerate({ node });
794
+ if (fieldsToGenerate.length === 0) {
795
+ return null;
796
+ }
781
797
  const declarationKind = 'type';
782
798
  const name = this.convertName(node, {
783
799
  suffix: this.config.resolverTypeSuffix,
784
800
  });
785
- const typeName = node.name;
786
801
  const parentType = this.getParentTypeToUse(typeName);
787
802
  const rootType = (() => {
788
803
  if (this.schema.getQueryType()?.name === typeName) {
@@ -796,15 +811,20 @@ export class BaseResolversVisitor extends BaseVisitor {
796
811
  }
797
812
  return false;
798
813
  })();
799
- const fieldsContent = node.fields.map(f => {
800
- return f(typeName, (rootType === 'query' && this.config.avoidOptionals.query) ||
814
+ const fieldsContent = node.fields
815
+ .map(({ printContent }) => {
816
+ return printContent(node, (rootType === 'query' && this.config.avoidOptionals.query) ||
801
817
  (rootType === 'mutation' && this.config.avoidOptionals.mutation) ||
802
818
  (rootType === 'subscription' && this.config.avoidOptionals.subscription) ||
803
819
  (rootType === false && this.config.avoidOptionals.resolvers)).value;
804
- });
820
+ })
821
+ .filter(v => v);
805
822
  if (!rootType && this._parsedSchemaMeta.typesWithIsTypeOf[typeName]) {
806
823
  fieldsContent.push(indent(`${this.config.internalResolversPrefix}isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>${this.getPunctuation(declarationKind)}`));
807
824
  }
825
+ if (fieldsContent.length === 0) {
826
+ return null;
827
+ }
808
828
  const genericTypes = [
809
829
  `ContextType = ${this.config.contextType.type}`,
810
830
  this.transformParentGenericType(parentType),
@@ -964,7 +984,7 @@ export class BaseResolversVisitor extends BaseVisitor {
964
984
  ];
965
985
  // An Interface in Federation may have the additional __resolveReference resolver, if resolvable.
966
986
  // So, we filter out the normal fields declared on the Interface and add the __resolveReference resolver.
967
- const fields = node.fields.map(f => f(typeName, this.config.avoidOptionals.resolvers));
987
+ const fields = node.fields.map(({ printContent }) => printContent(node, this.config.avoidOptionals.resolvers));
968
988
  for (const field of fields) {
969
989
  if (field.meta.federation?.isResolveReference) {
970
990
  blockFields.push(field.value);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "6.0.0-alpha-20250509134235-30ac8930f49f44ab10e6b7dcdd7f12a67bfa9fc4",
3
+ "version": "6.0.0-alpha-20250522111047-b446e84383ba57bc9f768b55db1e0ccf958a27c3",
4
4
  "peerDependencies": {
5
5
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },
7
7
  "dependencies": {
8
8
  "@graphql-tools/optimize": "^2.0.0",
9
- "@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250509134235-30ac8930f49f44ab10e6b7dcdd7f12a67bfa9fc4",
9
+ "@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250522111047-b446e84383ba57bc9f768b55db1e0ccf958a27c3",
10
10
  "@graphql-tools/relay-operation-optimizer": "^7.0.0",
11
11
  "@graphql-tools/utils": "^10.0.0",
12
12
  "auto-bind": "~4.0.0",
@@ -31,7 +31,11 @@ export interface ParsedResolversConfig extends ParsedConfig {
31
31
  resolversNonOptionalTypename: ResolversNonOptionalTypenameConfig;
32
32
  avoidCheckingAbstractTypesRecursively: boolean;
33
33
  }
34
- type FieldDefinitionPrintFn = (parentName: string, avoidResolverOptionals: boolean) => {
34
+ export interface FieldDefinitionResult {
35
+ node: FieldDefinitionNode;
36
+ printContent: FieldDefinitionPrintFn;
37
+ }
38
+ type FieldDefinitionPrintFn = (parentNode: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode, avoidResolverOptionals: boolean) => {
35
39
  value: string | null;
36
40
  meta: {
37
41
  federation?: {
@@ -756,13 +760,13 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
756
760
  protected getParentTypeToUse(name: string): string;
757
761
  protected getParentTypeForSignature(_node: FieldDefinitionNode): string;
758
762
  protected transformParentGenericType(parentType: string): string;
759
- FieldDefinition(node: FieldDefinitionNode, key: string | number, parent: any): FieldDefinitionPrintFn;
763
+ FieldDefinition(node: FieldDefinitionNode, key: string | number, parent: any): FieldDefinitionResult;
760
764
  private getFieldContextType;
761
765
  private getContextType;
762
766
  private parseSchemaMeta;
763
767
  protected applyRequireFields(argsType: string, fields: InputValueDefinitionNode[]): string;
764
768
  protected applyOptionalFields(argsType: string, _fields: readonly InputValueDefinitionNode[]): string;
765
- ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string;
769
+ ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string | null;
766
770
  UnionTypeDefinition(node: UnionTypeDefinitionNode, key: string | number, parent: any): string;
767
771
  ScalarTypeDefinition(node: ScalarTypeDefinitionNode): string;
768
772
  DirectiveDefinition(node: DirectiveDefinitionNode, key: string | number, parent: any): string;
@@ -31,7 +31,11 @@ export interface ParsedResolversConfig extends ParsedConfig {
31
31
  resolversNonOptionalTypename: ResolversNonOptionalTypenameConfig;
32
32
  avoidCheckingAbstractTypesRecursively: boolean;
33
33
  }
34
- type FieldDefinitionPrintFn = (parentName: string, avoidResolverOptionals: boolean) => {
34
+ export interface FieldDefinitionResult {
35
+ node: FieldDefinitionNode;
36
+ printContent: FieldDefinitionPrintFn;
37
+ }
38
+ type FieldDefinitionPrintFn = (parentNode: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode, avoidResolverOptionals: boolean) => {
35
39
  value: string | null;
36
40
  meta: {
37
41
  federation?: {
@@ -756,13 +760,13 @@ export declare class BaseResolversVisitor<TRawConfig extends RawResolversConfig
756
760
  protected getParentTypeToUse(name: string): string;
757
761
  protected getParentTypeForSignature(_node: FieldDefinitionNode): string;
758
762
  protected transformParentGenericType(parentType: string): string;
759
- FieldDefinition(node: FieldDefinitionNode, key: string | number, parent: any): FieldDefinitionPrintFn;
763
+ FieldDefinition(node: FieldDefinitionNode, key: string | number, parent: any): FieldDefinitionResult;
760
764
  private getFieldContextType;
761
765
  private getContextType;
762
766
  private parseSchemaMeta;
763
767
  protected applyRequireFields(argsType: string, fields: InputValueDefinitionNode[]): string;
764
768
  protected applyOptionalFields(argsType: string, _fields: readonly InputValueDefinitionNode[]): string;
765
- ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string;
769
+ ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string | null;
766
770
  UnionTypeDefinition(node: UnionTypeDefinitionNode, key: string | number, parent: any): string;
767
771
  ScalarTypeDefinition(node: ScalarTypeDefinitionNode): string;
768
772
  DirectiveDefinition(node: DirectiveDefinitionNode, key: string | number, parent: any): string;