Class: CardDB::Rails::GraphQL::Dataloader::DeckByExternalRefSource

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

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ DeckByExternalRefSource

Returns a new instance of DeckByExternalRefSource.



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

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

Instance Method Details

#fetch(external_refs) ⇒ Object



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

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

  client.batch do |batch|
    external_refs.each do |external_ref|
      batch.decks.get(external_ref: external_ref)
    end
  end
end