module GraphQL::StaticValidation::FragmentSpreadsArePossible
def validate_fragment_in_scope(parent_type, child_type, node, context, path)
def validate_fragment_in_scope(parent_type, child_type, node, context, path) if !child_type.kind.fields? # It's not a valid fragment type, this error was handled someplace else return end parent_types = context.warden.possible_types(parent_type.unwrap) child_types = context.warden.possible_types(child_type.unwrap) if child_types.none? { |c| parent_types.include?(c) } name = node.respond_to?(:name) ? " #{node.name}" : "" add_error(GraphQL::StaticValidation::FragmentSpreadsArePossibleError.new( "Fragment#{name} on #{child_type.name} can't be spread inside #{parent_type.name}", nodes: node, path: path, fragment_name: name.empty? ? "unknown" : name, type: child_type.name, parent: parent_type.name )) end end