From d17bd0aa3e368fe9ad4a486315e7c53ca6fe8ce7 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sun, 21 Aug 2016 23:33:32 -0700 Subject: [PATCH] Fixed arg names --- .../graphene_sqlalchemy/tests/test_types.py | 1 - graphene/types/tests/test_query.py | 8 ++++---- graphene/types/tests/test_typemap.py | 13 +++++++------ graphene/types/typemap.py | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/graphene-sqlalchemy/graphene_sqlalchemy/tests/test_types.py b/graphene-sqlalchemy/graphene_sqlalchemy/tests/test_types.py index 285ede98..3bae5442 100644 --- a/graphene-sqlalchemy/graphene_sqlalchemy/tests/test_types.py +++ b/graphene-sqlalchemy/graphene_sqlalchemy/tests/test_types.py @@ -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 diff --git a/graphene/types/tests/test_query.py b/graphene/types/tests/test_query.py index 08c61f2b..a8c21987 100644 --- a/graphene/types/tests/test_query.py +++ b/graphene/types/tests/test_query.py @@ -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) diff --git a/graphene/types/tests/test_typemap.py b/graphene/types/tests/test_typemap.py index 72bdd8fa..10f06af8 100644 --- a/graphene/types/tests/test_typemap.py +++ b/graphene/types/tests/test_typemap.py @@ -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'] diff --git a/graphene/types/typemap.py b/graphene/types/typemap.py index 3b3f5768..0d0260ee 100644 --- a/graphene/types/typemap.py +++ b/graphene/types/typemap.py @@ -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,