1
- from collections import OrderedDict
2
1
from functools import wraps
3
2
from itertools import chain
4
3
5
4
from graphql .core .type import GraphQLArgument
6
5
7
- from ...utils import ProxySnakeDict , to_camel_case
6
+ from ...utils import ProxySnakeDict
8
7
from .base import ArgumentType , GroupNamedType , NamedType , OrderedType
9
8
10
9
@@ -14,6 +13,7 @@ def __init__(self, type, description=None, default=None,
14
13
name = None , _creation_counter = None ):
15
14
super (Argument , self ).__init__ (_creation_counter = _creation_counter )
16
15
self .name = name
16
+ self .attname = None
17
17
self .type = type
18
18
self .description = description
19
19
self .default = default
@@ -38,20 +38,21 @@ def to_arguments(*args, **kwargs):
38
38
arguments = {}
39
39
iter_arguments = chain (kwargs .items (), [(None , a ) for a in args ])
40
40
41
- for name , arg in iter_arguments :
41
+ for attname , arg in iter_arguments :
42
42
if isinstance (arg , Argument ):
43
43
argument = arg
44
44
elif isinstance (arg , ArgumentType ):
45
45
argument = arg .as_argument ()
46
46
else :
47
- raise ValueError ('Unknown argument %s=%r' % (name , arg ))
48
-
49
- if name :
50
- argument .name = to_camel_case (name )
51
- assert argument .name , 'Argument in field must have a name'
52
- assert argument .name not in arguments , 'Found more than one Argument with same name {}' .format (
53
- argument .name )
54
- arguments [argument .name ] = argument
47
+ raise ValueError ('Unknown argument %s=%r' % (attname , arg ))
48
+
49
+ if attname :
50
+ argument .attname = attname
51
+
52
+ name = argument .name or argument .attname
53
+ assert name , 'Argument in field must have a name'
54
+ assert name not in arguments , 'Found more than one Argument with same name {}' .format (name )
55
+ arguments [name ] = argument
55
56
56
57
return sorted (arguments .values ())
57
58
0 commit comments