Skip to content

Commit 1c45dec

Browse files
committed
Fix typing
1 parent 9090b6e commit 1c45dec

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

graphql/utilities/extend_schema.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717
GraphQLArgumentMap,
1818
GraphQLDirective,
1919
GraphQLEnumType,
20-
GraphQLEnumValue,
21-
GraphQLEnumValueMap,
2220
GraphQLField,
2321
GraphQLFieldMap,
2422
GraphQLInputField,
25-
GraphQLInputFieldMap,
2623
GraphQLInputObjectType,
27-
GraphQLInputType,
2824
GraphQLInterfaceType,
2925
GraphQLList,
3026
GraphQLNamedType,

graphql/utilities/lexicographic_sort_schema.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,25 @@ def sort_named_type_impl(type_: GraphQLNamedType) -> GraphQLNamedType:
100100
return type_
101101
elif is_object_type(type_):
102102
kwargs = type_.to_kwargs()
103+
object_type = cast(GraphQLObjectType, type_)
103104
kwargs.update(
104-
interfaces=lambda: sort_types(type_.interfaces),
105-
fields=lambda: sort_fields(type_.fields),
105+
interfaces=lambda: sort_types(object_type.interfaces),
106+
fields=lambda: sort_fields(object_type.fields),
106107
)
107108
return GraphQLObjectType(**kwargs)
108109
elif is_interface_type(type_):
109110
kwargs = type_.to_kwargs()
110-
kwargs.update(fields=lambda: sort_fields(type_.fields))
111+
interface_type = cast(GraphQLInterfaceType, type_)
112+
kwargs.update(fields=lambda: sort_fields(interface_type.fields))
111113
return GraphQLInterfaceType(**kwargs)
112114
elif is_union_type(type_):
113115
kwargs = type_.to_kwargs()
114-
kwargs.update(types=lambda: sort_types(type_.types))
116+
union_type = cast(GraphQLUnionType, type_)
117+
kwargs.update(types=lambda: sort_types(union_type.types))
115118
return GraphQLUnionType(**kwargs)
116119
elif is_enum_type(type_):
117120
kwargs = type_.to_kwargs()
121+
enum_type = cast(GraphQLEnumType, type_)
118122
kwargs.update(
119123
values={
120124
name: GraphQLEnumValue(
@@ -123,13 +127,14 @@ def sort_named_type_impl(type_: GraphQLNamedType) -> GraphQLNamedType:
123127
deprecation_reason=val.deprecation_reason,
124128
ast_node=val.ast_node,
125129
)
126-
for name, val in sorted(type_.values.items())
130+
for name, val in sorted(enum_type.values.items())
127131
}
128132
)
129133
return GraphQLEnumType(**kwargs)
130134
elif is_input_object_type(type_):
131135
kwargs = type_.to_kwargs()
132-
kwargs.update(fields=sort_input_fields(type_.fields))
136+
input_object_type = cast(GraphQLInputObjectType, type_)
137+
kwargs.update(fields=sort_input_fields(input_object_type.fields))
133138
return GraphQLInputObjectType(**kwargs)
134139
raise TypeError(f"Unknown type: '{type_}'")
135140

0 commit comments

Comments
 (0)