Sha256: adbf50bcd00cf2df6298dd40f9576d9f8b3c41e3817204c13164ae67a58eb3cd
Contents?: true
Size: 851 Bytes
Versions: 19
Compression:
Stored size: 851 Bytes
Contents
module GraphQL module StaticValidation class VariablesAreInputTypes include GraphQL::StaticValidation::Message::MessageHelper def validate(context) context.visitor[GraphQL::Language::Nodes::VariableDefinition] << -> (node, parent) { validate_is_input_type(node, context) } end private def validate_is_input_type(node, context) type_name = get_type_name(node.type) type = context.schema.types[type_name] if !type.kind.input? context.errors << message("#{type.name} isn't a valid input type (on $#{node.name})", node, context: context) end end def get_type_name(ast_type) if ast_type.respond_to?(:of_type) get_type_name(ast_type.of_type) else ast_type.name end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems