Sha256: c8fd8d9d70d577347cfcda07521a54c349a5e05b77a080fa07a90c2484155e99
Contents?: true
Size: 959 Bytes
Versions: 11
Compression:
Stored size: 959 Bytes
Contents
class GraphQL::StaticValidation::FieldsAreDefinedOnType include GraphQL::StaticValidation::Message::MessageHelper def validate(context) visitor = context.visitor visitor[GraphQL::Language::Nodes::Field] << -> (node, parent) { return if context.skip_field?(node.name) parent_type = context.object_types[-2] parent_type = parent_type.unwrap validate_field(context.errors, node, parent_type, parent) } end private def validate_field(errors, ast_field, parent_type, parent) if parent_type.kind.union? errors << message("Selections can't be made directly on unions (see selections on #{parent_type.name})", parent) return GraphQL::Language::Visitor::SKIP end field = parent_type.fields[ast_field.name] if field.nil? errors << message("Field '#{ast_field.name}' doesn't exist on type '#{parent_type.name}'", parent) return GraphQL::Language::Visitor::SKIP end end end
Version data entries
11 entries across 11 versions & 1 rubygems