Skip to Content
🚧 This is WIP documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Rulesno-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

Last updated on