Skip to content

unique-fragment-name

GraphQLcorrectnessno fixdefault: error

Reports two fragments of a document with the same name, within one file.

A spread names the fragment it means, and with two of one name the tool cannot tell which, so it takes one or fails depending on the order. Code generators write one type per fragment name and collide.

To fix, rename one of them.

Reported
...
query B { c }
fragment F on T { a }
fragment F on T { b }
graphql:
lint:
rules:
unique-fragment-name: error # off, warn, error (default)

Suppress one line with sudsy-disable-next-line unique-fragment-name in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
graphql-eslint unique-fragment-name partial Not checked across files.