@graphql-codegen/visitor-plugin-common 6.2.0 → 6.2.2-alpha-20251208101827-e43ab73e4201f13f8df28eacf0c3fe4a7300f3e8
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
|
+
const schemaType = this._schema.getType(typeName);
|
|
690
|
+
// Check if current selection set has fragments (e.g., "... AppNotificationFragment" or "... on AppNotification")
|
|
691
|
+
const hasFragment = this._selectionSet?.selections?.some(selection => selection.kind === graphql_1.Kind.INLINE_FRAGMENT || selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) ?? false;
|
|
692
|
+
// When the parent schema type is an interface:
|
|
693
|
+
// - If we're processing inline fragments, use the concrete type name
|
|
694
|
+
// - If we're processing the interface directly, use the interface name
|
|
695
|
+
// - If we're in a named fragment, always use the concrete type name
|
|
696
|
+
if ((0, graphql_1.isObjectType)(schemaType) && this._parentSchemaType && (0, graphql_1.isInterfaceType)(this._parentSchemaType) && !hasFragment) {
|
|
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
|
+
const schemaType = this._schema.getType(typeName);
|
|
686
|
+
// Check if current selection set has fragments (e.g., "... AppNotificationFragment" or "... on AppNotification")
|
|
687
|
+
const hasFragment = this._selectionSet?.selections?.some(selection => selection.kind === Kind.INLINE_FRAGMENT || selection.kind === Kind.FRAGMENT_SPREAD) ?? false;
|
|
688
|
+
// When the parent schema type is an interface:
|
|
689
|
+
// - If we're processing inline fragments, use the concrete type name
|
|
690
|
+
// - If we're processing the interface directly, use the interface name
|
|
691
|
+
// - If we're in a named fragment, always use the concrete type name
|
|
692
|
+
if (isObjectType(schemaType) && this._parentSchemaType && isInterfaceType(this._parentSchemaType) && !hasFragment) {
|
|
693
|
+
return `${parentName}_${this._parentSchemaType.name}`;
|
|
694
|
+
}
|
|
695
|
+
return `${parentName}_${typeName}`;
|
|
683
696
|
}
|
|
684
697
|
}
|
|
685
698
|
function formatUnion(members) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/visitor-plugin-common",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2-alpha-20251208101827-e43ab73e4201f13f8df28eacf0c3fe4a7300f3e8",
|
|
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
|
},
|