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

no-duplicate-fields

✅ The "extends": "plugin:@graphql-eslint/operations-recommended" property in a configuration file enables this rule.

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

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

Checks for duplicate fields in selection set, variables in operation definition, or in arguments set of a field.

Usage Examples

Incorrect

# eslint @graphql-eslint/no-duplicate-fields: 'error'
 
query {
  user {
    name
    email
    name # duplicate field
  }
}

Incorrect

# eslint @graphql-eslint/no-duplicate-fields: 'error'
 
query {
  users(
    first: 100
    skip: 50
    after: "cji629tngfgou0b73kt7vi5jo"
    first: 100 # duplicate argument
  ) {
    id
  }
}

Incorrect

# eslint @graphql-eslint/no-duplicate-fields: 'error'
 
query (
  $first: Int!
  $first: Int! # duplicate variable
) {
  users(first: $first, skip: 50) {
    id
  }
}

Resources