Class GenerateCodeDocumentParser

java.lang.Object
com.graphql_java_generator.plugin.DocumentParser
com.graphql_java_generator.plugin.generate_code.GenerateCodeDocumentParser
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

@Component public class GenerateCodeDocumentParser extends DocumentParser
This class parses the GraphQL shema file(s), and loads it in a structure that'll make it easy to send to Velocity templates. There is no validity check: we trust the information in the Document, as it is read by the GraphQL Parser.
The graphQL-java library maps both FieldDefinition and InputValueDefinition in very similar structures, which are actually trees. These structures are too hard too read in a Velocity template, and we need to parse down to a properly structures way for that.
This class should not be used directly. Please use the GenerateCodePluginExecutor instead.
Author:
etienne-sf
  • Field Details

    • UTIL_PACKAGE_NAME

      public static final String UTIL_PACKAGE_NAME
      The name of the package for utility classes, when the separateUtilClasses plugin parameter is set to true. This is the name of subpackage within the package defined by the packageName plugin parameter.
      This constant is useless when the separateUtilClasses plugin parameter is set to false, which is its default value.
      See Also:
  • Constructor Details

    • GenerateCodeDocumentParser

      public GenerateCodeDocumentParser()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class DocumentParser
    • initScalarTypes

      protected void initScalarTypes(Class<?> notUsed)
      This method initializes the DocumentParser.scalarTypes list. This list depends on the use case
      Overrides:
      initScalarTypes in class DocumentParser
    • parseGraphQLSchemas

      public int parseGraphQLSchemas() throws IOException
      The main method of the class: it graphqlUtils.executes the generation of the given documents
      Overrides:
      parseGraphQLSchemas in class DocumentParser
      Parameters:
      documents - The GraphQL definition schema, from which the code is to be generated
      Returns:
      Throws:
      IOException - When an error occurs, during the parsing of the GraphQL schemas
    • getDataFetchersDelegate

      public DataFetchersDelegate getDataFetchersDelegate(Type type, boolean createIfNotExists)
      Returns the DataFetchersDelegate that manages the given type.
      Parameters:
      type - The type, for which the DataFetchersDelegate is searched. It may not be null.
      createIfNotExists - if true: a new DataFetchersDelegate is created when there is no DataFetchersDelegate for this type yet. If false: no DataFetchersDelegate creation.
      Returns:
      The relevant DataFetchersDelegate, or null of there is no DataFetchersDelegate for this type and createIfNotExists is false
      Throws:
      NullPointerException - If type is null
    • getUtilPackageName

      protected String getUtilPackageName()
      Returns the name of the package for utility classes, when the separateUtilClasses plugin parameter is set to true. This is the name of subpackage within the package defined by the packageName plugin parameter.
      This constant is useless when the separateUtilClasses plugin parameter is set to false, which is its default value.
      Overrides:
      getUtilPackageName in class DocumentParser
      Returns: