Skip to content

Don't report a shared fragment as a fragment cycle - #886

Open
toddburnside wants to merge 1 commit into
typelevel:mainfrom
toddburnside:fix-fragment-diamond-false-cycle
Open

Don't report a shared fragment as a fragment cycle#886
toddburnside wants to merge 1 commit into
typelevel:mainfrom
toddburnside:fix-fragment-diamond-false-cycle

Conversation

@toddburnside

Copy link
Copy Markdown

validateVariablesAndFragments accumulated visited fragments into a single seen set spanning the whole traversal rather than tracking the fragments on the current path. A fragment reachable by more than one path was therefore reported as a cycle, e.g.

fragment a on T { x { ...c } y { ...b } }
fragment b on U { z { ...c } }
fragment c on V { w }

failed with "Fragment cycle starting from 'a'".

Replace the check with a proper DFS: path holds the fragments on the current traversal path and done those already explored in full, a fragment joins done only after its references have been explored, and the path check precedes the done check. Genuine recursion is still detected, and reported against the same fragment as before.

Claude-Session: https://claude.ai/code/session_01Lyt6Er1f7k4DDcNBoZEUGS

`validateVariablesAndFragments` accumulated visited fragments into a single
`seen` set spanning the whole traversal rather than tracking the fragments on
the current path. A fragment reachable by more than one path was therefore
reported as a cycle, e.g.

    fragment a on T { x { ...c } y { ...b } }
    fragment b on U { z { ...c } }
    fragment c on V { w }

failed with "Fragment cycle starting from 'a'".

Replace the check with a proper DFS: `path` holds the fragments on the current
traversal path and `done` those already explored in full, a fragment joins
`done` only after its references have been explored, and the `path` check
precedes the `done` check. Genuine recursion is still detected, and reported
against the same fragment as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lyt6Er1f7k4DDcNBoZEUGS
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