Class: GraphqlRails::Model::AddFieldsToGraphqlType

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/model/add_fields_to_graphql_type.rb

Overview

Adds graphql attributes as graphql fields to given graphql schema object.

Instance Method Summary collapse

Constructor Details

#initialize(klass:, attributes:) ⇒ AddFieldsToGraphqlType

Returns a new instance of AddFieldsToGraphqlType.



12
13
14
15
# File 'lib/graphql_rails/model/add_fields_to_graphql_type.rb', line 12

def initialize(klass:, attributes:)
  @klass = klass
  @attributes = attributes
end

Instance Method Details

#callObject



17
18
19
# File 'lib/graphql_rails/model/add_fields_to_graphql_type.rb', line 17

def call
  attributes.each { |attribute| define_graphql_field(attribute) }
end