22
33from __future__ import annotations # Python < 3.10
44
5- import sys
65from enum import Enum
76from typing import (
87 TYPE_CHECKING ,
@@ -555,8 +554,10 @@ def to_kwargs(self) -> GraphQLFieldKwargs:
555554 def __copy__ (self ) -> GraphQLField : # pragma: no cover
556555 return self .__class__ (** self .to_kwargs ())
557556
558- if sys .version_info < (3 , 9 ) or sys .version_info >= (3 , 11 ):
559- TContext = TypeVar ("TContext" )
557+
558+ TContext = TypeVar ("TContext" )
559+
560+ try :
560561
561562 class GraphQLResolveInfo (NamedTuple , Generic [TContext ]):
562563 """Collection of information passed to the resolvers.
@@ -580,8 +581,11 @@ class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
580581 variable_values : Dict [str , Any ]
581582 context : TContext
582583 is_awaitable : Callable [[Any ], bool ]
583- else :
584- class GraphQLResolveInfo (NamedTuple ):
584+ except TypeError as error : # pragma: no cover
585+ if "Multiple inheritance with NamedTuple is not supported" not in str (error ):
586+ raise # only catch expected error for Python 3.9 and 3.10
587+
588+ class GraphQLResolveInfo (NamedTuple ): # type: ignore[no-redef]
585589 """Collection of information passed to the resolvers.
586590
587591 This is always passed as the first argument to the resolvers.
@@ -604,6 +608,7 @@ class GraphQLResolveInfo(NamedTuple):
604608 context : Any
605609 is_awaitable : Callable [[Any ], bool ]
606610
611+
607612# Note: Contrary to the Javascript implementation of GraphQLFieldResolver,
608613# the context is passed as part of the GraphQLResolveInfo and any arguments
609614# are passed individually as keyword arguments.
0 commit comments