Skip to content

Commit 395075e

Browse files
dexhunterCito
authored andcommitted
perf: reduce field overhead in execution (#299)
1 parent 9e5cfb6 commit 395075e

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

‎src/graphql/execution/executor.py‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -956,12 +956,16 @@ def execute_field(
956956
try:
957957
# Build a dictionary of arguments from the field.arguments AST, using the
958958
# variables scope to fulfill any variable references.
959-
args = get_argument_values(
960-
field_def,
961-
first_field_node,
962-
self.variable_values,
963-
first_field_details.fragment_variable_values,
964-
self.hide_suggestions,
959+
args = (
960+
get_argument_values(
961+
field_def,
962+
first_field_node,
963+
self.variable_values,
964+
first_field_details.fragment_variable_values,
965+
self.hide_suggestions,
966+
)
967+
if field_def.args or first_field_node.arguments
968+
else {}
965969
)
966970

967971
# Note that contrary to the JavaScript implementation, we pass the context
@@ -988,19 +992,27 @@ def execute_field(
988992
)
989993
if self.is_awaitable(completed):
990994

991-
async def await_completed() -> Any:
995+
async def await_completed(
996+
executor: Executor,
997+
completed: Awaitable[Any],
998+
return_type: GraphQLOutputType,
999+
field_details_list: FieldDetailsList,
1000+
path: Path,
1001+
) -> Any:
9921002
try:
9931003
return await completed
9941004
except Exception as raw_error:
995-
self.handle_field_error(
1005+
executor.handle_field_error(
9961006
raw_error,
9971007
return_type,
9981008
field_details_list,
9991009
path,
10001010
)
10011011
return None
10021012

1003-
return await_completed()
1013+
return await_completed(
1014+
self, completed, return_type, field_details_list, path
1015+
)
10041016

10051017
except Exception as raw_error:
10061018
self.handle_field_error(

0 commit comments

Comments
 (0)