|
2 | 2 |
|
3 | 3 | from __future__ import annotations # Python < 3.10
|
4 | 4 |
|
| 5 | +import sys |
5 | 6 | from enum import Enum
|
6 | 7 | from typing import (
|
7 | 8 | TYPE_CHECKING,
|
@@ -554,30 +555,54 @@ def to_kwargs(self) -> GraphQLFieldKwargs:
|
554 | 555 | def __copy__(self) -> GraphQLField: # pragma: no cover
|
555 | 556 | return self.__class__(**self.to_kwargs())
|
556 | 557 |
|
| 558 | +if sys.version_info < (3, 9) or sys.version_info >= (3, 11): |
| 559 | + TContext = TypeVar("TContext") |
557 | 560 |
|
558 |
| -class GraphQLResolveInfo(NamedTuple): |
559 |
| - """Collection of information passed to the resolvers. |
| 561 | + class GraphQLResolveInfo(NamedTuple, Generic[TContext]): |
| 562 | + """Collection of information passed to the resolvers. |
560 | 563 |
|
561 |
| - This is always passed as the first argument to the resolvers. |
| 564 | + This is always passed as the first argument to the resolvers. |
562 | 565 |
|
563 |
| - Note that contrary to the JavaScript implementation, the context (commonly used to |
564 |
| - represent an authenticated user, or request-specific caches) is included here and |
565 |
| - not passed as an additional argument. |
566 |
| - """ |
| 566 | + Note that contrary to the JavaScript implementation, the context (commonly used |
| 567 | + to represent an authenticated user, or request-specific caches) is included here |
| 568 | + and not passed as an additional argument. |
| 569 | + """ |
567 | 570 |
|
568 |
| - field_name: str |
569 |
| - field_nodes: List[FieldNode] |
570 |
| - return_type: GraphQLOutputType |
571 |
| - parent_type: GraphQLObjectType |
572 |
| - path: Path |
573 |
| - schema: GraphQLSchema |
574 |
| - fragments: Dict[str, FragmentDefinitionNode] |
575 |
| - root_value: Any |
576 |
| - operation: OperationDefinitionNode |
577 |
| - variable_values: Dict[str, Any] |
578 |
| - context: Any |
579 |
| - is_awaitable: Callable[[Any], bool] |
| 571 | + field_name: str |
| 572 | + field_nodes: List[FieldNode] |
| 573 | + return_type: GraphQLOutputType |
| 574 | + parent_type: GraphQLObjectType |
| 575 | + path: Path |
| 576 | + schema: GraphQLSchema |
| 577 | + fragments: Dict[str, FragmentDefinitionNode] |
| 578 | + root_value: Any |
| 579 | + operation: OperationDefinitionNode |
| 580 | + variable_values: Dict[str, Any] |
| 581 | + context: TContext |
| 582 | + is_awaitable: Callable[[Any], bool] |
| 583 | +else: |
| 584 | + class GraphQLResolveInfo(NamedTuple): |
| 585 | + """Collection of information passed to the resolvers. |
| 586 | +
|
| 587 | + This is always passed as the first argument to the resolvers. |
| 588 | +
|
| 589 | + Note that contrary to the JavaScript implementation, the context (commonly used |
| 590 | + to represent an authenticated user, or request-specific caches) is included here |
| 591 | + and not passed as an additional argument. |
| 592 | + """ |
580 | 593 |
|
| 594 | + field_name: str |
| 595 | + field_nodes: List[FieldNode] |
| 596 | + return_type: GraphQLOutputType |
| 597 | + parent_type: GraphQLObjectType |
| 598 | + path: Path |
| 599 | + schema: GraphQLSchema |
| 600 | + fragments: Dict[str, FragmentDefinitionNode] |
| 601 | + root_value: Any |
| 602 | + operation: OperationDefinitionNode |
| 603 | + variable_values: Dict[str, Any] |
| 604 | + context: Any |
| 605 | + is_awaitable: Callable[[Any], bool] |
581 | 606 |
|
582 | 607 | # Note: Contrary to the Javascript implementation of GraphQLFieldResolver,
|
583 | 608 | # the context is passed as part of the GraphQLResolveInfo and any arguments
|
|
0 commit comments