Skip to content

Commit d34ff72

Browse files
committed
Exec-next: some runtime fixes
1 parent 680b1d7 commit d34ff72

5 files changed

Lines changed: 16 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
- Runtime: add hooks for experimental custom runtimes #5425, #5429
101101
- Lazy handling and Dataloader have been merged under the hood #5422
102-
- Doc: merk `load_application_object_failed` as public #5426
102+
- Doc: mark `load_application_object_failed` as public #5426
103103

104104
# 2.5.11 (9 Jul 2025)
105105

guides/execution/migration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ Adopting a feature flag system (described below) can also make this easier.
4848

4949
When all tests pass on `.execute_next`, you're ready to try it out in production.
5050

51-
## COMING SOON: Migration and Clean-Up Script
51+
## Migration and Clean-Up Script
5252

53-
Migrating field implementations can be automated in many cases. A script to analyze and execute these cases is in the works: [Pull Request](https://github.com/rmosolgo/graphql-ruby/pull/5531). This script will also be able to clean up unused instance methods when the migration is complete.
53+
`graphql_migrate_execution` is a command-line development tool that can automate many common GraphQL-Ruby field resolver patterns. Check out its docs and try out: https://rmosolgo.github.io/graphql_migrate_execution/
5454

5555
## Production Considerations
5656

@@ -159,7 +159,7 @@ Previously, GraphQL-Ruby would check `type_object.respond_to?(:title)`, `object.
159159

160160
Now, GraphQL-Ruby simply calls `object.title` and allows the `NoMethodError` to bubble up if one is raised.
161161

162-
### Query Analyzers, including complexity 🌕
162+
### Query Analyzers, including complexity 🟡
163163

164164
Support is identical; this runs before execution using the exact same code.
165165

@@ -219,7 +219,7 @@ Not supported yet. This will need some new kind of integration.
219219

220220
These methods/procs are called.
221221

222-
### `validates:`
222+
### `validates:` 🟡
223223

224224
Built-in validators are supported. Custom validators will always receive `nil` as the `object`. (`object` is no longer available; this API will probably change before this is fully released.)
225225

lib/graphql/execution/next/field_resolve_step.rb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,27 @@ def append_selection(ast_node)
4949
end
5050

5151
def coerce_arguments(argument_owner, ast_arguments_or_hash)
52-
arg_defns = argument_owner.arguments(@selections_step.query.context)
52+
arg_defns = @selections_step.query.types.arguments(argument_owner)
5353
if arg_defns.empty?
5454
return EmptyObjects::EMPTY_HASH
5555
end
5656
args_hash = {}
5757
if ast_arguments_or_hash.is_a?(Hash)
5858
ast_arguments_or_hash.each do |key, value|
5959
key_s = nil
60-
arg_defn = arg_defns.each_value.find { |a|
60+
arg_defn = arg_defns.find { |a|
6161
a.keyword == key || a.graphql_name == (key_s ||= String(key))
6262
}
6363
coerce_argument_value(args_hash, arg_defn, value)
6464
end
6565
else
6666
ast_arguments_or_hash.each { |arg_node|
67-
arg_defn = arg_defns[arg_node.name]
67+
arg_defn = arg_defns.find { |ad| ad.graphql_name == arg_node.name }
6868
coerce_argument_value(args_hash, arg_defn, arg_node.value)
6969
}
7070
end
7171
# TODO refactor the loop above into this one
72-
arg_defns.each do |arg_graphql_name, arg_defn|
72+
arg_defns.each do |arg_defn|
7373
if arg_defn.default_value? && !args_hash.key?(arg_defn.keyword)
7474
coerce_argument_value(args_hash, arg_defn, arg_defn.default_value)
7575
end
@@ -252,14 +252,6 @@ def build_arguments
252252
query = @selections_step.query
253253
field_name = @ast_node.name
254254
@field_definition = query.get_field(@parent_type, field_name) || raise("Invariant: no field found for #{@parent_type.to_type_signature}.#{ast_node.name}")
255-
if field_name == "__typename"
256-
# TODO handle custom introspection
257-
@field_results = Array.new(@selections_step.objects.size, @parent_type.graphql_name)
258-
@object_is_authorized = AlwaysAuthorized
259-
build_results
260-
return
261-
end
262-
263255
arguments = coerce_arguments(@field_definition, @ast_node.arguments) # rubocop:disable Development/ContextIsPassedCop
264256
@arguments ||= arguments # may have already been set to an error
265257

@@ -689,6 +681,8 @@ def resolve_batch(objects, context, args_hash)
689681
else
690682
obj_inst.public_send(@field_definition.execution_next_mode_key, **args_hash)
691683
end
684+
rescue GraphQL::ExecutionError => exec_err
685+
exec_err
692686
end
693687
else
694688
raise "Batching execution for #{path} not implemented (execution_next_mode: #{@execution_next_mode.inspect}); provide `resolve_static:`, `resolve_batch:`, `hash_key:`, `method:`, or use a compatibility plug-in"

lib/graphql/execution/next/prepare_object_step.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def authorize
7272
begin
7373
query.current_trace.begin_authorized(@resolved_type, @object, query.context)
7474
@authorized_value = @resolved_type.authorized?(@object, query.context)
75-
query.current_trace.end_authorized(@resolve_type, @object, query.context, @authorized_value)
75+
query.current_trace.end_authorized(@resolved_type, @object, query.context, @authorized_value)
7676
rescue GraphQL::UnauthorizedError => auth_err
7777
@authorization_error = auth_err
7878
end

lib/graphql/execution/next/runner.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def initialize(multiplex, authorization:)
2323
end
2424

2525
def resolve_type(type, object, query)
26-
query.current_trace.begin_resolve_type(@static_type, object, query.context)
26+
query.current_trace.begin_resolve_type(type, object, query.context)
2727
resolved_type, _ignored_new_value = query.resolve_type(type, object)
28-
query.current_trace.end_resolve_type(@static_type, object, query.context, resolved_type)
28+
query.current_trace.end_resolve_type(type, object, query.context, resolved_type)
2929
resolved_type
3030
end
3131

@@ -184,7 +184,8 @@ def execute
184184
res_h
185185
end
186186

187-
GraphQL::Query::Result.new(query: query, values: fin_result)
187+
query.result_values = fin_result
188+
query.result
188189
end
189190
end
190191
ensure

0 commit comments

Comments
 (0)