Skip to content

noDuplicateFields (GraphQL)

Language GraphQL
biome.json
{
"linter": {
"rules": {
"suspicious": {
"noDuplicateFields": "error"
}
}
}
}

Disallow duplicate names inside GraphQL operations.

The rule checks selected fields within each selection set, variables declared by an operation, and arguments passed to a field. Each name must appear only once in its list.

query {
users {
id
name
email
name
}
}
code-block.graphql:4:5 lint/suspicious/noDuplicateFields ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The field `name` is defined multiple times.

2 │ users {
3 │ id
> 4 │ name
│ ^^^^
5 │ email
6 │ name

ℹ The field `name` is repeated here.

4 │ name
5 │ email
> 6 │ name
│ ^^^^
7 │ }
8 │ }

ℹ Defining the same name more than once is not allowed, even when the duplicates could be merged.

ℹ Remove the duplicated field.

query {
users(
first: 100,
after: 10,
filter: "test",
first: 50
) {
id
}
}
code-block.graphql:3:5 lint/suspicious/noDuplicateFields ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The argument `first` is defined multiple times.

1 │ query {
2 │ users(
> 3 │ first: 100,
│ ^^^^^
4 │ after: 10,
5 │ filter: "test",

ℹ The argument `first` is repeated here.

4 │ after: 10,
5 │ filter: "test",
> 6 │ first: 50
│ ^^^^^
7 │ ) {
8 │ id

ℹ Defining the same name more than once is not allowed, even when the duplicates could be merged.

ℹ Remove the duplicated argument.

query ($v: String, $t: String, $v: String) {
id
}
code-block.graphql:1:9 lint/suspicious/noDuplicateFields ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ The variable `v` is defined multiple times.

> 1 │ query ($v: String, $t: String, $v: String) {
│ ^
2 │ id
3 │ }

ℹ The variable `v` is repeated here.

> 1 │ query ($v: String, $t: String, $v: String) {
│ ^
2 │ id
3 │ }

ℹ Defining the same name more than once is not allowed, even when the duplicates could be merged.

ℹ Remove the duplicated variable.

query {
users {
id
name
email
}
}