Sha256: 3fd587c7fa05df0ed89093d3e0f5ada9a92bd992371b855c3c2deedf260f0501

Contents?: true

Size: 947 Bytes

Versions: 10

Compression:

Stored size: 947 Bytes

Contents

module GraphQL
  # A collection of types which implement the same fields
  #
  # @example An interface with three required fields
  #   DeviceInterface = GraphQL::InterfaceType.define do
  #     name("Device")
  #     description("Hardware devices for computing")
  #
  #     field :ram, types.String
  #     field :processor, ProcessorType
  #     field :release_year, types.Int
  #   end
  #
  class InterfaceType < GraphQL::BaseType
    include GraphQL::BaseType::HasPossibleTypes
    accepts_definitions :resolve_type, field: GraphQL::Define::AssignObjectField

    attr_accessor :fields

    def initialize
      @fields = {}
    end

    def kind
      GraphQL::TypeKinds::INTERFACE
    end

    # @return [GraphQL::Field] The defined field for `field_name`
    def get_field(field_name)
      fields[field_name]
    end

    # @return [Array<GraphQL::Field>] All fields on this type
    def all_fields
      fields.values
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
graphql-0.16.1 lib/graphql/interface_type.rb
graphql-0.16.0 lib/graphql/interface_type.rb
graphql-0.15.3 lib/graphql/interface_type.rb
graphql-0.15.2 lib/graphql/interface_type.rb
graphql-0.14.2 lib/graphql/interface_type.rb
graphql-0.15.1 lib/graphql/interface_type.rb
graphql-0.15.0 lib/graphql/interface_type.rb
graphql-0.14.1 lib/graphql/interface_type.rb
graphql-0.14.0 lib/graphql/interface_type.rb
graphql-0.13.0 lib/graphql/interface_type.rb