Fixed argument types

This commit is contained in:
Syrus Akbary 2015-11-10 23:05:11 -08:00
parent 41648b5a94
commit 862fa6f312
2 changed files with 12 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class MirroredType(OrderedType):
class ArgumentType(MirroredType): class ArgumentType(MirroredType):
def as_argument(self): def as_argument(self):
from .argument import Argument from .argument import Argument
return Argument(self.__class__, _creation_counter=self.creation_counter, *self.args, **self.kwargs) return Argument(self, _creation_counter=self.creation_counter, *self.args, **self.kwargs)
class FieldType(MirroredType): class FieldType(MirroredType):

View File

@ -1,15 +1,24 @@
import six import six
from collections import OrderedDict from collections import OrderedDict
from functools import wraps
from graphql.core.type import GraphQLField, GraphQLInputObjectField from graphql.core.type import GraphQLField, GraphQLInputObjectField
from .base import LazyType, OrderedType from .base import LazyType, OrderedType
from .argument import ArgumentsGroup from .argument import ArgumentsGroup
from .definitions import NonNull from .definitions import NonNull
from ...utils import to_camel_case from ...utils import to_camel_case, ProxySnakeDict
from ..types import BaseObjectType, InputObjectType from ..types import BaseObjectType, InputObjectType
def make_args_snake_case(resolver):
@wraps(resolver)
def wrapped_resolver(instance, args, info):
return resolver(instance, ProxySnakeDict(args), info)
return wrapped_resolver
class Empty(object): class Empty(object):
pass pass
@ -72,6 +81,7 @@ class Field(OrderedType):
arguments = type_objecttype.get_arguments() arguments = type_objecttype.get_arguments()
resolver = getattr(type_objecttype, 'mutate') resolver = getattr(type_objecttype, 'mutate')
resolver = make_args_snake_case(resolver)
assert type, 'Internal type for field %s is None' % str(self) assert type, 'Internal type for field %s is None' % str(self)
return GraphQLField(type, args=schema.T(arguments), resolver=resolver, return GraphQLField(type, args=schema.T(arguments), resolver=resolver,
description=description,) description=description,)