Class QueryField

java.lang.Object
com.graphql_java_generator.client.request.QueryField

public class QueryField extends Object
This 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 another QueryField is 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 Details

  • Method Details

    • readTokenizerForResponseDefinition

      public void readTokenizerForResponseDefinition(QueryTokenizer qt, Map<Class<?>,Map<String,Field>> aliasFields, 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 - The StringTokenizer, where the next token is the first token after the '{' have already been read.
      The StringTokenizer is read until the '}' associated with this already read '{'.
      For instance, when this method is called with the StringTokenizer where these characters are still to read: id date author{name email alias} title content}}, the StringTokenizer is read until and including the first '}' that follows content. Thus, there is still a '}' to read.
      aliasFields - This maps contains the Field, that matches each alias, of each GraphQL type. This allows a proper deserialization of each alias value returned in the json response
      schema - 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(StringBuilder sb, Map<String,Object> parameters, boolean appendName) throws GraphQLRequestExecutionException
      Append this query field in the StringBuilder in 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 GraphQLRequestPreparationException
      Indicates 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 QueryField is a query, a mutation or a subscription. False otherwise.
    • getFields

      public List<QueryField> getFields()
    • getOwningClazz

      public Class<?> getOwningClazz()
    • getClazz

      public Class<?> getClazz()
    • getName

      public String getName()
    • getAlias

      public String getAlias()