2020"""
2121
2222from functools import partial
23+ from inspect import isclass , iscoroutinefunction
2324import logging
2425from typing import TYPE_CHECKING , Any , Tuple , Union
2526
26- from inspect import isclass , iscoroutinefunction
27-
2827from graphene .utils .str_converters import to_snake_case
2928from graphql .execution .utils import (
3029 get_operation_root_type , get_field_def
3534from graphql .backend .base import GraphQLBackend , GraphQLDocument
3635from graphql .backend .core import execute_and_validate
3736from graphql .utils .base import type_from_ast
38- from graphql .type import get_named_type
37+ from graphql .type . definition import get_named_type
3938from promise import Promise
4039from rx import Observable
4140
42- from cylc .flow .network .schema import NODE_MAP , get_type_str
41+ from cylc .flow .network .schema import NODE_MAP
4342
4443if TYPE_CHECKING :
4544 from graphql .execution import ExecutionResult
4645 from graphql .language .ast import Document
47- from graphql .type import GraphQLSchema
46+ from graphql .type . schema import GraphQLSchema
4847
4948
5049logger = logging .getLogger (__name__ )
@@ -376,18 +375,18 @@ def resolve(self, next_, root, info, **args):
376375
377376 # Avoid using the protobuf default if field isn't set.
378377 if (
379- hasattr (root , 'ListFields' )
380- and hasattr (root , field_name )
381- and get_type_str (info .return_type ) not in NODE_MAP
378+ hasattr (root , 'ListFields' )
379+ and hasattr (root , field_name )
380+ and get_named_type (info .return_type ). name not in NODE_MAP
382381 ):
383382
384383 # Gather fields set in root
385384 parent_path_string = f'{ info .path [:- 1 :]} '
386385 stamp = getattr (root , 'stamp' , '' )
387386 if (
388- parent_path_string not in self .field_sets
389- or self .field_sets [
390- parent_path_string ]['stamp' ] != stamp
387+ parent_path_string not in self .field_sets
388+ or self .field_sets [
389+ parent_path_string ]['stamp' ] != stamp
391390 ):
392391 self .field_sets [parent_path_string ] = {
393392 'stamp' : stamp ,
@@ -398,36 +397,33 @@ def resolve(self, next_, root, info, **args):
398397 }
399398
400399 if (
401- parent_path_string in self .field_sets
402- and field_name not in self .field_sets [
403- parent_path_string ]['fields' ]
400+ parent_path_string in self .field_sets
401+ and field_name not in self .field_sets [
402+ parent_path_string ]['fields' ]
404403 ):
405404 return None
406405 # Do not resolve subfields of an empty type
407406 # by setting as null in parent/root.
408- elif (
409- isinstance (root , dict )
410- and field_name in root
411- ):
407+ elif isinstance (root , dict ) and field_name in root :
412408 field_value = root [field_name ]
413409 if (
414- field_value in EMPTY_VALUES
415- or (
416- hasattr (field_value , 'ListFields' )
417- and not field_value .ListFields ()
418- )
410+ field_value in EMPTY_VALUES
411+ or (
412+ hasattr (field_value , 'ListFields' )
413+ and not field_value .ListFields ()
414+ )
419415 ):
420416 return None
421417 if (
422- info .operation .operation in self .ASYNC_OPS
423- or iscoroutinefunction (next_ )
418+ info .operation .operation in self .ASYNC_OPS
419+ or iscoroutinefunction (next_ )
424420 ):
425421 return self .async_null_setter (next_ , root , info , ** args )
426422 return null_setter (next_ (root , info , ** args ))
427423
428424 if (
429- info .operation .operation in self .ASYNC_OPS
430- or iscoroutinefunction (next_ )
425+ info .operation .operation in self .ASYNC_OPS
426+ or iscoroutinefunction (next_ )
431427 ):
432428 return self .async_resolve (next_ , root , info , ** args )
433429 return next_ (root , info , ** args )
0 commit comments