Sha256: 30b5cbb2a44bd48a825d66a3ef661a4758a7caca239a1be22f03efd017e4bc4d
Contents?: true
Size: 803 Bytes
Versions: 25
Compression:
Stored size: 803 Bytes
Contents
class GraphQL::StaticValidation::FragmentsAreOnCompositeTypes include GraphQL::StaticValidation::Message::MessageHelper HAS_TYPE_CONDITION = [ GraphQL::Language::Nodes::FragmentDefinition, GraphQL::Language::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::Language::Visitor::SKIP end end end
Version data entries
25 entries across 25 versions & 1 rubygems