-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix single non zeroth index resolving #5
base: main
Are you sure you want to change the base?
Fix single non zeroth index resolving #5
Conversation
@@ -460,7 +460,7 @@ def on_one_resolved(result): | |||
|
|||
# If there is only one index, avoid the overhead of parallelization. | |||
index = awaitable_indices[0] | |||
return completed_results[0].then(on_one_resolved) | |||
return completed_results[index].then(on_one_resolved) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fellowapp @sciyoshi This fixed an issue for me.
Traceback
╭────────────────────────── Traceback (most recent call last) ───────────────────────────╮ │
│ promise.py:213 in execute_field │
│ │
│ 210 │ │ │ │ │
│ 211 │ │ │ │ return await_result() │
│ 212 │ │ │ │
│ ❱ 213 │ │ │ completed = self.complete_value( │
│ 214 │ │ │ │ return_type, field_nodes, info, path, result │
│ 215 │ │ │ ) │
│ 216 │ │ │ if self.is_promise(completed): │
│ │
│ site-packages/graphql/execution/execute.py:612 in complete_value │
│ │
│ 609 │ │ # If field type is NonNull, complete for inner type, and throw field er │
│ 610 │ │ # result is null. │
│ 611 │ │ if is_non_null_type(return_type): │
│ ❱ 612 │ │ │ completed = self.complete_value( │
│ 613 │ │ │ │ cast(GraphQLNonNull, return_type).of_type, │
│ 614 │ │ │ │ field_nodes, │
│ 615 │ │ │ │ info, │
│ │
│ site-packages/graphql/execution/execute.py:632 in complete_value │
│ │
│ 629 │ │ │
│ 630 │ │ # If field type is List, complete each item in the list with inner type │
│ 631 │ │ if is_list_type(return_type): │
│ ❱ 632 │ │ │ return self.complete_list_value( │
│ 633 │ │ │ │ cast(GraphQLList, return_type), field_nodes, info, path, result │
│ 634 │ │ │ ) │
│ 635 │
│ │
│ promise.py:484 in complete_list_value │
│ │
│ 481 │ │ │ │ completed_results[index] for index in awaitable_indices │
│ 482 │ │ │ ]).then(on_all_resolve) │
│ 483 │ │ │
│ ❱ 484 │ │ res = get_completed_results() │
│ 485 │ │ return res │
│ 486 │
│ │
│ promise.py:473 in get_completed_results │
│ │
│ 470 │ │ │ │ │
│ 471 │ │ │ │ # If there is only one index, avoid the overhead of parallelizat │
│ 472 │ │ │ │ index = awaitable_indices[0] │
│ ❱ 473 │ │ │ │ return completed_results[0].then(on_one_resolved) │
│ 474 │ │ │ │
│ 475 │ │ │ def on_all_resolve(results): │
│ 476 │ │ │ │ for index, result in zip(awaitable_indices, results, strict=Fals │
╰────────────────────────────────────────────────────────────────────────────────────────╯
Unfortunately, due to the complexity of the schemas I am working with, I don't have an MVP for a test or recreation. If there's a critical need for it please ping me.
I'm having the same issue. |
Would be great to have this merged 🙏 |
There is a bug on this line. I believe it should be
return completed_results[index].then(on_one_resolved)
instead ofreturn completed_results[0].then(on_one_resolved)
It looks like that code is optimizing for when there is only a single Promise being returned and tries to execute the 0th index of "awaitable_promise"s. However it is possible the awaitable index may not be the 0ths index, it could be the 1st.
Here is some sample code that reproduces the issue.
Before:
After: