Skip to Content
This is documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Ruleslone-executable-definition

lone-executable-definition

  • Category: Operations
  • Rule name: @graphql-eslint/lone-executable-definition
  • Requires GraphQL Schema: false ℹ️
  • Requires GraphQL Operations: false ℹ️
Require queries, mutations, subscriptions or fragments to be located in separate files.

Usage Examples

Incorrect

# eslint @graphql-eslint/lone-executable-definition: 'error'
 
query Foo {
  id
}
fragment Bar on Baz {
  id
}

Correct

# eslint @graphql-eslint/lone-executable-definition: 'error'
 
query Foo {
  id
}

Config Schema

The schema defines the following properties:

ignore (array)

Allow certain definitions to be placed alongside others.

The elements of the array can contain the following enum values:

  • fragment
  • query
  • mutation
  • subscription

Additional restrictions:

  • Minimum items: 1
  • Unique items: true

Resources

Last updated on