50e21a89a0
This suggests possibly related issues when the user types a title. This uses GraphQL to allow the frontend to request the exact data that is requires. We also get free caching through the Vue Apollo plugin. With this we can include the ability to import .graphql files in JS and Vue files. Also we now have the Vue test utils library to make testing Vue components easier. Closes #22071
29 lines
849 B
Ruby
29 lines
849 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Graphql
|
|
module Loaders
|
|
class BatchModelLoader
|
|
attr_reader :model_class, :model_id
|
|
|
|
def initialize(model_class, model_id)
|
|
@model_class, @model_id = model_class, model_id
|
|
end
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
def find
|
|
BatchLoader.for({ model: model_class, id: model_id }).batch do |loader_info, loader|
|
|
per_model = loader_info.group_by { |info| info[:model] }
|
|
per_model.each do |model, info|
|
|
ids = info.map { |i| i[:id] }
|
|
results = model.where(id: ids)
|
|
|
|
results.each { |record| loader.call({ model: model, id: record.id }, record) }
|
|
end
|
|
end
|
|
end
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
end
|
|
end
|
|
end
|
|
end
|