Sha256: be45e99fbe04f67d8faa13227523d2558135ab9e9b9700a38c9e1aad968e5be3
Contents?: true
Size: 928 Bytes
Versions: 9
Compression:
Stored size: 928 Bytes
Contents
class GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTyped include GraphQL::StaticValidation::Message::MessageHelper def validate(context) literal_validator = GraphQL::StaticValidation::LiteralValidator.new context.visitor[GraphQL::Language::Nodes::Variable] << -> (node, parent) { if !node.default_value.nil? validate_default_value(node, literal_validator, context) end } end def validate_default_value(node, literal_validator, context) value = node.default_value if node.type.is_a?(GraphQL::Language::Nodes::NonNullType) context.errors << message("Non-null variable $#{node.name} can't have a default value", node) else type = context.schema.type_from_ast(node.type) if !literal_validator.validate(value, type) context.errors << message("Default value for $#{node.name} doesn't match type #{type}", node) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems