Przejdź do głównej zawartości

useUniqueGraphqlOperationName

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useUniqueGraphqlOperationName": "error"
}
}
}
}

Enforce unique operation names across a GraphQL document.

This rule ensures that all GraphQL operations (queries, mutations, subscriptions) have unique names. Using unique operation names is essential for proper identification and reducing confusion.

query user {
user {
id
}
}
query user {
me {
id
}
}
code-block.graphql:7:1 lint/nursery/useUniqueGraphqlOperationName ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Operation named “user” is already defined.

5 │ }
6 │
> 7 │ query user {
^^^^^^^^^^^^
> 8 │ me {
> 9 │ id
> 10 │ }
> 11 │ }
^
12 │

GraphQL operation names must be unique to ensure proper identification.

Rename the operation to have a unique name.

query user {
user {
id
}
}
query me {
me {
id
}
}