Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.08 KB

avoid-duplicate-fields.md

File metadata and controls

54 lines (42 loc) · 1.08 KB

avoid-duplicate-fields

  • Category: Stylistic Issues
  • Rule name: @graphql-eslint/avoid-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/avoid-duplicate-fields: 'error'

query getUserDetails {
  user {
    name # first
    email
    name # second
  }
}

Incorrect

# eslint @graphql-eslint/avoid-duplicate-fields: 'error'

query getUsers {
  users(
    first: 100
    skip: 50
    after: "cji629tngfgou0b73kt7vi5jo"
    first: 100 # duplicate argument
  ) {
    id
  }
}

Incorrect

# eslint @graphql-eslint/avoid-duplicate-fields: 'error'

query getUsers($first: Int!, $first: Int!) {
  # Duplicate variable
  users(first: 100, skip: 50, after: "cji629tngfgou0b73kt7vi5jo") {
    id
  }
}