Class: CardDB::Rails::GraphQL::Dataloader::PublisherSource

Inherits:
GraphQL::Dataloader::Source
  • Object
show all
Defined in:
lib/carddb/rails/graphql/dataloader/publisher_source.rb

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ PublisherSource

Returns a new instance of PublisherSource.



8
9
10
11
# File 'lib/carddb/rails/graphql/dataloader/publisher_source.rb', line 8

def initialize(client: nil)
  super()
  @client = client
end

Instance Method Details

#fetch(slugs) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/carddb/rails/graphql/dataloader/publisher_source.rb', line 13

def fetch(slugs)
  client = @client || CardDB::Rails.client

  client.batch do |batch|
    slugs.each do |slug|
      batch.publishers.fetch(slug: slug)
    end
  end
end