@@ -365,9 +365,11 @@ def __str__(self):
365
365
def to_kwargs (self ) -> Dict [str , Any ]:
366
366
return dict (
367
367
** super ().to_kwargs (),
368
- serialize = self .serialize ,
369
- parse_value = self .parse_value ,
370
- parse_literal = self .parse_literal ,
368
+ serialize = None if self .serialize is identity_func else self .serialize ,
369
+ parse_value = None if self .parse_value is identity_func else self .parse_value ,
370
+ parse_literal = None
371
+ if self .parse_literal is value_from_ast_untyped
372
+ else self .parse_literal ,
371
373
)
372
374
373
375
@@ -529,24 +531,29 @@ class GraphQLArgument:
529
531
type : "GraphQLInputType"
530
532
default_value : Any
531
533
description : Optional [str ]
534
+ out_name : Optional [str ] # for transforming names (extension of GraphQL.js)
532
535
ast_node : Optional [InputValueDefinitionNode ]
533
536
534
537
def __init__ (
535
538
self ,
536
539
type_ : "GraphQLInputType" ,
537
540
default_value : Any = INVALID ,
538
541
description : str = None ,
542
+ out_name : str = None ,
539
543
ast_node : InputValueDefinitionNode = None ,
540
544
) -> None :
541
545
if not is_input_type (type_ ):
542
546
raise TypeError (f"Argument type must be a GraphQL input type." )
543
547
if description is not None and not isinstance (description , str ):
544
- raise TypeError ("The description must be a string." )
548
+ raise TypeError ("Argument description must be a string." )
549
+ if out_name is not None and not isinstance (out_name , str ):
550
+ raise TypeError ("Argument out name must be a string." )
545
551
if ast_node and not isinstance (ast_node , InputValueDefinitionNode ):
546
552
raise TypeError ("Argument AST node must be an InputValueDefinitionNode." )
547
553
self .type = type_
548
554
self .default_value = default_value
549
555
self .description = description
556
+ self .out_name = out_name
550
557
self .ast_node = ast_node
551
558
552
559
def __eq__ (self , other ):
@@ -555,13 +562,15 @@ def __eq__(self, other):
555
562
and self .type == other .type
556
563
and self .default_value == other .default_value
557
564
and self .description == other .description
565
+ and self .out_name == other .out_name
558
566
)
559
567
560
568
def to_kwargs (self ) -> Dict [str , Any ]:
561
569
return dict (
562
570
type_ = self .type ,
563
571
default_value = self .default_value ,
564
572
description = self .description ,
573
+ out_name = self .out_name ,
565
574
ast_node = self .ast_node ,
566
575
)
567
576
@@ -1119,8 +1128,7 @@ class GeoPoint(GraphQLInputObjectType):
1119
1128
converted to other types by specifying an `out_type` function or class.
1120
1129
"""
1121
1130
1122
- # Transforms values to different type (this is an extension of GraphQL.js).
1123
- out_type : GraphQLInputFieldOutType
1131
+ out_type : GraphQLInputFieldOutType # transforms values (extension of GraphQL.js)
1124
1132
ast_node : Optional [InputObjectTypeDefinitionNode ]
1125
1133
extension_ast_nodes : Optional [Tuple [InputObjectTypeExtensionNode ]]
1126
1134
@@ -1156,7 +1164,13 @@ def __init__(
1156
1164
self .out_type = out_type or identity_func # type: ignore
1157
1165
1158
1166
def to_kwargs (self ) -> Dict [str , Any ]:
1159
- return dict (** super ().to_kwargs (), fields = self .fields .copy ())
1167
+ return dict (
1168
+ ** super ().to_kwargs (),
1169
+ fields = self .fields .copy (),
1170
+ out_type = None
1171
+ if self .out_type is identity_func # type: ignore
1172
+ else self .out_type , # type: ignore
1173
+ )
1160
1174
1161
1175
@cached_property
1162
1176
def fields (self ) -> GraphQLInputFieldMap :
@@ -1204,38 +1218,48 @@ class GraphQLInputField:
1204
1218
"""Definition of a GraphQL input field"""
1205
1219
1206
1220
type : "GraphQLInputType"
1207
- description : Optional [str ]
1208
1221
default_value : Any
1222
+ description : Optional [str ]
1223
+ out_name : Optional [str ] # for transforming names (extension of GraphQL.js)
1209
1224
ast_node : Optional [InputValueDefinitionNode ]
1210
1225
1211
1226
def __init__ (
1212
1227
self ,
1213
1228
type_ : "GraphQLInputType" ,
1214
- description : str = None ,
1215
1229
default_value : Any = INVALID ,
1230
+ description : str = None ,
1231
+ out_name : str = None ,
1216
1232
ast_node : InputValueDefinitionNode = None ,
1217
1233
) -> None :
1218
1234
if not is_input_type (type_ ):
1219
1235
raise TypeError (f"Input field type must be a GraphQL input type." )
1236
+ if description is not None and not isinstance (description , str ):
1237
+ raise TypeError ("Input field description must be a string." )
1238
+ if out_name is not None and not isinstance (out_name , str ):
1239
+ raise TypeError ("Input field out name must be a string." )
1220
1240
if ast_node and not isinstance (ast_node , InputValueDefinitionNode ):
1221
1241
raise TypeError ("Input field AST node must be an InputValueDefinitionNode." )
1222
1242
self .type = type_
1223
1243
self .default_value = default_value
1224
1244
self .description = description
1245
+ self .out_name = out_name
1225
1246
self .ast_node = ast_node
1226
1247
1227
1248
def __eq__ (self , other ):
1228
1249
return self is other or (
1229
1250
isinstance (other , GraphQLInputField )
1230
1251
and self .type == other .type
1252
+ and self .default_value == other .default_value
1231
1253
and self .description == other .description
1254
+ and self .out_name == other .out_name
1232
1255
)
1233
1256
1234
1257
def to_kwargs (self ) -> Dict [str , Any ]:
1235
1258
return dict (
1236
1259
type_ = self .type ,
1237
1260
description = self .description ,
1238
1261
default_value = self .default_value ,
1262
+ out_name = self .out_name ,
1239
1263
ast_node = self .ast_node ,
1240
1264
)
1241
1265
0 commit comments