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, read_state: 'DRAFT') ⇒ DeckByExternalRefSource

Returns a new instance of DeckByExternalRefSource.



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

def initialize(client: nil, read_state: 'DRAFT')
  super()
  @client = client
  @read_state = read_state
end

Instance Method Details

#fetch(external_refs) ⇒ Object



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

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

  client.batch do |batch|
    external_refs.each do |external_ref|
      batch.decks.get_by_external_ref(external_ref: external_ref, read_state: @read_state)
    end
  end
end