🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
No One Place Fragments

no-one-place-fragments

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

Disallow fragments that are used only in one place.

Usage Examples

Incorrect

# eslint @graphql-eslint/no-one-place-fragments: 'error'
 
fragment UserFields on User {
  id
}
 
{
  user {
    ...UserFields
  }
}

Correct

# eslint @graphql-eslint/no-one-place-fragments: 'error'
 
fragment UserFields on User {
  id
}
 
{
  user {
    ...UserFields
    friends {
      ...UserFields
    }
  }
}

Resources