Class QueryField
- java.lang.Object
-
- com.graphql_java_generator.client.request.QueryField
-
public class QueryField extends java.lang.ObjectThis class gives parsing capabilities for the QueryString for one object.
For instance, for the GraphQL query queryType.boards("{id name publiclyAvailable topics(since: \"2018-12-20\"){id}}"), it is created for the field named boards, then the#readTokenizerForResponseDefinition(StringTokenizer)is called for the whole String.
Then anotherQueryFieldis created, for the field named topics, and the (since: \"2018-12-20\") is parsed by the#readTokenizerForInputParameters(StringTokenizer), then the {id} String is parsed by#readTokenizerForResponseDefinition(StringTokenizer).- Author:
- etienne-sf
-
-
Constructor Summary
Constructors Constructor Description QueryField(java.lang.Class<?> owningClass, java.lang.String fieldName)The constructor, when created by theBuilder: it must provide the owningClassQueryField(java.lang.Class<?> owningClass, java.lang.String fieldName, java.lang.String fieldAlias)The constructor, when created by theBuilder: it must provide the owningClass
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendToGraphQLRequests(java.lang.StringBuilder sb, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean appendName)Append this query field in theStringBuilderin which the query is being written.java.lang.StringgetAlias()java.lang.Class<?>getClazz()java.util.List<QueryField>getFields()java.lang.StringgetName()java.lang.Class<?>getOwningClazz()booleanisQueryLevel()Indicates whether this field is a query/mutation/subscription or notbooleanisScalar()Indicates whether this field is a scalar or not.voidreadTokenizerForResponseDefinition(QueryTokenizer qt, java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.lang.reflect.Field>> aliasFields, java.lang.String schema)Reads the definition of the expected response definition from the server.
-
-
-
Constructor Detail
-
QueryField
public QueryField(java.lang.Class<?> owningClass, java.lang.String fieldName, java.lang.String fieldAlias) throws GraphQLRequestPreparationExceptionThe constructor, when created by theBuilder: it must provide the owningClass- Parameters:
owningClass- TheClassthat owns the fieldfieldName- The name of the fieldfieldAlias- The alias for this field- Throws:
GraphQLRequestPreparationException
-
QueryField
public QueryField(java.lang.Class<?> owningClass, java.lang.String fieldName) throws GraphQLRequestPreparationExceptionThe constructor, when created by theBuilder: it must provide the owningClass- Parameters:
owningClass- TheClassthat owns the fieldfieldName- The name of the field- Throws:
GraphQLRequestPreparationException
-
-
Method Detail
-
readTokenizerForResponseDefinition
public void readTokenizerForResponseDefinition(QueryTokenizer qt, java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.lang.reflect.Field>> aliasFields, java.lang.String schema) throws GraphQLRequestPreparationException
Reads the definition of the expected response definition from the server. It is recursive.
For instance, for the GraphQL query queryType.boards("{id name publiclyAvailable topics(since: \"2018-12-20\"){id}}"), it will be called twice:
Once for the String id name publiclyAvailable topics(since: \"2018-12-20\"){id}} (without the leading '{'), where QueryField is boards,
Then for the String id}, where the QueryField is topics- Parameters:
qt- TheStringTokenizer, where the next token is the first token after the '{' have already been read.
TheStringTokenizeris read until the '}' associated with this already read '{'.
For instance, when this method is called with theStringTokenizerwhere these characters are still to read: id date author{name email alias} title content}}, theStringTokenizeris read until and including the first '}' that follows content. Thus, there is still a '}' to read.aliasFields- This maps contains theField, that matches each alias, of each GraphQL type. This allows a proper deserialization of each alias value returned in the json responseschema- value of the springBeanSuffix plugin parameter for the searched schema. When there is only one schema, this plugin parameter is usually not set. In this case, its default value ("") is used.- Throws:
GraphQLRequestPreparationException
-
appendToGraphQLRequests
public void appendToGraphQLRequests(java.lang.StringBuilder sb, java.util.Map<java.lang.String,java.lang.Object> parameters, boolean appendName) throws GraphQLRequestExecutionExceptionAppend this query field in theStringBuilderin which the query is being written. Any parameter will be replaced by its value. It's a recursive method, that calls itself when this field is not a scalar: it calls itself for each subfield.- Parameters:
sb-parameters-appendName- true if the name of the field must be written in the query (for regular fields for instance). False otherwise (for fragments, for instance)- Throws:
GraphQLRequestExecutionException
-
isScalar
public boolean isScalar() throws GraphQLRequestPreparationExceptionIndicates whether this field is a scalar or not.- Returns:
- true if this field is a scalar (custom or not), and false otherwise.
- Throws:
GraphQLRequestPreparationException
-
isQueryLevel
public boolean isQueryLevel()
Indicates whether this field is a query/mutation/subscription or not- Returns:
- true if the
QueryFieldis a query, a mutation or a subscription. False otherwise.
-
getFields
public java.util.List<QueryField> getFields()
-
getOwningClazz
public java.lang.Class<?> getOwningClazz()
-
getClazz
public java.lang.Class<?> getClazz()
-
getName
public java.lang.String getName()
-
getAlias
public java.lang.String getAlias()
-
-