noDuplicateFields (GraphQL)
Language GraphQL
Summary
Section titled “Summary”- Rule available since:
v1.9.0 - Diagnostic Category:
lint/suspicious/noDuplicateFields - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noDuplicateFields": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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 }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.