Skip to content

Commit b602b64

Browse files
committed
handle fragment spreads
1 parent 41047b0 commit b602b64

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/plugins/other/visitor-plugin-common/src/selection-set-to-object.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -965,19 +965,16 @@ export class SelectionSetToObject<Config extends ParsedDocumentsConfig = ParsedD
965965
const schemaType = this._schema.getType(typeName);
966966

967967
// Check if current selection set has inline fragments (e.g., "... on AppNotification")
968-
const hasInlineFragments =
969-
this._selectionSet?.selections?.some(selection => selection.kind === Kind.INLINE_FRAGMENT) ?? false;
968+
const hasFragment =
969+
this._selectionSet?.selections?.some(
970+
selection => selection.kind === Kind.INLINE_FRAGMENT || selection.kind === Kind.FRAGMENT_SPREAD
971+
) ?? false;
970972

971973
// When the parent schema type is an interface:
972974
// - If we're processing inline fragments, use the concrete type name
973975
// - If we're processing the interface directly, use the interface name
974976
// - If we're in a named fragment, always use the concrete type name
975-
if (
976-
isObjectType(schemaType) &&
977-
this._parentSchemaType &&
978-
isInterfaceType(this._parentSchemaType) &&
979-
!hasInlineFragments
980-
) {
977+
if (isObjectType(schemaType) && this._parentSchemaType && isInterfaceType(this._parentSchemaType) && !hasFragment) {
981978
return `${parentName}_${this._parentSchemaType.name}`;
982979
}
983980

0 commit comments

Comments
 (0)