42
42
UnionTypeExtensionNode ,
43
43
ValueNode ,
44
44
)
45
- from ..pyutils import AwaitableOrValue , cached_property , identity_func , inspect
45
+ from ..pyutils import AwaitableOrValue , cached_property , inspect
46
46
from ..utilities .value_from_ast_untyped import value_from_ast_untyped
47
47
48
48
if TYPE_CHECKING : # pragma: no cover
@@ -360,7 +360,7 @@ def __str__(self):
360
360
return self .name
361
361
362
362
@staticmethod
363
- def serialize (value : Any ):
363
+ def serialize (value : Any ) -> Any :
364
364
"""Serializes an internal value to include in a response.
365
365
366
366
This default method just passes the value through and should be replaced
@@ -369,7 +369,7 @@ def serialize(value: Any):
369
369
return value
370
370
371
371
@staticmethod
372
- def parse_value (value : Any ):
372
+ def parse_value (value : Any ) -> Any :
373
373
"""Parses an externally provided value to use as an input.
374
374
375
375
This default method just passes the value through and should be replaced
@@ -379,7 +379,7 @@ def parse_value(value: Any):
379
379
380
380
def parse_literal ( # type: ignore
381
381
self , node : ValueNode , _variables : Dict [str , Any ] = None
382
- ):
382
+ ) -> Any :
383
383
"""Parses an externally provided literal value to use as an input.
384
384
385
385
This default method uses the parse_value method and should be replaced
@@ -1158,7 +1158,6 @@ class GeoPoint(GraphQLInputObjectType):
1158
1158
converted to other types by specifying an `out_type` function or class.
1159
1159
"""
1160
1160
1161
- out_type : GraphQLInputFieldOutType # transforms values (extension of GraphQL.js)
1162
1161
ast_node : Optional [InputObjectTypeDefinitionNode ]
1163
1162
extension_ast_nodes : Optional [Tuple [InputObjectTypeExtensionNode ]]
1164
1163
@@ -1191,15 +1190,24 @@ def __init__(
1191
1190
f"{ name } extension AST nodes must be InputObjectTypeExtensionNode."
1192
1191
)
1193
1192
self ._fields = fields
1194
- self .out_type = out_type or identity_func # type: ignore
1193
+ if out_type is not None :
1194
+ self .out_type = out_type
1195
+
1196
+ @staticmethod
1197
+ def out_type (value : Dict [str , Any ]) -> Any :
1198
+ """Transform outbound values (this is an extension of GraphQL.js).
1199
+
1200
+ This default implementation passes values unaltered as dictionaries.
1201
+ """
1202
+ return value
1195
1203
1196
1204
def to_kwargs (self ) -> Dict [str , Any ]:
1197
1205
return dict (
1198
1206
** super ().to_kwargs (),
1199
1207
fields = self .fields .copy (),
1200
1208
out_type = None
1201
- if self .out_type is identity_func # type: ignore
1202
- else self .out_type , # type: ignore
1209
+ if self .out_type is GraphQLInputObjectType . out_type
1210
+ else self .out_type ,
1203
1211
)
1204
1212
1205
1213
@cached_property
0 commit comments