Fixed arg names

This commit is contained in:
Syrus Akbary 2016-08-21 23:33:32 -07:00
parent dac4f2dc19
commit d17bd0aa3e
4 changed files with 12 additions and 11 deletions

View File

@ -8,7 +8,6 @@ from ..types import SQLAlchemyObjectType
from ..registry import Registry
from graphene import Field, Int
# from tests.utils import assert_equal_lists
from .models import Article, Reporter

View File

@ -73,7 +73,7 @@ def test_big_list_query_benchmark(benchmark):
def test_big_list_query_compiled_query_benchmark(benchmark):
big_list = range(10000)
big_list = range(100000)
class Query(ObjectType):
all_ints = List(Int)
@ -95,7 +95,7 @@ def test_big_list_of_containers_query_benchmark(benchmark):
class Container(ObjectType):
x = Int()
big_container_list = [Container(x=x) for x in range(10000)]
big_container_list = [Container(x=x) for x in range(1000)]
class Query(ObjectType):
all_containers = List(Container)
@ -118,7 +118,7 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
z = Int()
o = Int()
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(10000)]
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(1000)]
class Query(ObjectType):
all_containers = List(Container)
@ -153,7 +153,7 @@ def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark
def resolve_o(self, args, context, info):
return self.o
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(10000)]
big_container_list = [Container(x=x, y=x, z=x, o=x) for x in range(1000)]
class Query(ObjectType):
all_containers = List(Container)

View File

@ -36,7 +36,7 @@ def test_enum():
assert isinstance(graphql_enum, GraphQLEnumType)
assert graphql_enum.name == 'MyEnum'
assert graphql_enum.description == 'Description'
values = graphql_enum.get_values()
values = graphql_enum.values
assert values == [
GraphQLEnumValue(name='foo', value=1, description='Description foo=1', deprecation_reason='Is deprecated'),
GraphQLEnumValue(name='bar', value=2, description='Description bar=2'),
@ -59,7 +59,7 @@ def test_objecttype():
assert graphql_type.name == 'MyObjectType'
assert graphql_type.description == 'Description'
fields = graphql_type.get_fields()
fields = graphql_type.fields
assert list(fields.keys()) == ['foo', 'gizmo']
foo_field = fields['foo']
assert isinstance(foo_field, GraphQLField)
@ -82,7 +82,7 @@ def test_dynamic_objecttype():
assert list(MyObjectType._meta.fields.keys()) == ['bar', 'own']
graphql_type = typemap['MyObjectType']
fields = graphql_type.get_fields()
fields = graphql_type.fields
assert list(fields.keys()) == ['bar', 'own']
assert fields['bar'].type == GraphQLString
assert fields['own'].type == graphql_type
@ -92,7 +92,7 @@ def test_interface():
class MyInterface(Interface):
'''Description'''
foo = String(bar=String(description='Argument description', default_value='x'), description='Field description')
bar = String(name='gizmo')
bar = String(name='gizmo', first_arg=String(), other_arg=String(name='oth_arg'))
own = Field(lambda: MyInterface)
def resolve_foo(self, args, info):
@ -105,9 +105,10 @@ def test_interface():
assert graphql_type.name == 'MyInterface'
assert graphql_type.description == 'Description'
fields = graphql_type.get_fields()
fields = graphql_type.fields
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
assert fields['own'].type == graphql_type
assert (fields['gizmo'].args.keys()) == ['firstArg', 'oth_arg']
foo_field = fields['foo']
assert isinstance(foo_field, GraphQLField)
assert foo_field.description == 'Field description'
@ -134,7 +135,7 @@ def test_inputobject():
assert graphql_type.name == 'MyInputObjectType'
assert graphql_type.description == 'Description'
fields = graphql_type.get_fields()
fields = graphql_type.fields
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
assert fields['own'].type == graphql_type
foo_field = fields['foo']

View File

@ -213,6 +213,7 @@ class TypeMap(GraphQLTypeMap):
for arg_name, arg in field.args.items():
map = cls.reducer(map, arg.type)
arg_type = cls.get_field_type(map, arg.type)
arg_name = arg.name or cls.process_field_name(arg_name)
args[arg_name] = GraphQLArgument(
arg_type,
description=arg.description,