useLoneExecutableDefinition
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useLoneExecutableDefinition - 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": { "nursery": { "useLoneExecutableDefinition": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.