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):
def as_argument(self):
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):

View File

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