Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphql_core_promise/execute/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

@tony tony Aug 4, 2024

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.


def on_all_resolve(results):
for index, result in zip(awaitable_indices, results, strict=False):
Expand Down