Class CommonExtension

java.lang.Object
com.graphql_java_generator.gradleplugin.CommonExtension
All Implemented Interfaces:
com.graphql_java_generator.plugin.conf.CommonConfiguration
Direct Known Subclasses:
GenerateCodeCommon, GenerateGraphQLSchemaExtension

public class CommonExtension
extends java.lang.Object
implements com.graphql_java_generator.plugin.conf.CommonConfiguration

This class contain the parameters that are common to all Gradle Extensions for this plugin, that is the parameters that are common to all the tasks of this plugin.

This avoids to redeclare each common parameter in each Extension, including its comment. When a comment is updated, only one update is necessary, instead of updating it in each Extension.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    boolean addRelayConnections
    True if the plugin is configured to add the relay connection capabilities, as described here and specified in the relay connection specification.
    protected org.gradle.api.Project project  

    Fields inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration

    DEFAULT_ADD_RELAY_CONNECTIONS, DEFAULT_PACKAGE_NAME, DEFAULT_SCHEMA_FILE_FOLDER, DEFAULT_SCHEMA_FILE_PATTERN
  • Constructor Summary

    Constructors 
    Constructor Description
    CommonExtension​(org.gradle.api.Project project)  
  • Method Summary

    Modifier and Type Method Description
    com.graphql_java_generator.plugin.conf.Logger getPluginLogger()  
    java.io.File getSchemaFileFolder()  
    java.lang.String getSchemaFilePattern()  
    java.util.Map<java.lang.String,​java.lang.String> getTemplates()  
    boolean isAddRelayConnections()  
    void logConfiguration()  
    void setAddRelayConnections​(java.lang.Boolean addRelayConnections)  
    void setSchemaFileFolder​(java.lang.String schemaFileFolder)  
    void setSchemaFilePattern​(java.lang.String schemaFilePattern)  
    void setTemplates​(java.util.Map<java.lang.String,​java.lang.String> templates)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration

    getDefaultTargetSchemaFileName, logCommonConfiguration
  • Field Details

    • project

      protected final org.gradle.api.Project project
    • addRelayConnections

      public boolean addRelayConnections

      True if the plugin is configured to add the relay connection capabilities, as described here and specified in the relay connection specification.

      The plugin reads the GraphQL schema file(s), and enrich them with the interface 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, type's field. It must be declared in the given GraphQL schema file(s) like this:

       directive @RelayConnection on FIELD_DEFINITION
       

      When addRelayConnections is set to true, here is what's done for each field that is marked with the @RelayConnection directive:

      • The field type, whether it's a list or not, is replaced by the relevant XxxConnection type. For instance the query allHumans(criteria: String): [Human] @RelayConnection is replaced by allHumans(criteria: String): HumanConnection, and the human's field friends: Character @RelayConnection is replaced by friends: CharacterConnection. Please note that :
        • The @RelayConnection directive is removed in the target schema
        • If the @RelayConnection is set on a field of an interface, it should be set also in the same field, for each type that implements this interface. If not, a warning is generated. The directive is applied on the interface and its implementations's field, whether or not the directive is actually set in the implementing classes.
        • If the @RelayConnection is not set on a field of an interface, but is set in the same field, for one type that implements this interface, then an error is generated. The directive is applied on the interface and its implementations's field, whether or not the directive is actually set in the implementing classes.
        • Input type's fields may not have the @RelayConnection directive
      • For each type marked at least once, with the @RelayConnection directive (the Human type, and the Character interface, here above), the relevant XxxConnection and XxxEdge type are added to the in-memory schema.
      • The Node interface is added to each type marked at least once, with the @RelayConnection directive (the Human type, and the Character interface, here above). Of course, these types must have a mandatory field id of type ID that is not a list. If not, then an error is thrown.

      As a sum-up, if addRelayConnections is set to true, the plugin will add into the in-memory GraphQL schema:

      • Check that the @@RelayConnexion directive definition exist in the GraphQL schema, and is compliant with the above definition.
      • Add 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 with the relay specification, then an error is thrown.
      • Add 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 type in the GraphQL schema, for each type that is marked by the @@RelayConnexion directive.
  • Constructor Details

    • CommonExtension

      public CommonExtension​(org.gradle.api.Project project)
  • Method Details

    • getPluginLogger

      public com.graphql_java_generator.plugin.conf.Logger getPluginLogger()
      Specified by:
      getPluginLogger in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • isAddRelayConnections

      public boolean isAddRelayConnections()
      Specified by:
      isAddRelayConnections in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setAddRelayConnections

      public void setAddRelayConnections​(java.lang.Boolean addRelayConnections)
    • getSchemaFileFolder

      public java.io.File getSchemaFileFolder()
      Specified by:
      getSchemaFileFolder in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setSchemaFileFolder

      public void setSchemaFileFolder​(java.lang.String schemaFileFolder)
    • getSchemaFilePattern

      public java.lang.String getSchemaFilePattern()
      Specified by:
      getSchemaFilePattern in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setSchemaFilePattern

      public void setSchemaFilePattern​(java.lang.String schemaFilePattern)
    • getTemplates

      public java.util.Map<java.lang.String,​java.lang.String> getTemplates()
      Specified by:
      getTemplates in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setTemplates

      public void setTemplates​(java.util.Map<java.lang.String,​java.lang.String> templates)
    • logConfiguration

      public void logConfiguration()
      Specified by:
      logConfiguration in interface com.graphql_java_generator.plugin.conf.CommonConfiguration