🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
No Root Type

no-root-type

💡 This rule provides suggestions (opens in a new tab)

  • Category: Schema
  • Rule name: @graphql-eslint/no-root-type
  • Requires GraphQL Schema: true ℹī¸
  • Requires GraphQL Operations: false ℹī¸

Disallow using root types mutation and/or subscription.

Usage Examples

Incorrect

# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
 
type Mutation {
  createUser(input: CreateUserInput!): User!
}

Correct

# eslint @graphql-eslint/no-root-type: ['error', { disallow: ['mutation', 'subscription'] }]
 
type Query {
  users: [User!]!
}

Config Schema

The schema defines the following properties:

disallow (array, required)

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

  • mutation
  • subscription

Additional restrictions:

  • Minimum items: 1
  • Unique items: true

Resources