Sha256: 46fa79318c83b41bbc2955344c414bd3fbbdc5e4cb6da2013404ddb4364c7e67
Contents?: true
Size: 773 Bytes
Versions: 3
Compression:
Stored size: 773 Bytes
Contents
class GraphQL::StaticValidation::FragmentsAreOnCompositeTypes include GraphQL::StaticValidation::Message::MessageHelper HAS_TYPE_CONDITION = [ GraphQL::Nodes::FragmentDefinition, GraphQL::Nodes::InlineFragment, ] def validate(context) HAS_TYPE_CONDITION.each do |node_class| context.visitor[node_class] << -> (node, parent) { validate_type_is_composite(node, context) } end end private def validate_type_is_composite(node, context) type_name = node.type type_def = context.schema.types[type_name] if type_def.nil? || !type_def.kind.composite? context.errors << message("Invalid fragment on type #{type_name} (must be Union, Interface or Object)", node) GraphQL::Visitor::SKIP end end end
Version data entries
3 entries across 3 versions & 1 rubygems