Sha256: b6bea80a44f77dab05963b48421bd9d6e67c54068aed3f46a1c6d97755bcd467

Contents?: true

Size: 960 Bytes

Versions: 41

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class Schema
    class Union < GraphQL::Schema::Member
      extend GraphQL::Schema::Member::AcceptsDefinition

      class << self
        def possible_types(*types)
          if types.any?
            @possible_types = types
          else
            all_possible_types = @possible_types || []
            all_possible_types += super if defined?(super)
            all_possible_types.uniq
          end
        end

        def to_graphql
          type_defn = GraphQL::UnionType.new
          type_defn.name = graphql_name
          type_defn.description = description
          type_defn.possible_types = possible_types
          if respond_to?(:resolve_type)
            type_defn.resolve_type = method(:resolve_type)
          end
          type_defn.metadata[:type_class] = self
          type_defn
        end

        def kind
          GraphQL::TypeKinds::UNION
        end
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
graphql-1.8.18 lib/graphql/schema/union.rb
graphql-1.9.16 lib/graphql/schema/union.rb
graphql-1.9.15 lib/graphql/schema/union.rb
graphql-1.9.14 lib/graphql/schema/union.rb
graphql-1.9.13 lib/graphql/schema/union.rb
graphql-1.9.12 lib/graphql/schema/union.rb
graphql-1.9.11 lib/graphql/schema/union.rb
graphql-1.9.10 lib/graphql/schema/union.rb
graphql-1.9.9 lib/graphql/schema/union.rb
graphql-1.9.8 lib/graphql/schema/union.rb
graphql-1.9.7 lib/graphql/schema/union.rb
graphql-1.9.6 lib/graphql/schema/union.rb
graphql-1.9.5 lib/graphql/schema/union.rb
graphql-1.9.4 lib/graphql/schema/union.rb
graphql-1.9.3 lib/graphql/schema/union.rb
graphql-1.9.2 lib/graphql/schema/union.rb
graphql-1.8.17 lib/graphql/schema/union.rb
graphql-1.8.16 lib/graphql/schema/union.rb
graphql-1.9.1 lib/graphql/schema/union.rb
graphql-1.9.0 lib/graphql/schema/union.rb