Skip to Content
🚧 This is WIP documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Rulesrequire-import-fragment

require-import-fragment

💡 This rule provides suggestions

  • 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

Last updated on