Sha256: f813de2384dbdde2a8dfcc3cb8ce4acae1580328e69c48d327911bfd85703635

Contents?: true

Size: 979 Bytes

Versions: 3

Compression:

Stored size: 979 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_name, 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.pre6 lib/graphql/schema/interface.rb
graphql-1.8.0.pre5 lib/graphql/schema/interface.rb
graphql-1.8.0.pre4 lib/graphql/schema/interface.rb