Skip to content

useLoneExecutableDefinition (GraphQL)

Language GraphQL
biome.json
{
"linter": {
"rules": {
"style": {
"useLoneExecutableDefinition": "error"
}
}
}
}

Require one executable GraphQL definition per file.

An executable definition is a query, mutation, subscription, or fragment. Keeping each one in a separate file makes operations easier to locate, test, and maintain.

query Foo {
id
}
fragment Bar on Baz {
id
}
code-block.graphql:5:1 lint/style/useLoneExecutableDefinition ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Document contains multiple definitions. This definition should be in a separate file.

3 │ }
4 │
> 5 │ fragment Bar on Baz {
│ ^^^^^^^^^^^^^^^^^^^^^
> 6 │ id
> 7 │ }
│ ^
8 │

ℹ Queries, mutations, subscriptions or fragments each must be defined in separate files.

query Foo {
id
}
mutation ($name: String!) {
createUser {
id
}
}
code-block.graphql:5:1 lint/style/useLoneExecutableDefinition ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Document contains multiple definitions. This definition should be in a separate file.

3 │ }
4 │
> 5 │ mutation ($name: String!) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 6 │ createUser {
> 7 │ id
> 8 │ }
> 9 │ }
│ ^
10 │

ℹ Queries, mutations, subscriptions or fragments each must be defined in separate files.

query Foo {
id
}
query Bar {
id
}
code-block.graphql:5:1 lint/style/useLoneExecutableDefinition ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ Document contains multiple definitions. This definition should be in a separate file.

3 │ }
4 │
> 5 │ query Bar {
│ ^^^^^^^^^^^
> 6 │ id
> 7 │ }
│ ^
8 │

ℹ Queries, mutations, subscriptions or fragments each must be defined in separate files.

query Foo {
id
}
fragment Bar on Baz {
id
}