From d708a3b06a5f838ea659ad67c8cb7323895d8bbb Mon Sep 17 00:00:00 2001 From: Esteban Echeverry Date: Mon, 25 Nov 2019 12:31:51 -0500 Subject: [PATCH 1/3] Fix TypeError while sorting errors in build_response As GraphQLError objects might have 'None' as value for their 'locations' and 'path' attributes, a check must be placed in order to avoid raising a TypeError inside the errors list's 'sort' method. This commit changes None by an empty list to enable proper pairwise comparisons. --- src/graphql/execution/execute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphql/execution/execute.py b/src/graphql/execution/execute.py index 4ddff2ad..99361b28 100644 --- a/src/graphql/execution/execute.py +++ b/src/graphql/execution/execute.py @@ -315,7 +315,7 @@ async def build_response_async(): return ExecutionResult(data, None) # Sort the error list in order to make it deterministic, since we might have # been using parallel execution. - errors.sort(key=lambda error: (error.locations, error.path, error.message)) + errors.sort(key=lambda error: (error.locations or [], error.path or [], error.message)) return ExecutionResult(data, errors) def execute_operation( From 2a2cb52c6fdf1c7b32e73ed69a3417a37cfd14ff Mon Sep 17 00:00:00 2001 From: Esteban Echeverry Date: Mon, 25 Nov 2019 14:16:56 -0500 Subject: [PATCH 2/3] Meet 88 columns max limit formatting rule. --- src/graphql/execution/execute.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graphql/execution/execute.py b/src/graphql/execution/execute.py index 99361b28..8d119ede 100644 --- a/src/graphql/execution/execute.py +++ b/src/graphql/execution/execute.py @@ -315,7 +315,8 @@ async def build_response_async(): return ExecutionResult(data, None) # Sort the error list in order to make it deterministic, since we might have # been using parallel execution. - errors.sort(key=lambda error: (error.locations or [], error.path or [], error.message)) + errors.sort(key=lambda error: ( + error.locations or [], error.path or [], error.message)) return ExecutionResult(data, errors) def execute_operation( From e442f5704d616c43eaf5dd3cb60ec2ddffd4686c Mon Sep 17 00:00:00 2001 From: Esteban Echeverry Date: Mon, 25 Nov 2019 14:28:35 -0500 Subject: [PATCH 3/3] Reformat execute.py file with black. --- src/graphql/execution/execute.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/graphql/execution/execute.py b/src/graphql/execution/execute.py index 8d119ede..d6e7fea2 100644 --- a/src/graphql/execution/execute.py +++ b/src/graphql/execution/execute.py @@ -315,8 +315,9 @@ async def build_response_async(): return ExecutionResult(data, None) # Sort the error list in order to make it deterministic, since we might have # been using parallel execution. - errors.sort(key=lambda error: ( - error.locations or [], error.path or [], error.message)) + errors.sort( + key=lambda error: (error.locations or [], error.path or [], error.message) + ) return ExecutionResult(data, errors) def execute_operation(