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
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 @NotNull 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)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.static java.lang.Object
literalToNormalizedValue(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
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
@NotNull public static @NotNull 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)
-
literalToNormalizedValue
public static java.lang.Object literalToNormalizedValue(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, java.util.Map<java.lang.String,NormalizedInputValue> normalizedVariables)
-
-