@graphql-codegen/visitor-plugin-common 6.2.0 → 6.2.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.
|
@@ -683,7 +683,20 @@ class SelectionSetToObject {
|
|
|
683
683
|
buildParentFieldName(typeName, parentName) {
|
|
684
684
|
// queries/mutations/fragments are guaranteed to be unique type names,
|
|
685
685
|
// so we can skip affixing the field names with typeName
|
|
686
|
-
|
|
686
|
+
if (operationTypes.includes(typeName)) {
|
|
687
|
+
return parentName;
|
|
688
|
+
}
|
|
689
|
+
// When the parent schema type is an interface, use the interface name instead of the concrete type
|
|
690
|
+
// BUT only if we're not inside a fragment (fragments explicitly target specific types)
|
|
691
|
+
const schemaType = this._schema.getType(typeName);
|
|
692
|
+
const isInFragment = parentName.includes('Fragment');
|
|
693
|
+
if ((0, graphql_1.isObjectType)(schemaType) &&
|
|
694
|
+
this._parentSchemaType &&
|
|
695
|
+
(0, graphql_1.isInterfaceType)(this._parentSchemaType) &&
|
|
696
|
+
!isInFragment) {
|
|
697
|
+
return `${parentName}_${this._parentSchemaType.name}`;
|
|
698
|
+
}
|
|
699
|
+
return `${parentName}_${typeName}`;
|
|
687
700
|
}
|
|
688
701
|
}
|
|
689
702
|
exports.SelectionSetToObject = SelectionSetToObject;
|
|
@@ -679,7 +679,20 @@ export class SelectionSetToObject {
|
|
|
679
679
|
buildParentFieldName(typeName, parentName) {
|
|
680
680
|
// queries/mutations/fragments are guaranteed to be unique type names,
|
|
681
681
|
// so we can skip affixing the field names with typeName
|
|
682
|
-
|
|
682
|
+
if (operationTypes.includes(typeName)) {
|
|
683
|
+
return parentName;
|
|
684
|
+
}
|
|
685
|
+
// When the parent schema type is an interface, use the interface name instead of the concrete type
|
|
686
|
+
// BUT only if we're not inside a fragment (fragments explicitly target specific types)
|
|
687
|
+
const schemaType = this._schema.getType(typeName);
|
|
688
|
+
const isInFragment = parentName.includes('Fragment');
|
|
689
|
+
if (isObjectType(schemaType) &&
|
|
690
|
+
this._parentSchemaType &&
|
|
691
|
+
isInterfaceType(this._parentSchemaType) &&
|
|
692
|
+
!isInFragment) {
|
|
693
|
+
return `${parentName}_${this._parentSchemaType.name}`;
|
|
694
|
+
}
|
|
695
|
+
return `${parentName}_${typeName}`;
|
|
683
696
|
}
|
|
684
697
|
}
|
|
685
698
|
function formatUnion(members) {
|