Sha256: 876dbe198c373840e2e1fe2a3ed36f1b8cf11a6a8246b9b8d82e61f1fe947084

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

class GraphQL::Union
  include GraphQL::NonNullWithBang
  attr_reader :name, :description, :possible_types
  def initialize(name, desc, types)
    @name = name
    @description = desc
    @possible_types = types
  end

  def kind
    GraphQL::TypeKinds::UNION
  end

  # Find a type in this union for a given object.
  # Reimplement if needed
  def resolve_type(object)
    type_name = object.class.name
    possible_types.find {|t| t.name == type_name}
  end

  def to_s
    "<GraphQL::Union #{name}>"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-0.2.0 lib/graph_ql/union.rb