Class InputParameter

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

public class InputParameter extends Object
Contains an input parameter, to be sent to a query (mutation...). It can be either:
    • A hard coded value
      A bind variable, which value must be provided when executing the query
  • Author:
    etienne-sf
    • Method Details

      • newBindParameter

        public static InputParameter newBindParameter(String schema, String name, String bindParameterName, InputParameter.InputParameterType type, String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
        Creates and returns a new instance of InputParameter, which is bound to a bind variable. The value for this bind variable must be provided, when calling the request execution.
        Parameters:
        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.
        name -
        bindParameterName - The name of the bind parameter, as defined in the GraphQL response definition. It is mandator for bind parameters, so it may not be null here. Please read the client doc for more information on input parameters and bind variables.
        type - The kind of InputParameter to create
        graphQLTypeName - The GraphQL type name of this parameter. For instance: "Human", for the type "[[Human]]"
        mandatory - True if this parameter is mandatory
        listDepth - The depth of the list for this input parameter: 0 if this parameter is not a list. And 2, for instance, if the parameter's type is "[[Int]]"
        itemMandatory - Used only if this parameter is a list. In this case: true if the item of the list are mandatory, false otherwise
        Returns:
        The newly created InputParameter, according to these parameters
        See Also:
        • RequestExecutionSpringReactiveImpl#execute(String, ObjectResponse, List, Class)
      • newGraphQLVariableParameter

        public static InputParameter newGraphQLVariableParameter(String schema, String name, String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
        Creates and returns a new instance of InputParameter, which value is given, and can not be changed afterwards.
        Parameters:
        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.
        name - The parameter name, as defined in the GraphQL schema
        graphQLTypeName - The GraphQL type name of this parameter. For instance: "Human", for the type "[[Human]]"
        mandatory - True if this parameter is mandatory
        listDepth - The depth of the list for this input parameter: 0 if this parameter is not a list. And 2, for instance, if the parameter's type is "[[Int]]"
        itemMandatory - Used only if this parameter is a list. In this case: true if the item of the list are mandatory, false otherwise
        Returns:
        The newly created InputParameter, according to these parameters
      • newHardCodedParameter

        public static InputParameter newHardCodedParameter(String schema, String name, Object value, String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
        Creates and returns a new instance of InputParameter, which value is given, and can not be changed afterwards.
        Parameters:
        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.
        name - The parameter name, as defined in the GraphQL schema
        value - The value to send, for this input parameter. If null, it's a bind parameter. The bindParameterName is then mandatory.
        graphQLTypeName - The GraphQL type name of this parameter. For instance: "Human", for the type "[[Human]]"
        mandatory - True if this parameter is mandatory
        listDepth - The depth of the list for this input parameter: 0 if this parameter is not a list. And 2, for instance, if the parameter's type is "[[Int]]"
        itemMandatory - Used only if this parameter is a list. In this case: true if the item of the list are mandatory, false otherwise
        Returns:
        The newly created InputParameter, according to these parameters
      • readTokenizerForInputParameters

        public static List<InputParameter> readTokenizerForInputParameters(QueryTokenizer qt, Directive directive, Class<?> owningClass, String fieldName, String schema) throws GraphQLRequestPreparationException
        Reads a list of input parameters, from a QueryTokenizer. It can be the list of parameters for a Field or for a Directive. It can be either a Field of a Query, Mutation or Subscription, or a Field of a standard GraphQL Type, or any directive...
        Parameters:
        qt - The StringTokenizer, where the opening parenthesis has been read. It will be read until and including the next closing parenthesis.
        directive - if not null, then this method is reading the input parameters (arguments) for this Directive
        owningClass - if not null, then this method is reading the input parameters for the field fieldName of this class.
        fieldName - if owningClass, this is the name of the field, whose input parameters are being read.
        Throws:
        GraphQLRequestPreparationException - If the request string is invalid
      • getName

        public String getName()
      • getValue

        public Object getValue()
      • getValueForGraphqlQuery

        public Object getValueForGraphqlQuery(Map<String,Object> bindVariables)
        Returns the parameter value, as-is, without any escape character
        Parameters:
        bindVariables - The map for the bind variables. It may be null, if this input parameter is a hard coded one. If this parameter is a Bind Variable, then bindVariables is mandatory, and it must contain a value for th bind parameter which name is stored in bindParameterName.
        Returns:
        Throws:
        GraphQLRequestExecutionException
      • getValueForGraphqlQuery

        public static Object getValueForGraphqlQuery(String parameterName, Object val, int listDepth, graphql.schema.GraphQLScalarType graphQLScalarTypeParam, Map<String,Object> bindVariables)
      • getStringContentForGraphqlQuery

        public String getStringContentForGraphqlQuery(boolean writingGraphQLVariables, Map<String,Object> bindVariables) throws GraphQLRequestExecutionException
        Returns the parameter, as it should be written in the GraphQL query. For instance:
        • String: a "string" -> "a \"string\""
        • Enum: EPISODE -> EPISODE (no escape or double quote here)
        Parameters:
        writingGraphQLVariables - true if this call is done, while writing the value for the "variables" field of the json request.
        bindVariables - The map for the bind variables. It may be null, if this input parameter is a hard coded one. If this parameter is a Bind Variable, then bindVariables is mandatory, and it must contain a value for th bind parameter which name is stored in bindParameterName.
        Returns:
        Throws:
        GraphQLRequestExecutionException
      • getBindParameterName

        public String getBindParameterName()
      • getType

      • getGraphQLTypeName

        public String getGraphQLTypeName()
      • getGraphQLScalarType

        public graphql.schema.GraphQLScalarType getGraphQLScalarType()
      • isItemMandatory

        public boolean isItemMandatory()
      • getListDepth

        public int getListDepth()
      • isMandatory

        public boolean isMandatory()
      • appendInputParametersToGraphQLRequests

        public static void appendInputParametersToGraphQLRequests(boolean writingGraphQLVariables, StringBuilder sb, List<InputParameter> inputParameters, Map<String,Object> parameters) throws GraphQLRequestExecutionException
        Parameters:
        writingGraphQLVariables - true if this call is done, while writing the value for the "variables" field of the json request.
        sb -
        inputParameters -
        parameters -
        Throws:
        GraphQLRequestExecutionException