Class: GraphQL::Execution::Interpreter::ArgumentsCache
- Inherits:
-
Object
- Object
- GraphQL::Execution::Interpreter::ArgumentsCache
- Defined in:
- lib/graphql/execution/interpreter/arguments_cache.rb
Instance Method Summary collapse
-
#fetch(ast_node, argument_owner, parent_object) ⇒ Object
-
#initialize(query) ⇒ ArgumentsCache
constructor
A new instance of ArgumentsCache.
Constructor Details
#initialize(query) ⇒ ArgumentsCache
Returns a new instance of ArgumentsCache.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/graphql/execution/interpreter/arguments_cache.rb', line 7 def initialize(query) @query = query @storage = Hash.new do |h, ast_node| h[ast_node] = Hash.new do |h2, arg_owner| h2[arg_owner] = Hash.new do |h3, parent_object| # First, normalize all AST or Ruby values to a plain Ruby hash args_hash = prepare_args_hash(ast_node) # Then call into the schema to coerce those incoming values args = arg_owner.coerce_arguments(parent_object, args_hash, query.context) h3[parent_object] = @query.schema.after_lazy(args) do |resolved_args| # when this promise is resolved, update the cache with the resolved value h3[parent_object] = resolved_args end end end end end |
Instance Method Details
#fetch(ast_node, argument_owner, parent_object) ⇒ Object
26 27 28 |
# File 'lib/graphql/execution/interpreter/arguments_cache.rb', line 26 def fetch(ast_node, argument_owner, parent_object) @storage[ast_node][argument_owner][parent_object] end |