Package graphql.execution
Class ValuesResolver
java.lang.Object
graphql.execution.ValuesResolver
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionargumentMap
(List<Argument> arguments) static CoercedVariables
coerceVariableValues
(GraphQLSchema schema, List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, Locale locale) This method coerces the "raw" variables values provided to the engine.static Object
externalValueToInternalValue
(GraphqlFieldVisibility fieldVisibility, Object externalValue, GraphQLInputType type, GraphQLContext graphqlContext, Locale locale) Converts an external value to an internal valuegetArgumentValues
(GraphQLCodeRegistry codeRegistry, List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, Locale locale) getArgumentValues
(List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, Locale locale) This is not used for validation: the argument literals are all validated and the variables are validated (when coerced)getArgumentValuesImpl
(InputInterceptor inputInterceptor, GraphqlFieldVisibility fieldVisibility, List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, Locale locale) static <T> T
getInputValueImpl
(GraphQLInputType inputType, InputValueWithState inputValue, GraphQLContext graphqlContext, Locale locale) static Map
<String, NormalizedInputValue> getNormalizedArgumentValues
(List<GraphQLArgument> argumentTypes, List<Argument> arguments, Map<String, NormalizedInputValue> normalizedVariables) No validation as the arguments are assumed validstatic Map
<String, NormalizedInputValue> getNormalizedVariableValues
(GraphQLSchema schema, List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, Locale locale) Normalized variables values are Literals with type information.private static boolean
isVariableAbsent
(Value value, Map<String, NormalizedInputValue> variables) static Object
literalToNormalizedValue
(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, Map<String, NormalizedInputValue> normalizedVariables) private static Object
literalToNormalizedValueForInputObject
(GraphqlFieldVisibility fieldVisibility, GraphQLInputObjectType type, ObjectValue inputObjectLiteral, Map<String, NormalizedInputValue> normalizedVariables) literalToNormalizedValueForList
(GraphqlFieldVisibility fieldVisibility, GraphQLList type, Value value, Map<String, NormalizedInputValue> normalizedVariables) private static void
validateOneOfInputTypes
(GraphQLInputObjectType oneOfInputType, Value argumentValue, String argumentName, Object inputValue, Locale locale) static Object
valueToInternalValue
(InputValueWithState inputValueWithState, GraphQLInputType inputType, GraphQLContext graphqlContext, Locale locale) static Value
<?> valueToLiteral
(@NotNull InputValueWithState inputValueWithState, @NotNull GraphQLType type, GraphQLContext graphqlContext, Locale locale) static Value
<?> valueToLiteral
(@NotNull GraphqlFieldVisibility fieldVisibility, @NotNull InputValueWithState inputValueWithState, @NotNull GraphQLType type, GraphQLContext graphqlContext, Locale locale) Takes a value which can be in different states (internal, literal, external value) and converts into Literal
-
Constructor Details
-
ValuesResolver
private ValuesResolver()
-
-
Method Details
-
coerceVariableValues
public static CoercedVariables coerceVariableValues(GraphQLSchema schema, List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, 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 Map<String,NormalizedInputValue> getNormalizedVariableValues(GraphQLSchema schema, List<VariableDefinition> variableDefinitions, RawVariables rawVariables, GraphQLContext graphqlContext, 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 Map<String,Object> getArgumentValues(List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, 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 Map<String,NormalizedInputValue> getNormalizedArgumentValues(List<GraphQLArgument> argumentTypes, List<Argument> arguments, Map<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 Map<String,Object> getArgumentValues(GraphQLCodeRegistry codeRegistry, List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, Locale locale) -
valueToLiteral
public static Value<?> valueToLiteral(@NotNull @NotNull GraphqlFieldVisibility fieldVisibility, @NotNull @NotNull InputValueWithState inputValueWithState, @NotNull @NotNull GraphQLType type, GraphQLContext graphqlContext, 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, Locale locale) -
valueToInternalValue
public static Object valueToInternalValue(InputValueWithState inputValueWithState, GraphQLInputType inputType, GraphQLContext graphqlContext, Locale locale) throws CoercingParseValueException, CoercingParseLiteralException -
externalValueToInternalValue
public static Object externalValueToInternalValue(GraphqlFieldVisibility fieldVisibility, Object externalValue, GraphQLInputType type, GraphQLContext graphqlContext, 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, Locale locale) -
getArgumentValuesImpl
private static Map<String,Object> getArgumentValuesImpl(InputInterceptor inputInterceptor, GraphqlFieldVisibility fieldVisibility, List<GraphQLArgument> argumentTypes, List<Argument> arguments, CoercedVariables coercedVariables, GraphQLContext graphqlContext, Locale locale) -
validateOneOfInputTypes
private static void validateOneOfInputTypes(GraphQLInputObjectType oneOfInputType, Value argumentValue, String argumentName, Object inputValue, Locale locale) -
argumentMap
-
literalToNormalizedValue
public static Object literalToNormalizedValue(GraphqlFieldVisibility fieldVisibility, GraphQLType type, Value inputValue, Map<String, NormalizedInputValue> normalizedVariables) -
literalToNormalizedValueForInputObject
private static Object literalToNormalizedValueForInputObject(GraphqlFieldVisibility fieldVisibility, GraphQLInputObjectType type, ObjectValue inputObjectLiteral, Map<String, NormalizedInputValue> normalizedVariables) -
literalToNormalizedValueForList
private static List<Object> literalToNormalizedValueForList(GraphqlFieldVisibility fieldVisibility, GraphQLList type, Value value, Map<String, NormalizedInputValue> normalizedVariables) -
isVariableAbsent
- Returns:
- true if variable is absent from input, and if value is NOT a variable then false
-