@@ -22,43 +22,49 @@ def resolve(object:, arguments:, context:)
22
22
end
23
23
24
24
def after_resolve ( value :, object :, arguments :, context :, memo :)
25
- if value . is_a? GraphQL ::ExecutionError
26
- # This isn't even going to work because context doesn't have ast_node anymore
27
- context . add_error ( value )
28
- nil
29
- elsif value . nil?
30
- nil
31
- elsif value . is_a? ( GraphQL ::Pagination ::Connection )
32
- # update the connection with some things that may not have been provided
33
- value . context ||= context
34
- value . parent ||= object . object
35
- value . first_value ||= arguments [ :first ]
36
- value . after_value ||= arguments [ :after ]
37
- value . last_value ||= arguments [ :last ]
38
- value . before_value ||= arguments [ :before ]
39
- if field . has_max_page_size? && !value . has_max_page_size_override?
40
- value . max_page_size = field . max_page_size
25
+ # rename some inputs to avoid conflicts inside the block
26
+ maybe_lazy = value
27
+ value = nil
28
+ context . schema . after_lazy ( maybe_lazy ) do |resolved_value |
29
+ value = resolved_value
30
+ if value . is_a? GraphQL ::ExecutionError
31
+ # This isn't even going to work because context doesn't have ast_node anymore
32
+ context . add_error ( value )
33
+ nil
34
+ elsif value . nil?
35
+ nil
36
+ elsif value . is_a? ( GraphQL ::Pagination ::Connection )
37
+ # update the connection with some things that may not have been provided
38
+ value . context ||= context
39
+ value . parent ||= object . object
40
+ value . first_value ||= arguments [ :first ]
41
+ value . after_value ||= arguments [ :after ]
42
+ value . last_value ||= arguments [ :last ]
43
+ value . before_value ||= arguments [ :before ]
44
+ if field . has_max_page_size? && !value . has_max_page_size_override?
45
+ value . max_page_size = field . max_page_size
46
+ end
47
+ if ( custom_t = context . schema . connections . edge_class_for_field ( @field ) )
48
+ value . edge_class = custom_t
49
+ end
50
+ value
51
+ elsif context . schema . new_connections?
52
+ wrappers = context . namespace ( :connections ) [ :all_wrappers ] ||= context . schema . connections . all_wrappers
53
+ context . schema . connections . wrap ( field , object . object , value , arguments , context , wrappers : wrappers )
54
+ else
55
+ if object . is_a? ( GraphQL ::Schema ::Object )
56
+ object = object . object
57
+ end
58
+ connection_class = GraphQL ::Relay ::BaseConnection . connection_for_nodes ( value )
59
+ connection_class . new (
60
+ value ,
61
+ arguments ,
62
+ field : field ,
63
+ max_page_size : field . max_page_size ,
64
+ parent : object ,
65
+ context : context ,
66
+ )
41
67
end
42
- if ( custom_t = context . schema . connections . edge_class_for_field ( @field ) )
43
- value . edge_class = custom_t
44
- end
45
- value
46
- elsif context . schema . new_connections?
47
- wrappers = context . namespace ( :connections ) [ :all_wrappers ] ||= context . schema . connections . all_wrappers
48
- context . schema . connections . wrap ( field , object . object , value , arguments , context , wrappers : wrappers )
49
- else
50
- if object . is_a? ( GraphQL ::Schema ::Object )
51
- object = object . object
52
- end
53
- connection_class = GraphQL ::Relay ::BaseConnection . connection_for_nodes ( value )
54
- connection_class . new (
55
- value ,
56
- arguments ,
57
- field : field ,
58
- max_page_size : field . max_page_size ,
59
- parent : object ,
60
- context : context ,
61
- )
62
68
end
63
69
end
64
70
end
0 commit comments