Sha256: bbe314a81e04f77281e2778a271ce645e8ab2880759a70ab46611dd769d0d022

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module GraphQL
  class Schema
    # This class joins an object type to an abstract type (interface or union) of which
    # it is a member.
    #
    # TODO: Not yet implemented for interfaces.
    class TypeMembership
      # @return [Class<GraphQL::Schema::Object>]
      attr_reader :object_type

      # @return [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
      attr_reader :abstract_type

      # Called when an object is hooked up to an abstract type, such as {Schema::Union.possible_types}
      # or {Schema::Object.implements} (for interfaces).
      #
      # @param abstract_type [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
      # @param object_type [Class<GraphQL::Schema::Object>]
      # @param options [Hash] Any options passed to `.possible_types` or `.implements`
      def initialize(abstract_type, object_type, **options)
        @abstract_type = abstract_type
        @object_type = object_type
        @options = options
      end

      # @return [Boolean] if false, {#object_type} will be treated as _not_ a member of {#abstract_type}
      def visible?(_ctx)
        true
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
graphql-1.9.21 lib/graphql/schema/type_membership.rb
graphql-1.9.20 lib/graphql/schema/type_membership.rb
graphql-1.9.19 lib/graphql/schema/type_membership.rb
graphql-1.9.18 lib/graphql/schema/type_membership.rb