Class: CardDB::Rails::GraphQL::Dataloader::DeckSource

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

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, read_state: 'DRAFT') ⇒ DeckSource

Returns a new instance of DeckSource.



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

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

Instance Method Details

#fetch(ids) ⇒ Object



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

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

  client.batch do |batch|
    ids.each do |id|
      batch.decks.get(id, read_state: @read_state)
    end
  end
end