Class InputParameter
java.lang.Object
com.graphql_java_generator.client.request.InputParameter
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
Modifier and TypeClassDescriptionstatic enum
Indicates the kind of parameter -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendInputParametersToGraphQLRequests
(boolean writingGraphQLVariables, StringBuilder sb, List<InputParameter> inputParameters, Map<String, Object> parameters) graphql.schema.GraphQLScalarType
int
getName()
getStringContentForGraphqlQuery
(boolean writingGraphQLVariables, Map<String, Object> bindVariables) Returns the parameter, as it should be written in the GraphQL query.getType()
getValue()
static Object
getValueForGraphqlQuery
(String parameterName, Object val, int listDepth, graphql.schema.GraphQLScalarType graphQLScalarTypeParam, Map<String, Object> bindVariables) getValueForGraphqlQuery
(Map<String, Object> bindVariables) Returns the parameter value, as-is, without any escape characterboolean
boolean
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 ofInputParameter
, which is bound to a bind variable.static InputParameter
newGraphQLVariableParameter
(String schema, String name, 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
(String schema, String name, Object value, 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 List<InputParameter>
readTokenizerForInputParameters
(QueryTokenizer qt, Directive directive, Class<?> owningClass, String fieldName, String schema) Reads a list of input parameters, from aQueryTokenizer
.
-
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 ofInputParameter
, 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 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:
-
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 ofInputParameter
, 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 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(String schema, String name, Object value, 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:
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 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 List<InputParameter> readTokenizerForInputParameters(QueryTokenizer qt, Directive directive, Class<?> owningClass, String fieldName, String schema) throws GraphQLRequestPreparationException Reads 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
-
getValue
-
getValueForGraphqlQuery
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 inbindParameterName
.- Returns:
- Throws:
GraphQLRequestExecutionException
-
getValueForGraphqlQuery
-
getStringContentForGraphqlQuery
public String getStringContentForGraphqlQuery(boolean writingGraphQLVariables, Map<String, 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
-
getType
-
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
-