Package graphql.execution
Class ValuesResolver
- java.lang.Object
-
- graphql.execution.ValuesResolver
-
public class ValuesResolver extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ValuesResolver.ValueMode
-
Constructor Summary
Constructors Modifier Constructor Description private
ValuesResolver()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.Map<java.lang.String,Argument>
argumentMap(java.util.List<Argument> arguments)
static CoercedVariables
coerceVariableValues(GraphQLSchema schema, java.util.List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, java.util.Locale locale)
This method coerces the "raw" variables values provided to the engine.static java.lang.Object
externalValueToInternalValue(GraphqlFieldVisibility fieldVisibility, java.lang.Object externalValue, GraphQLInputType type, GraphQLContext graphqlContext, java.util.Locale locale)
Converts an external value to an internal valuestatic java.util.Map<java.lang.String,java.lang.Object>
getArgumentValues(GraphQLCodeRegistry codeRegistry, java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
static java.util.Map<java.lang.String,java.lang.Object>
getArgumentValues(java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
This is not used for validation: the argument literals are all validated and the variables are validated (when coerced)private static java.util.Map<java.lang.String,java.lang.Object>
getArgumentValuesImpl(InputInterceptor inputInterceptor, GraphqlFieldVisibility fieldVisibility, java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
static <T> T
getInputValueImpl(GraphQLInputType inputType, InputValueWithState inputValue, GraphQLContext graphqlContext, java.util.Locale locale)
static java.util.Map<java.lang.String,NormalizedInputValue>
getNormalizedArgumentValues(java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
No validation as the arguments are assumed validstatic java.util.Map<java.lang.String,NormalizedInputValue>
getNormalizedVariableValues(GraphQLSchema schema, java.util.List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, java.util.Locale locale)
Normalized variables values are Literals with type information.private static boolean
isVariableAbsent(Value value, java.util.Map<java.lang.String,NormalizedInputValue> variables)
static java.lang.Object
literalToNormalizedValue(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
private static java.lang.Object
literalToNormalizedValueForInputObject(GraphqlFieldVisibility fieldVisibility, GraphQLInputObjectType type, ObjectValue inputObjectLiteral, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
private static java.util.List<java.lang.Object>
literalToNormalizedValueForList(GraphqlFieldVisibility fieldVisibility, GraphQLList type, Value value, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
private static void
validateOneOfInputTypes(GraphQLInputObjectType oneOfInputType, Value argumentValue, java.lang.String argumentName, java.lang.Object inputValue, java.util.Locale locale)
static java.lang.Object
valueToInternalValue(InputValueWithState inputValueWithState, GraphQLInputType inputType, GraphQLContext graphqlContext, java.util.Locale locale)
static Value<?>
valueToLiteral(@NotNull InputValueWithState inputValueWithState, @NotNull GraphQLType type, GraphQLContext graphqlContext, java.util.Locale locale)
static Value<?>
valueToLiteral(@NotNull GraphqlFieldVisibility fieldVisibility, @NotNull InputValueWithState inputValueWithState, @NotNull GraphQLType type, GraphQLContext graphqlContext, java.util.Locale locale)
Takes a value which can be in different states (internal, literal, external value) and converts into Literal
-
-
-
Method Detail
-
coerceVariableValues
public static CoercedVariables coerceVariableValues(GraphQLSchema schema, java.util.List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, java.util.Locale locale) throws CoercingParseValueException, NonNullableValueCoercedAsNullException
This method coerces the "raw" variables values provided to the engine. The coerced values will be used to provide arguments toDataFetchingEnvironment
This method is called once per execution and also performs validation.- Parameters:
schema
- the schemavariableDefinitions
- the variable definitionsrawVariables
- the supplied variablesgraphqlContext
- the GraphqlContext to uselocale
- the Locale to use- Returns:
- coerced variable values as a map
- Throws:
CoercingParseValueException
NonNullableValueCoercedAsNullException
-
getNormalizedVariableValues
public static java.util.Map<java.lang.String,NormalizedInputValue> getNormalizedVariableValues(GraphQLSchema schema, java.util.List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, java.util.Locale locale)
Normalized variables values are Literals with type information. No validation here!- Parameters:
schema
- the schema to usevariableDefinitions
- the list of variable definitionsrawVariables
- the raw variablesgraphqlContext
- the GraphqlContext to uselocale
- the Locale to use- Returns:
- a map of the normalised values
-
getArgumentValues
public static java.util.Map<java.lang.String,java.lang.Object> getArgumentValues(java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
This is not used for validation: the argument literals are all validated and the variables are validated (when coerced)- Parameters:
argumentTypes
- the list of argument typesarguments
- the AST argumentscoercedVariables
- the coerced variablesgraphqlContext
- the GraphqlContext to uselocale
- the Locale to use- Returns:
- a map of named argument values
-
getNormalizedArgumentValues
public static java.util.Map<java.lang.String,NormalizedInputValue> getNormalizedArgumentValues(java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
No validation as the arguments are assumed valid- Parameters:
argumentTypes
- the list of argument typesarguments
- the AST argumentsnormalizedVariables
- the normalised variables- Returns:
- a map of named normalised values
-
getArgumentValues
public static java.util.Map<java.lang.String,java.lang.Object> getArgumentValues(GraphQLCodeRegistry codeRegistry, java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
-
valueToLiteral
public static Value<?> valueToLiteral(@NotNull @NotNull GraphqlFieldVisibility fieldVisibility, @NotNull @NotNull InputValueWithState inputValueWithState, @NotNull @NotNull GraphQLType type, GraphQLContext graphqlContext, java.util.Locale locale)
Takes a value which can be in different states (internal, literal, external value) and converts into LiteralThis assumes the value is valid!
- Parameters:
fieldVisibility
- the field visibility to useinputValueWithState
- the input valuetype
- the type of input valuegraphqlContext
- the GraphqlContext to uselocale
- the Locale to use- Returns:
- a value converted to a literal
-
valueToLiteral
public static Value<?> valueToLiteral(@NotNull @NotNull InputValueWithState inputValueWithState, @NotNull @NotNull GraphQLType type, GraphQLContext graphqlContext, java.util.Locale locale)
-
valueToInternalValue
public static java.lang.Object valueToInternalValue(InputValueWithState inputValueWithState, GraphQLInputType inputType, GraphQLContext graphqlContext, java.util.Locale locale) throws CoercingParseValueException, CoercingParseLiteralException
-
externalValueToInternalValue
public static java.lang.Object externalValueToInternalValue(GraphqlFieldVisibility fieldVisibility, java.lang.Object externalValue, GraphQLInputType type, GraphQLContext graphqlContext, java.util.Locale locale)
Converts an external value to an internal value- Parameters:
fieldVisibility
- the field visibility to useexternalValue
- the input external valuetype
- the type of input valuegraphqlContext
- the GraphqlContext to uselocale
- the Locale to use- Returns:
- a value converted to an internal value
-
getInputValueImpl
@Nullable public static <T> T getInputValueImpl(GraphQLInputType inputType, InputValueWithState inputValue, GraphQLContext graphqlContext, java.util.Locale locale)
-
getArgumentValuesImpl
private static java.util.Map<java.lang.String,java.lang.Object> getArgumentValuesImpl(InputInterceptor inputInterceptor, GraphqlFieldVisibility fieldVisibility, java.util.List<GraphQLArgument> argumentTypes, java.util.List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, java.util.Locale locale)
-
validateOneOfInputTypes
private static void validateOneOfInputTypes(GraphQLInputObjectType oneOfInputType, Value argumentValue, java.lang.String argumentName, java.lang.Object inputValue, java.util.Locale locale)
-
argumentMap
private static java.util.Map<java.lang.String,Argument> argumentMap(java.util.List<Argument> arguments)
-
literalToNormalizedValue
public static java.lang.Object literalToNormalizedValue(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
-
literalToNormalizedValueForInputObject
private static java.lang.Object literalToNormalizedValueForInputObject(GraphqlFieldVisibility fieldVisibility, GraphQLInputObjectType type, ObjectValue inputObjectLiteral, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
-
literalToNormalizedValueForList
private static java.util.List<java.lang.Object> literalToNormalizedValueForList(GraphqlFieldVisibility fieldVisibility, GraphQLList type, Value value, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
-
isVariableAbsent
private static boolean isVariableAbsent(Value value, java.util.Map<java.lang.String,NormalizedInputValue> variables)
- Returns:
- true if variable is absent from input, and if value is NOT a variable then false
-
-