Linter rulesGraphQLstrict-id-in-types
strict-id-in-types
Since 0.9.0
This rule checks that object types have exactly one non-null identifier field, id: ID! by default.
Rule Details
Clients such as Apollo Client and Relay cache objects by their identifier. Root operation types are not checked; payload and connection types usually need exceptions.
Configuration
The configuration block is an object with the properties:
acceptedIdNames: the names of identifier fields,[id]by defaultacceptedIdTypes: the types of identifier fields,[ID]by defaultexceptions: an object withtypes, the names of types that are not checked, andsuffixes, the suffixes of the names of types that are not checked
version: "1.0"
commands:
lint:
graphql:
rules:
strict-id-in-types: [error, { exceptions: { suffixes: [Payload, Connection, Edge] } }]
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable strict-id-in-types 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 definitions.
Examples
Good.
type User { id: ID!, name: String }
Bad. The linter reports Object type 'User' should have exactly one non-null field named 'id' of type 'ID'.
type User { name: String }