Class: GraphQL::Dataloader::NullDataloader

Inherits:
GraphQL::Dataloader show all
Defined in:
lib/graphql/dataloader/null_dataloader.rb

Overview

The default implementation of dataloading – all no-ops.

The Dataloader interface isn’t public, but it enables simple internal code while adding the option to add Dataloader.

Instance Attribute Summary

Attributes inherited from GraphQL::Dataloader

#fiber_limit

Instance Method Summary collapse

Methods inherited from GraphQL::Dataloader

#cleanup_fiber, #get_fiber_variables, #merge_records, #nonblocking?, #run_fiber, #set_fiber_variables, #spawn_fiber, use, with_dataloading

Constructor Details

#initializeNullDataloader

These are all no-ops because code was executed synchronously.



13
# File 'lib/graphql/dataloader/null_dataloader.rb', line 13

def initialize(*); end

Instance Method Details

#append_jobObject



21
22
23
24
# File 'lib/graphql/dataloader/null_dataloader.rb', line 21

def append_job
  yield
  nil
end

#clear_cacheObject



16
# File 'lib/graphql/dataloader/null_dataloader.rb', line 16

def clear_cache; end

#runObject



14
# File 'lib/graphql/dataloader/null_dataloader.rb', line 14

def run; end

#run_isolatedObject



15
# File 'lib/graphql/dataloader/null_dataloader.rb', line 15

def run_isolated; yield; end

#withObject

Raises:



26
27
28
# File 'lib/graphql/dataloader/null_dataloader.rb', line 26

def with(*)
  raise GraphQL::Error, "GraphQL::Dataloader is not running -- add `use GraphQL::Dataloader` to your schema to use Dataloader sources."
end

#yield(_source) ⇒ Object

Raises:



17
18
19
# File 'lib/graphql/dataloader/null_dataloader.rb', line 17

def yield(_source)
  raise GraphQL::Error, "GraphQL::Dataloader is not running -- add `use GraphQL::Dataloader` to your schema to use Dataloader sources."
end