26
26
OperationType ,
27
27
SelectionSetNode ,
28
28
)
29
- from ..pyutils import inspect , is_invalid , is_nullish , MaybeAwaitable
29
+ from ..pyutils import inspect , is_invalid , is_nullish , AwaitableOrValue
30
30
from ..utilities import get_operation_root_type , type_from_ast
31
31
from ..type import (
32
32
GraphQLAbstractType ,
@@ -116,7 +116,7 @@ def execute(
116
116
type_resolver : GraphQLTypeResolver = None ,
117
117
middleware : Middleware = None ,
118
118
execution_context_class : Type ["ExecutionContext" ] = None ,
119
- ) -> MaybeAwaitable [ExecutionResult ]:
119
+ ) -> AwaitableOrValue [ExecutionResult ]:
120
120
"""Execute a GraphQL operation.
121
121
122
122
Implements the "Evaluating requests" section of the GraphQL specification.
@@ -304,8 +304,8 @@ def build(
304
304
)
305
305
306
306
def build_response (
307
- self , data : MaybeAwaitable [Optional [Dict [str , Any ]]]
308
- ) -> MaybeAwaitable [ExecutionResult ]:
307
+ self , data : AwaitableOrValue [Optional [Dict [str , Any ]]]
308
+ ) -> AwaitableOrValue [ExecutionResult ]:
309
309
"""Build response.
310
310
311
311
Given a completed execution context and data, build the (data, errors) response
@@ -328,7 +328,7 @@ async def build_response_async():
328
328
329
329
def execute_operation (
330
330
self , operation : OperationDefinitionNode , root_value : Any
331
- ) -> Optional [MaybeAwaitable [Any ]]:
331
+ ) -> Optional [AwaitableOrValue [Any ]]:
332
332
"""Execute an operation.
333
333
334
334
Implements the "Evaluating operations" section of the spec.
@@ -377,7 +377,7 @@ def execute_fields_serially(
377
377
source_value : Any ,
378
378
path : Optional [ResponsePath ],
379
379
fields : Dict [str , List [FieldNode ]],
380
- ) -> MaybeAwaitable [Dict [str , Any ]]:
380
+ ) -> AwaitableOrValue [Dict [str , Any ]]:
381
381
"""Execute the given fields serially.
382
382
383
383
Implements the "Evaluating selection sets" section of the spec for "write" mode.
@@ -427,7 +427,7 @@ def execute_fields(
427
427
source_value : Any ,
428
428
path : Optional [ResponsePath ],
429
429
fields : Dict [str , List [FieldNode ]],
430
- ) -> MaybeAwaitable [Dict [str , Any ]]:
430
+ ) -> AwaitableOrValue [Dict [str , Any ]]:
431
431
"""Execute the given fields concurrently.
432
432
433
433
Implements the "Evaluating selection sets" section of the spec for "read" mode.
@@ -581,7 +581,7 @@ def resolve_field(
581
581
source : Any ,
582
582
field_nodes : List [FieldNode ],
583
583
path : ResponsePath ,
584
- ) -> MaybeAwaitable [Any ]:
584
+ ) -> AwaitableOrValue [Any ]:
585
585
"""Resolve the field on the given source object.
586
586
587
587
In particular, this figures out the value that the field returns by calling its
@@ -652,7 +652,7 @@ def complete_value_catching_error(
652
652
info : GraphQLResolveInfo ,
653
653
path : ResponsePath ,
654
654
result : Any ,
655
- ) -> MaybeAwaitable [Any ]:
655
+ ) -> AwaitableOrValue [Any ]:
656
656
"""Complete a value while catching an error.
657
657
658
658
This is a small wrapper around completeValue which detects and logs errors in
@@ -713,7 +713,7 @@ def complete_value(
713
713
info : GraphQLResolveInfo ,
714
714
path : ResponsePath ,
715
715
result : Any ,
716
- ) -> MaybeAwaitable [Any ]:
716
+ ) -> AwaitableOrValue [Any ]:
717
717
"""Complete a value.
718
718
719
719
Implements the instructions for completeValue as defined in the "Field entries"
@@ -797,7 +797,7 @@ def complete_list_value(
797
797
info : GraphQLResolveInfo ,
798
798
path : ResponsePath ,
799
799
result : Iterable [Any ],
800
- ) -> MaybeAwaitable [Any ]:
800
+ ) -> AwaitableOrValue [Any ]:
801
801
"""Complete a list value.
802
802
803
803
Complete a list value by completing each item in the list with the inner type.
@@ -866,7 +866,7 @@ def complete_abstract_value(
866
866
info : GraphQLResolveInfo ,
867
867
path : ResponsePath ,
868
868
result : Any ,
869
- ) -> MaybeAwaitable [Any ]:
869
+ ) -> AwaitableOrValue [Any ]:
870
870
"""Complete an abstract value.
871
871
872
872
Complete a value of an abstract type by determining the runtime object type of
@@ -947,7 +947,7 @@ def complete_object_value(
947
947
info : GraphQLResolveInfo ,
948
948
path : ResponsePath ,
949
949
result : Any ,
950
- ) -> MaybeAwaitable [Dict [str , Any ]]:
950
+ ) -> AwaitableOrValue [Dict [str , Any ]]:
951
951
"""Complete an Object value by executing all sub-selections."""
952
952
# If there is an `is_type_of()` predicate function, call it with the current
953
953
# result. If `is_type_of()` returns False, then raise an error rather than
@@ -981,7 +981,7 @@ def collect_and_execute_subfields(
981
981
field_nodes : List [FieldNode ],
982
982
path : ResponsePath ,
983
983
result : Any ,
984
- ) -> MaybeAwaitable [Dict [str , Any ]]:
984
+ ) -> AwaitableOrValue [Dict [str , Any ]]:
985
985
"""Collect sub-fields to execute to complete this value."""
986
986
sub_field_nodes = self .collect_subfields (return_type , field_nodes )
987
987
return self .execute_fields (return_type , result , path , sub_field_nodes )
@@ -1100,7 +1100,7 @@ def invalid_return_type_error(
1100
1100
1101
1101
def default_type_resolver (
1102
1102
value : Any , info : GraphQLResolveInfo , abstract_type : GraphQLAbstractType
1103
- ) -> MaybeAwaitable [Optional [Union [GraphQLObjectType , str ]]]:
1103
+ ) -> AwaitableOrValue [Optional [Union [GraphQLObjectType , str ]]]:
1104
1104
"""Default type resolver function.
1105
1105
1106
1106
If a resolve_type function is not given, then a default resolve behavior is used
0 commit comments