use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class AstValueHelper method handleInputObject.
private static Value handleInputObject(Object _value, GraphQLInputObjectType type) {
Map mapValue = objToMap(_value);
List<GraphQLInputObjectField> fields = type.getFields();
List<ObjectField> fieldNodes = new ArrayList<>();
fields.forEach(field -> {
GraphQLInputType fieldType = field.getType();
Value nodeValue = astFromValue(mapValue.get(field.getName()), fieldType);
if (nodeValue != null) {
fieldNodes.add(new ObjectField(field.getName(), nodeValue));
}
});
return new ObjectValue(fieldNodes);
}
use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class VariableDefaultValuesOfCorrectType method checkVariableDefinition.
@Override
public void checkVariableDefinition(VariableDefinition variableDefinition) {
GraphQLInputType inputType = getValidationContext().getInputType();
if (inputType == null)
return;
if (inputType instanceof GraphQLNonNull && variableDefinition.getDefaultValue() != null) {
String message = "Missing value for non null type";
addError(ValidationErrorType.DefaultForNonNullArgument, variableDefinition.getSourceLocation(), message);
}
if (variableDefinition.getDefaultValue() != null && !getValidationUtil().isValidLiteralValue(variableDefinition.getDefaultValue(), inputType, getValidationContext().getSchema())) {
String message = String.format("Bad default value %s for type %s", variableDefinition.getDefaultValue(), inputType.getName());
addError(ValidationErrorType.BadValueForDefaultArg, variableDefinition.getSourceLocation(), message);
}
}
use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(VariableDefinition variableDefinition) {
GraphQLType type = TypeFromAST.getTypeFromAST(schema, variableDefinition.getType());
addInputType(type != null ? (GraphQLInputType) type : null);
}
use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(ObjectField objectField) {
GraphQLUnmodifiedType objectType = schemaUtil.getUnmodifiedType(getInputType());
GraphQLInputType inputType = null;
if (objectType instanceof GraphQLInputObjectType) {
GraphQLInputObjectType inputObjectType = (GraphQLInputObjectType) objectType;
GraphQLInputObjectField inputField = schema.getFieldVisibility().getFieldDefinition(inputObjectType, objectField.getName());
if (inputField != null)
inputType = inputField.getType();
}
addInputType(inputType);
}
use of graphql.schema.GraphQLInputType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(ArrayValue arrayValue) {
GraphQLNullableType nullableType = getNullableType(getInputType());
GraphQLInputType inputType = null;
if (nullableType instanceof GraphQLList) {
inputType = (GraphQLInputType) ((GraphQLList) nullableType).getWrappedType();
}
addInputType(inputType);
}
Aggregations