Linter rulesGraphQLone-field-subscriptions
one-field-subscriptions
Since 0.9.0
This rule checks that subscriptions select a single root field, as the specification requires.
Rule Details
A subscription maps one event stream to responses; selecting several root fields, or an introspection field, is invalid. Inline fragments and the fragments of the document are followed.
Configuration
This rule has no options.
version: "1.0"
commands:
lint:
graphql:
rules:
one-field-subscriptions: warning
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable one-field-subscriptions 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.
subscription OnMessage { messageAdded { id } }
Bad. The linter reports Subscription "OnEvents" must select only one top level field..
subscription OnEvents { messageAdded { id } userJoined { id } }