Skip to content

Commit b162083

Browse files
committed
refactor(Execute) remove unused Lazy code; mark @api private
1 parent 4539714 commit b162083

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

lib/graphql/execution/directive_checks.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module GraphQL
33
module Execution
44
# Boolean checks for how an AST node's directives should
55
# influence its execution
6+
# @api private
67
module DirectiveChecks
78
SKIP = "skip"
89
INCLUDE = "include"

lib/graphql/execution/execute.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module GraphQL
33
module Execution
44
# A valid execution strategy
5+
# @api private
56
class Execute
67
PROPAGATE_NULL = :__graphql_propagate_null__
78

lib/graphql/execution/field_result.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module GraphQL
33
module Execution
44
# This is one key-value pair in a GraphQL response.
5+
# @api private
56
class FieldResult
67
# @return [Any, Lazy] the GraphQL-ready response value, or a {Lazy} instance
78
attr_reader :value

lib/graphql/execution/lazy.rb

+4-14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Execution
1010
# This is an itty-bitty promise-like object, with key differences:
1111
# - It has only two states, not-resolved and resolved
1212
# - It has no error-catching functionality
13+
# @api private
1314
class Lazy
1415
# Traverse `val`, lazily resolving any values along the way
1516
# @param val [Object] A data structure containing mixed plain values and `Lazy` instances
@@ -19,28 +20,17 @@ def self.resolve(val)
1920
end
2021

2122
# Create a {Lazy} which will get its inner value by calling the block
22-
# @param target [Object]
23-
# @param method_name [Symbol]
2423
# @param get_value_func [Proc] a block to get the inner value (later)
25-
def initialize(target = nil, method_name = nil, &get_value_func)
26-
if block_given?
27-
@get_value_func = get_value_func
28-
else
29-
@target = target
30-
@method_name = method_name
31-
end
24+
def initialize(&get_value_func)
25+
@get_value_func = get_value_func
3226
@resolved = false
3327
end
3428

3529
# @return [Object] The wrapped value, calling the lazy block if necessary
3630
def value
3731
if !@resolved
3832
@resolved = true
39-
if @get_value_func
40-
@value = @get_value_func.call
41-
else
42-
@value = @target.public_send(@method_name)
43-
end
33+
@value = @get_value_func.call
4434
end
4535
@value
4636
rescue GraphQL::ExecutionError => err

lib/graphql/execution/lazy/lazy_method_map.rb

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class Lazy
55
# {GraphQL::Schema} uses this to match returned values to lazy resolution methods.
66
# Methods may be registered for classes, they apply to its subclasses also.
77
# The result of this lookup is cached for future resolutions.
8+
# @api private
9+
# @see {Schema#lazy?} looks up values from this map
810
class LazyMethodMap
911
def initialize
1012
@storage = Hash.new do |h, value_class|

lib/graphql/execution/lazy/resolve.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module GraphQL
33
module Execution
44
class Lazy
55
# Helpers for dealing with data structures containing {Lazy} instances
6+
# @api private
67
module Resolve
78
# Mutate `value`, replacing {Lazy} instances in place with their resolved values
89
# @return [void]

lib/graphql/execution/selection_result.rb

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module GraphQL
33
module Execution
44
# A set of key-value pairs suitable for a GraphQL response.
5+
# @api private
56
class SelectionResult
67
def initialize
78
@storage = {}

lib/graphql/execution/typecast.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22
module GraphQL
33
module Execution
4+
# @api private
45
module Typecast
56
# @return [Boolean]
67
def self.subtype?(parent_type, child_type)

0 commit comments

Comments
 (0)