Class InputParameter
java.lang.Object
com.graphql_java_generator.client.request.InputParameter
public class InputParameter
extends java.lang.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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InputParameter.InputParameterType
Indicates the kind of parameter -
Method Summary
Modifier and Type Method Description static void
appendInputParametersToGraphQLRequests(boolean writingGraphQLVariables, java.lang.StringBuilder sb, java.util.List<InputParameter> inputParameters, java.util.Map<java.lang.String,java.lang.Object> parameters)
java.lang.String
getBindParameterName()
graphql.schema.GraphQLScalarType
getGraphQLScalarType()
java.lang.String
getGraphQLTypeName()
int
getListDepth()
java.lang.String
getName()
InputParameter.InputParameterType
getType()
java.lang.Object
getValue()
java.lang.String
getValueForGraphqlQuery(boolean writingGraphQLVariables, java.util.Map<java.lang.String,java.lang.Object> bindVariables)
Returns the parameter, as it should be written in the GraphQL query.boolean
isItemMandatory()
boolean
isMandatory()
static InputParameter
newBindParameter(java.lang.String name, java.lang.String bindParameterName, InputParameter.InputParameterType type, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
Creates and returns a new instance ofInputParameter
, which is bound to a bind variable.static InputParameter
newGraphQLVariableParameter(java.lang.String name, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
Creates and returns a new instance ofInputParameter
, which value is given, and can not be changed afterwards.static InputParameter
newHardCodedParameter(java.lang.String name, java.lang.Object value, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)
Creates and returns a new instance ofInputParameter
, which value is given, and can not be changed afterwards.static java.util.List<InputParameter>
readTokenizerForInputParameters(QueryTokenizer qt, Directive directive, java.lang.Class<?> owningClass, java.lang.String fieldName)
Reads a list of input parameters, from aQueryTokenizer
.
-
Method Details
-
newBindParameter
public static InputParameter newBindParameter(java.lang.String name, java.lang.String bindParameterName, InputParameter.InputParameterType type, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)Creates and returns a new instance ofInputParameter
, which is bound to a bind variable. The value for this bind variable must be provided, when calling the request execution.- Parameters:
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 ofInputParameter
to creategraphQLTypeName
- The GraphQL type name of this parameter. For instance: "Human", for the type "[[Human]]"mandatory
- True if this parameter is mandatorylistDepth
- 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:
QueryExecutorSpringReactiveImpl#execute(String, ObjectResponse, List, Class)
-
newGraphQLVariableParameter
public static InputParameter newGraphQLVariableParameter(java.lang.String name, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)Creates and returns a new instance ofInputParameter
, which value is given, and can not be changed afterwards.- Parameters:
name
- The parameter name, as defined in the GraphQL schemagraphQLTypeName
- The GraphQL type name of this parameter. For instance: "Human", for the type "[[Human]]"mandatory
- True if this parameter is mandatorylistDepth
- 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(java.lang.String name, java.lang.Object value, java.lang.String graphQLTypeName, boolean mandatory, int listDepth, boolean itemMandatory)Creates and returns a new instance ofInputParameter
, which value is given, and can not be changed afterwards.- Parameters:
name
- The parameter name, as defined in the GraphQL schemavalue
- 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 mandatorylistDepth
- 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 java.util.List<InputParameter> readTokenizerForInputParameters(QueryTokenizer qt, Directive directive, java.lang.Class<?> owningClass, java.lang.String fieldName) throws GraphQLRequestPreparationExceptionReads a list of input parameters, from aQueryTokenizer
. 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 thisDirective
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 java.lang.String getName() -
getValue
public java.lang.Object getValue() -
getValueForGraphqlQuery
public java.lang.String getValueForGraphqlQuery(boolean writingGraphQLVariables, java.util.Map<java.lang.String,java.lang.Object> bindVariables) throws GraphQLRequestExecutionExceptionReturns 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 inbindParameterName
.- Returns:
- Throws:
GraphQLRequestExecutionException
-
getBindParameterName
public java.lang.String getBindParameterName() -
getType
-
getGraphQLTypeName
public java.lang.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, java.lang.StringBuilder sb, java.util.List<InputParameter> inputParameters, java.util.Map<java.lang.String,java.lang.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
-