Fix bug in singular_association resolver
This commit is contained in:
@@ -49,7 +49,14 @@ module GraphQL
|
|||||||
field(field_name, SCALAR_TYPES[field_type])
|
field(field_name, SCALAR_TYPES[field_type])
|
||||||
when :singular_association
|
when :singular_association
|
||||||
field(field_name, -> { api_types_creator.created_types[field_type] }) do
|
field(field_name, -> { api_types_creator.created_types[field_type] }) do
|
||||||
resolve -> (object, arguments, context) { field_type.public_for_api.find_by(id: object.id) }
|
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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when :multiple_association
|
when :multiple_association
|
||||||
field_type = field_type.first
|
field_type = field_type.first
|
||||||
|
|||||||
Reference in New Issue
Block a user