Skip to content

Fix duplicate typename__ when type implements multiple interfaces - #460

Open
magicmark wants to merge 2 commits into
mirumee:mainfrom
magicmark:fix/duplicate-typename-dedup
Open

Fix duplicate typename__ when type implements multiple interfaces#460
magicmark wants to merge 2 commits into
mirumee:mainfrom
magicmark:fix/duplicate-typename-dedup

Conversation

@magicmark

Copy link
Copy Markdown

Fixes the bug from the xfail test — _resolve_selection_set merges fields from all matching inline fragments, so when a type implements interfaces Bar and Baz and both spreads select __typename, you get it twice.

The fix deduplicates fields by name at the end of _resolve_selection_set, keeping the first occurrence. All 924 existing tests pass unchanged.

Stacked on #442.

magicmark and others added 2 commits July 7, 2026 16:45
When a concrete type implements multiple interfaces and a query uses inline
fragments on those interfaces (each selecting __typename), the codegen
produces duplicate typename__ fields in the generated Pydantic model. This
causes mypy to fail with: Name "typename__" already defined [no-redef]

Co-Authored-By: Claude <noreply@anthropic.com>
When multiple inline fragments (targeting different interfaces a type
implements) each select the same field, only keep the first occurrence.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a84a52d-9b96-46d2-a094-d0d0e15789d3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant