The addRelayConnections parameter configures the plugin, so that it uses the @RelayConnection directive as a marker, to apply the relay connection capabilities, as defined in the Relay specification. For more information, you can check The Relay GraphQL server specification or the Relay connection specification.
When the addRelayConnections parameter is set to true, the plugin reads the GraphQL schema file(s), and enriches them it with the interfaces and types needed to respect the Relay Connection specification. The entry point for that is the @RelayConnection directive. It is specific to this plugin. It can be added to any field, that is, typically: queries, mutations, interface's fields and any object's field.
The addRelayConnections parameter may be used in these goals/tasks of the plugin:
It must be declared in the given GraphQL schema file(s) like this:
directive @RelayConnection on FIELD_DEFINITION
Then the @RelayConnection directive may be added to every field that should be used through a Relay connection. That is: the field's type, whether it's a list or not, is replaced by the relevant XxxConnection type.
For instance the query:
query { ... allHumans(criteria: String): [Human] @RelayConnection, ... }
is replaced by:
query { ... allHumans(criteria: String): HumanConnection! @RelayConnection, ... } type HumanConnection { edges: [HumanEdge] pageInfo: PageInfo! } type HumanEdge { node: Human cursor: String! } type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String! endCursor: String! } interface Node { id: ID! } # The Character interface is marked as implementing the Node interface type Human implements Node { ... }
And the field:
Human { ... friends: Character @RelayConnection, ... }
is replaced by:
Human { ... friends: CharacterConnection! @RelayConnection, ... } interface CharacterConnection { edges: [CharacterEdge] pageInfo: PageInfo! } interface CharacterEdge { node: Character cursor: String! } type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String! endCursor: String! } interface Node { id: ID! } # The Character interface is marked as implementing the Node interface interface Character implements Node { ... }
Please note that :
To sum-up, if addRelayConnections plugin parameter is set to true, the plugin will: