-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Is something like this possible?
class Types::SubcategoryType < Types::BaseObject
def records
BatchLoader.for(object.category_id).batch do |category_ids, loader|
records = Record.where(category_id: category_ids).group_by(&:subcategory_id)
loader.call(object.subcategory_id, records[object.id])
end
end
endThe goal is to load all records across all subcategories of a category at once. Currently the example above will return null because the batch call uses the category_id as the key, but on the loader call I'm using a subcategory_id.
Metadata
Metadata
Assignees
Labels
No labels