@@ -123,63 +123,33 @@ def after_define_apply
123123 #
124124 # Whatever this method returns will be used for execution.
125125 #
126- # @param object [Object] The object the field is being resolved on
126+ # @param object [Object] The object the field is being resolved on (not passed by new execution)
127+ # @param objects [Array<Object>] The objects the field is being resolved on (passed by new execution)
127128 # @param arguments [Hash] Ruby keyword arguments for resolving this field
128129 # @param context [Query::Context] the context for this query
129- # @yieldparam object [Object] The object to continue resolving the field on
130+ # @yieldparam object_or_objects [Object, Array<Object> ] The object or objects (new execution) to continue resolving the field on
130131 # @yieldparam arguments [Hash] The keyword arguments to continue resolving with
131132 # @yieldparam memo [Object] Any extension-specific value which will be passed to {#after_resolve} later
132133 # @return [Object] The return value for this field.
133- def resolve ( object :, arguments :, context :)
134- yield ( object , arguments , nil )
135- end
136-
137- # Called before batch-resolving {#field}. It should either:
138- #
139- # - `yield` values to continue execution; OR
140- # - return something else to shortcut field execution.
141- #
142- # Whatever this method returns will be used for execution.
143- #
144- # @param objects [Array<Object>] The objects the field is being resolved on
145- # @param arguments [Hash] Ruby keyword arguments for resolving this field
146- # @param context [Query::Context] the context for this query
147- # @yieldparam objects [Array<Object>] The objects to continue resolving the field on. Length must be the same as passed-in `objects:`
148- # @yieldparam arguments [Hash] The keyword arguments to continue resolving with
149- # @yieldparam memo [Object] Any extension-specific value which will be passed to {#after_resolve} later
150- # @return [Array<Object>] The return value for this field, length matching passed-in `objects:`.
151- def resolve_next ( objects :, arguments :, context :)
152- yield ( objects , arguments , nil )
134+ def resolve ( object : nil , objects : nil , arguments :, context :)
135+ yield ( object || objects , arguments , nil )
153136 end
154137
155138 # Called after {#field} was resolved, and after any lazy values (like `Promise`s) were synced,
156139 # but before the value was added to the GraphQL response.
157140 #
158141 # Whatever this hook returns will be used as the return value.
159142 #
160- # @param object [Object] The object the field is being resolved on
143+ # @param object [Object] The object the field is being resolved on (not passed by new execution)
144+ # @param objects [Array<Object>] The object the field is being resolved on (passed by new execution)
161145 # @param arguments [Hash] Ruby keyword arguments for resolving this field
162146 # @param context [Query::Context] the context for this query
163- # @param value [Object] Whatever the field previously returned
147+ # @param value [Object] Whatever the field previously returned (not passed by new execution)
148+ # @param values [Array<Object>] Whatever the field previously returned (passed by new execution)
164149 # @param memo [Object] The third value yielded by {#resolve}, or `nil` if there wasn't one
165150 # @return [Object] The return value for this field.
166- def after_resolve ( object :, arguments :, context :, value :, memo :)
167- value
168- end
169-
170- # Called after {#field} was batch-resolved, and after any lazy values (like `Promise`s) were synced,
171- # but before the value was added to the GraphQL response.
172- #
173- # Whatever this hook returns will be used as the return value.
174- #
175- # @param objects [Array<Object>] The objects the field is being resolved on
176- # @param arguments [Hash] Ruby keyword arguments for resolving this field
177- # @param context [Query::Context] the context for this query
178- # @param values [Array<Object>] Whatever the field returned, one for each of `objects`
179- # @param memo [Object] The third value yielded by {#resolve}, or `nil` if there wasn't one
180- # @return [Array<Object>] The return values for this field, length matching `objects:`.
181- def after_resolve_next ( objects :, arguments :, context :, values :, memo :)
182- values
151+ def after_resolve ( object : nil , objects : nil , arguments :, context :, values : nil , value : nil , memo :)
152+ value || values
183153 end
184154 end
185155 end
0 commit comments