Method: GraphQL::Schema::Loader.build_fields

Defined in:
lib/graphql/schema/loader.rb

.build_fields(type_defn, fields, type_resolver) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/graphql/schema/loader.rb', line 173

def build_fields(type_defn, fields, type_resolver)
  loader = self
  fields.each do |field_hash|
    unwrapped_field_hash = field_hash
    while (of_type = unwrapped_field_hash["ofType"])
      unwrapped_field_hash = of_type
    end

    type_defn.field(
      field_hash["name"],
      type: type_resolver.call(field_hash["type"]),
      description: field_hash["description"],
      deprecation_reason: field_hash["deprecationReason"],
      null: true,
      camelize: false,
      connection_extension: nil,
    ) do
      if !field_hash["args"].empty?
        loader.build_arguments(self, field_hash["args"], type_resolver)
      end
    end
  end
end