Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03a44cb

Browse filesBrowse files
committed
Remove deprecated get_field_def_fn argument of TypeInfo
Replicates graphql/graphql-js@75eb3eb
1 parent 2d90cc1 commit 03a44cb
Copy full SHA for 03a44cb

File tree

1 file changed

+8
-17
lines changed
Filter options

1 file changed

+8
-17
lines changed

‎src/graphql/utilities/type_info.py

Copy file name to clipboardExpand all lines: src/graphql/utilities/type_info.py
+8-17Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations # Python < 3.10
22

3-
from typing import Any, Callable, List, Optional, Union, cast
3+
from typing import Any, List, Optional, Union, cast
44

55
from ..language import (
66
ArgumentNode,
@@ -52,11 +52,6 @@
5252
__all__ = ["TypeInfo", "TypeInfoVisitor"]
5353

5454

55-
GetFieldDefFn = Callable[
56-
[GraphQLSchema, GraphQLType, FieldNode], Optional[GraphQLField]
57-
]
58-
59-
6055
class TypeInfo:
6156
"""Utility class for keeping track of type definitions.
6257
@@ -70,14 +65,11 @@ def __init__(
7065
self,
7166
schema: GraphQLSchema,
7267
initial_type: Optional[GraphQLType] = None,
73-
get_field_def_fn: Optional[GetFieldDefFn] = None,
7468
) -> None:
7569
"""Initialize the TypeInfo for the given GraphQL schema.
7670
7771
Initial type may be provided in rare cases to facilitate traversals beginning
7872
somewhere other than documents.
79-
80-
The optional last parameter is deprecated and will be removed in v3.3.
8173
"""
8274
self._schema = schema
8375
self._type_stack: List[Optional[GraphQLOutputType]] = []
@@ -88,7 +80,6 @@ def __init__(
8880
self._directive: Optional[GraphQLDirective] = None
8981
self._argument: Optional[GraphQLArgument] = None
9082
self._enum_value: Optional[GraphQLEnumValue] = None
91-
self._get_field_def: GetFieldDefFn = get_field_def_fn or get_field_def
9283
if initial_type:
9384
if is_input_type(initial_type):
9485
self._input_type_stack.append(cast(GraphQLInputType, initial_type))
@@ -158,7 +149,7 @@ def enter_selection_set(self, node: SelectionSetNode) -> None:
158149
def enter_field(self, node: FieldNode) -> None:
159150
parent_type = self.get_parent_type()
160151
if parent_type:
161-
field_def = self._get_field_def(self._schema, parent_type, node)
152+
field_def = get_field_def(self._schema, parent_type, node)
162153
field_type = field_def.type if field_def else None
163154
else:
164155
field_def = field_type = None
@@ -277,24 +268,24 @@ def leave_enum_value(self) -> None:
277268

278269

279270
def get_field_def(
280-
schema: GraphQLSchema, parent_type: GraphQLType, field_node: FieldNode
271+
schema: GraphQLSchema, parent_type: GraphQLCompositeType, field_node: FieldNode
281272
) -> Optional[GraphQLField]:
282273
"""Get field definition.
283274
284275
Not exactly the same as the executor's definition of
285276
:func:`graphql.execution.get_field_def`, in this statically evaluated environment
286277
we do not always have an Object type, and need to handle Interface and Union types.
287278
"""
288-
name = field_node.name.value
289-
if name == "__schema" and schema.query_type is parent_type:
279+
field_name = field_node.name.value
280+
if field_name == "__schema" and schema.query_type is parent_type:
290281
return SchemaMetaFieldDef
291-
if name == "__type" and schema.query_type is parent_type:
282+
if field_name == "__type" and schema.query_type is parent_type:
292283
return TypeMetaFieldDef
293-
if name == "__typename" and is_composite_type(parent_type):
284+
if field_name == "__typename" and is_composite_type(parent_type):
294285
return TypeNameMetaFieldDef
295286
if is_object_type(parent_type) or is_interface_type(parent_type):
296287
parent_type = cast(Union[GraphQLObjectType, GraphQLInterfaceType], parent_type)
297-
return parent_type.fields.get(name)
288+
return parent_type.fields.get(field_name)
298289
return None
299290

300291

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.