Skip to content

useLoneExecutableDefinition

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

Require queries, mutations, subscriptions or fragments each to be located in separate files.

This rule ensures that each GraphQL document only contains a single operation (query, mutation, or subscription) or fragment definition. Having multiple executable definitions in a single file can make code harder to maintain, test, and understand.

query Foo {
id
}
fragment Bar on Baz {
id
}
code-block.graphql:5:1 lint/nursery/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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

query Foo {
id
}
mutation ($name: String!) {
createUser {
id
}
}
code-block.graphql:5:1 lint/nursery/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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

query Foo {
id
}
query Bar {
id
}
code-block.graphql:5:1 lint/nursery/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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

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