🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
Lone 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