public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, GraphQLType graphQLType) { super(format("Variable '%s' has coerced Null value for NonNull type '%s'", variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType))); this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation()); }
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, String fieldName, GraphQLType graphQLType) { super(format("Field '%s' of variable '%s' has coerced Null value for NonNull type '%s'", fieldName, variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType))); this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation()); }
@Override public void leaveOperationDefinition(OperationDefinition operationDefinition) { for (VariableDefinition variableDefinition : variableDefinitions) { if (!usedVariables.contains(variableDefinition.getName())) { String message = String.format("Unused variable %s", variableDefinition.getName()); addError(ValidationErrorType.UnusedVariable, variableDefinition.getSourceLocation(), message); } } }
private Builder(VariableDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.type = existing.getType(); this.defaultValue = existing.getDefaultValue(); this.ignoredChars = existing.getIgnoredChars(); }
@Override public VariableDefinition deepCopy() { return new VariableDefinition(name, deepCopy(type), deepCopy(defaultValue), getSourceLocation(), getComments(), getIgnoredChars() ); }
@Override public void checkVariableDefinition(VariableDefinition variableDefinition) { GraphQLInputType inputType = getValidationContext().getInputType(); if (inputType == null) return; if (isNonNull(inputType) && 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); } } }
@Override public void checkVariableDefinition(VariableDefinition variableDefinition) { TypeName unmodifiedAstType = getValidationUtil().getUnmodifiedType(variableDefinition.getType()); GraphQLType type = getValidationContext().getSchema().getType(unmodifiedAstType.getName()); if (type == null) return; if (!isInput(type)) { String message = "Wrong type for a variable"; addError(ValidationErrorType.NonInputTypeOnVariable, variableDefinition.getSourceLocation(), message); } } }
"Variable '" + inputName + "' has an invalid value. " + e.getMessage(), e.getCause(), variableDefinition.getSourceLocation() );
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, GraphQLType graphQLType) { super(format("Variable '%s' has coerced Null value for NonNull type '%s'", variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType))); this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation()); }
public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinition, String fieldName, GraphQLType graphQLType) { super(format("Field '%s' of variable '%s' has coerced Null value for NonNull type '%s'", fieldName, variableDefinition.getName(), GraphQLTypeUtil.simplePrint(graphQLType))); this.sourceLocations = Collections.singletonList(variableDefinition.getSourceLocation()); }
@Override public void leaveOperationDefinition(OperationDefinition operationDefinition) { for (VariableDefinition variableDefinition : variableDefinitions) { if (!usedVariables.contains(variableDefinition.getName())) { String message = String.format("Unused variable %s", variableDefinition.getName()); addError(ValidationErrorType.UnusedVariable, variableDefinition.getSourceLocation(), message); } } }
@Override public VariableDefinition deepCopy() { return new VariableDefinition(name, deepCopy(type), deepCopy(defaultValue), getSourceLocation(), getComments(), getIgnoredChars() ); }
private Builder(VariableDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.type = existing.getType(); this.defaultValue = existing.getDefaultValue(); this.ignoredChars = existing.getIgnoredChars(); }
@Override public void checkVariableDefinition(VariableDefinition variableDefinition) { GraphQLInputType inputType = getValidationContext().getInputType(); if (inputType == null) return; if (isNonNull(inputType) && 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); } } }
@Override public void checkVariableDefinition(VariableDefinition variableDefinition) { TypeName unmodifiedAstType = getValidationUtil().getUnmodifiedType(variableDefinition.getType()); GraphQLType type = getValidationContext().getSchema().getType(unmodifiedAstType.getName()); if (type == null) return; if (!isInput(type)) { String message = "Wrong type for a variable"; addError(ValidationErrorType.NonInputTypeOnVariable, variableDefinition.getSourceLocation(), message); } } }
"Variable '" + inputName + "' has an invalid value. " + e.getMessage(), e.getCause(), variableDefinition.getSourceLocation() );