Revised public fields, wrote more exhaustive specs

This commit is contained in:
Alberto Miedes Garcés
2017-05-15 20:13:20 +02:00
parent 3c7f60d625
commit ad8aba0739
9 changed files with 665 additions and 52 deletions

View File

@@ -44,11 +44,7 @@ module GraphQL
field(field_name, -> { created_types[field_type] }) do
resolve -> (object, arguments, context) do
association_target = object.send(field_name)
if association_target.nil?
nil
else
field_type.public_for_api.find_by(id: association_target.id)
end
association_target.present? ? field_type.public_for_api.find_by(id: association_target.id) : nil
end
end
when :multiple_association