Class: CardDB::Rails::GraphQL::Dataloader::DatasetSource
- Inherits:
-
GraphQL::Dataloader::Source
- Object
- GraphQL::Dataloader::Source
- CardDB::Rails::GraphQL::Dataloader::DatasetSource
- Defined in:
- lib/carddb/rails/graphql/dataloader/dataset_source.rb
Instance Method Summary collapse
- #fetch(dataset_keys) ⇒ Object
-
#initialize(publisher_slug: nil, game_key: nil, client: nil) ⇒ DatasetSource
constructor
A new instance of DatasetSource.
Constructor Details
#initialize(publisher_slug: nil, game_key: nil, client: nil) ⇒ DatasetSource
Returns a new instance of DatasetSource.
8 9 10 11 12 13 |
# File 'lib/carddb/rails/graphql/dataloader/dataset_source.rb', line 8 def initialize(publisher_slug: nil, game_key: nil, client: nil) super() @publisher_slug = publisher_slug @game_key = game_key @client = client end |
Instance Method Details
#fetch(dataset_keys) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/carddb/rails/graphql/dataloader/dataset_source.rb', line 15 def fetch(dataset_keys) client = @client || CardDB::Rails.client publisher_slug = client.config.resolve_publisher(@publisher_slug) game_key = client.config.resolve_game(@game_key) raise ArgumentError, 'publisher_slug is required (no default configured)' if publisher_slug.nil? || publisher_slug.empty? raise ArgumentError, 'game_key is required (no default configured)' if game_key.nil? || game_key.empty? client.batch do |batch| dataset_keys.each do |dataset_key| batch.datasets.get( publisher_slug: publisher_slug, game_key: game_key, dataset_key: dataset_key ) end end end |