fix(graphql): return empty arrays from loaders when loading collections
This commit is contained in:
parent
110a8aec97
commit
2a09f1d505
3 changed files with 34 additions and 2 deletions
|
@ -13,7 +13,7 @@ module Loaders
|
|||
|
||||
def perform(keys)
|
||||
query(keys).each { |record| fulfill(record.stable_id, [record].compact) }
|
||||
keys.each { |key| fulfill(key, nil) unless fulfilled?(key) }
|
||||
keys.each { |key| fulfill(key, []) unless fulfilled?(key) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -21,7 +21,7 @@ module Loaders
|
|||
fulfilled_value = @array ? [record].compact : record
|
||||
fulfill(record.public_send(@column), fulfilled_value)
|
||||
end
|
||||
keys.each { |key| fulfill(key, nil) unless fulfilled?(key) }
|
||||
keys.each { |key| fulfill(key, @array ? [] : nil) unless fulfilled?(key) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue