Search in sources :

Example 1 with GraphQLInputType

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);
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with GraphQLInputType

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);
    }
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLNonNull(graphql.schema.GraphQLNonNull)

Example 3 with GraphQLInputType

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);
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLType(graphql.schema.GraphQLType)

Example 4 with GraphQLInputType

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);
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLUnmodifiedType(graphql.schema.GraphQLUnmodifiedType) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType)

Example 5 with GraphQLInputType

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);
}
Also used : GraphQLInputType(graphql.schema.GraphQLInputType) GraphQLList(graphql.schema.GraphQLList) GraphQLNullableType(graphql.schema.GraphQLNullableType)

Aggregations

GraphQLInputType (graphql.schema.GraphQLInputType)13 GraphQLInputObjectField (graphql.schema.GraphQLInputObjectField)4 GraphQLArgument (graphql.schema.GraphQLArgument)3 GraphQLInputObjectType (graphql.schema.GraphQLInputObjectType)3 Value (graphql.language.Value)2 GraphQLList (graphql.schema.GraphQLList)2 GraphQLType (graphql.schema.GraphQLType)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Scalars (graphql.Scalars)1 EnumTypeDefinition (graphql.language.EnumTypeDefinition)1 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)1 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)1 ObjectTypeDefinition (graphql.language.ObjectTypeDefinition)1 OperationTypeDefinition (graphql.language.OperationTypeDefinition)1 ScalarTypeDefinition (graphql.language.ScalarTypeDefinition)1 TypeDefinition (graphql.language.TypeDefinition)1 UnionTypeDefinition (graphql.language.UnionTypeDefinition)1