Linter rulesGraphQLno-one-place-fragments
no-one-place-fragments
Since 0.9.0
This rule checks that fragments are spread more than once in the document.
Rule Details
A fragment spread once adds indirection without reuse; its selections are better inlined.
Configuration
This rule has no options.
version: "1.0"
commands:
lint:
graphql:
rules:
no-one-place-fragments: warning
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable no-one-place-fragments comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to operations and fragments.
Examples
Good.
query Q { a: user(id: 1) { ...UserFields } b: user(id: 2) { ...UserFields } }
fragment UserFields on User { id }
Bad. The linter reports Fragment 'UserFields' is spread only once; inline its selections.
query Q { me { ...UserFields } }
fragment UserFields on User { id }