🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
Require Import Fragment

require-import-fragment

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

  • Category: Operations
  • Rule name: @graphql-eslint/require-import-fragment
  • Requires GraphQL Schema: false ℹī¸
  • Requires GraphQL Operations: true ℹī¸

Require fragments to be imported via an import expression.

Usage Examples

Incorrect

# eslint @graphql-eslint/require-import-fragment: 'error'
 
query {
  user {
    ...UserFields
  }
}

Incorrect

# eslint @graphql-eslint/require-import-fragment: 'error'
 
# import 'post-fields.fragment.graphql'
query {
  user {
    ...UserFields
  }
}

Incorrect

# eslint @graphql-eslint/require-import-fragment: 'error'
 
# import UserFields from 'post-fields.fragment.graphql'
query {
  user {
    ...UserFields
  }
}

Correct

# eslint @graphql-eslint/require-import-fragment: 'error'
 
# import UserFields from 'user-fields.fragment.graphql'
query {
  user {
    ...UserFields
  }
}

Resources