Class AddRelayConnections

java.lang.Object
com.graphql_java_generator.plugin.AddRelayConnections

@Component public class AddRelayConnections extends Object
This method add the relay capabilities into the GraphQL schema, as it has been read by DocumentParser. The relay capabilities are specified in this doc.
The implementation is the one described on the Relay website. It (currently) doesn't implement the generic utility types, as described in this article: Intermediate Interfaces & Generic Utility Types in GraphQL, which explains the choices in the GraphQL specifications, for interfaces that implements interface(s), especially when implementing the relay connection. The reason is that the capacity to "narrow" a field's type in a type inherited from an interface is not compatible with Java. So the Java implementation will need to use Java Generics, and probably some hint (directive) to properly generate the Java code.
This class will add the items described below in the currently read schema data. It is the possible to generate a Java Really compatible code (by using the graphql goal/task), or to generate the Relay compatible GraphQL schema (by using the mergeSchema task/goal).
The items added to the in-memory read schema are:
  • The Node interface in the GraphQL schema (if not already defined). If this interface is already defined in the given schema, but is not compliant, then an error is thrown.
  • The @RelayConnection directive definition in the GraphQL schema (if not already defined). If this is already defined in the given schema, but is not compliant with the relay specification, then an error is thrown.
  • The PageInfo type in the GraphQL schema (if not already defined). If this type is already defined in the given schema, but is not compliant with the relay specification, then an error is thrown.
  • All the Edge and Connection types in the GraphQL schema, for each type of a field that is marked by the @RelayConnection directive. If types with these names exist, and are not compliant with the Relay specification, then an error is thrown
  • Each type of a field that is marked by the @RelayConnection directive, is marked by the Node interface
Author:
etienne-sf
  • Constructor Details

    • AddRelayConnections

      public AddRelayConnections()
  • Method Details

    • addRelayConnections

      public void addRelayConnections()
      The main entry point of the class. It is responsible for doing what's described in the class documentation