Module: GraphQL::Schema::Member::HasDataloader Private
- Included in:
- Interface::DefinitionMethods, Object, Resolver
- Defined in:
- lib/graphql/schema/member/has_dataloader.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#dataload(source_class, *source_args, load_key) ⇒ Object
private
A shortcut method for loading a key from a source.
-
#dataload_association(record = object, association_name, scope: nil) ⇒ ActiveRecord::Base?
private
Look up an associated record using a Rails association.
-
#dataload_record(model, find_by_value, find_by: nil) ⇒ ActiveRecord::Base?
private
Find an object with ActiveRecord via Dataloader::ActiveRecordSource.
-
#dataloader ⇒ GraphQL::Dataloader
private
The dataloader for the currently-running query.
Instance Method Details
#dataload(source_class, *source_args, load_key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A shortcut method for loading a key from a source.
Identical to dataloader.with(source_class, *source_args).load(load_key)
17 18 19 |
# File 'lib/graphql/schema/member/has_dataloader.rb', line 17 def dataload(source_class, *source_args, load_key) dataloader.with(source_class, *source_args).load(load_key) end |
#dataload_association(record = object, association_name, scope: nil) ⇒ ActiveRecord::Base?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Look up an associated record using a Rails association.
45 46 47 48 49 50 51 52 |
# File 'lib/graphql/schema/member/has_dataloader.rb', line 45 def dataload_association(record = object, association_name, scope: nil) source = if scope dataloader.with(Dataloader::ActiveRecordAssociationSource, association_name, scope) else dataloader.with(Dataloader::ActiveRecordAssociationSource, association_name) end source.load(record) end |
#dataload_record(model, find_by_value, find_by: nil) ⇒ ActiveRecord::Base?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find an object with ActiveRecord via Dataloader::ActiveRecordSource.
26 27 28 29 30 31 32 33 34 |
# File 'lib/graphql/schema/member/has_dataloader.rb', line 26 def dataload_record(model, find_by_value, find_by: nil) source = if find_by dataloader.with(Dataloader::ActiveRecordSource, model, find_by: find_by) else dataloader.with(Dataloader::ActiveRecordSource, model) end source.load(find_by_value) end |
#dataloader ⇒ GraphQL::Dataloader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The dataloader for the currently-running query.
8 9 10 |
# File 'lib/graphql/schema/member/has_dataloader.rb', line 8 def dataloader context.dataloader end |