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

no-unused-fields

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

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

Requires all fields to be used at some level by siblings operations.

Usage Examples

Incorrect

# eslint @graphql-eslint/no-unused-fields: 'error'
 
type User {
  id: ID!
  name: String
  someUnusedField: String
}
 
type Query {
  me: User
}
 
query {
  me {
    id
    name
  }
}

Correct

# eslint @graphql-eslint/no-unused-fields: 'error'
 
type User {
  id: ID!
  name: String
}
 
type Query {
  me: User
}
 
query {
  me {
    id
    name
  }
}

Resources