Sha256: 064e1b7dc17ea0f110ae288fecf629ed1efa940ea780aaebf3f75ab305305b39

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  class Schema
    class Interface < GraphQL::Schema::Member
      extend GraphQL::Schema::Member::HasFields
      field_class GraphQL::Schema::Field

      class << self

        # When this interface is added to a `GraphQL::Schema::Object`,
        # it calls this method. We add methods to the object by convention,
        # a nested module named `Implementation`
        def apply_implemented(object_class)
          if defined?(self::Implementation)
            object_class.include(self::Implementation)
          end
        end

        def to_graphql
          type_defn = GraphQL::InterfaceType.new
          type_defn.name = graphql_name
          type_defn.description = description
          fields.each do |field_inst|
            field_defn = field_inst.graphql_definition
            type_defn.fields[field_defn.name] = field_defn
          end
          type_defn
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graphql-1.8.0.pre3 lib/graphql/schema/interface.rb
graphql-1.8.0.pre2 lib/graphql/schema/interface.rb
graphql-1.8.0.pre1 lib/graphql/schema/interface.rb