@@ -100,21 +100,25 @@ def sort_named_type_impl(type_: GraphQLNamedType) -> GraphQLNamedType:
100
100
return type_
101
101
elif is_object_type (type_ ):
102
102
kwargs = type_ .to_kwargs ()
103
+ object_type = cast (GraphQLObjectType , type_ )
103
104
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 ),
106
107
)
107
108
return GraphQLObjectType (** kwargs )
108
109
elif is_interface_type (type_ ):
109
110
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 ))
111
113
return GraphQLInterfaceType (** kwargs )
112
114
elif is_union_type (type_ ):
113
115
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 ))
115
118
return GraphQLUnionType (** kwargs )
116
119
elif is_enum_type (type_ ):
117
120
kwargs = type_ .to_kwargs ()
121
+ enum_type = cast (GraphQLEnumType , type_ )
118
122
kwargs .update (
119
123
values = {
120
124
name : GraphQLEnumValue (
@@ -123,13 +127,14 @@ def sort_named_type_impl(type_: GraphQLNamedType) -> GraphQLNamedType:
123
127
deprecation_reason = val .deprecation_reason ,
124
128
ast_node = val .ast_node ,
125
129
)
126
- for name , val in sorted (type_ .values .items ())
130
+ for name , val in sorted (enum_type .values .items ())
127
131
}
128
132
)
129
133
return GraphQLEnumType (** kwargs )
130
134
elif is_input_object_type (type_ ):
131
135
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 ))
133
138
return GraphQLInputObjectType (** kwargs )
134
139
raise TypeError (f"Unknown type: '{ type_ } '" )
135
140
0 commit comments