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
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
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
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 Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the package for utility classes, when the separateUtilClasses plugin parameter is set to true.Fields inherited from class com.graphql_java_generator.plugin.DocumentParser
addRelayConnections, configuration, customScalars, DEFAULT_MUTATION_NAME, DEFAULT_QUERY_NAME, DEFAULT_SUBSCRIPTION_NAME, directives, enumTypes, graphqlUtils, interfaceTypes, mutationType, mutationTypeName, queryType, queryTypeName, scalarTypes, schemaDirectives, schemaStringProvider, subscriptionType, subscriptionTypeName, types, unionTypes
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
getDataFetchersDelegate
(Type type, boolean createIfNotExists) Returns theDataFetchersDelegate
that manages the given type.protected String
Returns the name of the package for utility classes, when the separateUtilClasses plugin parameter is set to true.protected void
initScalarTypes
(Class<?> notUsed) This method initializes theDocumentParser.scalarTypes
list.int
The main method of the class: it graphqlUtils.executes the generation of the given documentsMethods inherited from class com.graphql_java_generator.plugin.DocumentParser
fillTypesMap, getDirectiveDefinition, getType, getType, getType, readDirectiveDefinition, readEnumType, readObjectTypeDefinition
-
Field Details
-
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()The default constructor
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in classDocumentParser
-
getConfiguration
-
initScalarTypes
This method initializes theDocumentParser.scalarTypes
list. This list depends on the use case- Overrides:
initScalarTypes
in classDocumentParser
-
parseGraphQLSchemas
The main method of the class: it graphqlUtils.executes the generation of the given documents- Overrides:
parseGraphQLSchemas
in classDocumentParser
- 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
Returns theDataFetchersDelegate
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 noDataFetchersDelegate
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
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 classDocumentParser
- Returns:
-