mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Fixed arg names
This commit is contained in:
parent
dac4f2dc19
commit
d17bd0aa3e
|
@ -8,7 +8,6 @@ from ..types import SQLAlchemyObjectType
|
||||||
from ..registry import Registry
|
from ..registry import Registry
|
||||||
|
|
||||||
from graphene import Field, Int
|
from graphene import Field, Int
|
||||||
# from tests.utils import assert_equal_lists
|
|
||||||
|
|
||||||
from .models import Article, Reporter
|
from .models import Article, Reporter
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ def test_big_list_query_benchmark(benchmark):
|
||||||
|
|
||||||
|
|
||||||
def test_big_list_query_compiled_query_benchmark(benchmark):
|
def test_big_list_query_compiled_query_benchmark(benchmark):
|
||||||
big_list = range(10000)
|
big_list = range(100000)
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
all_ints = List(Int)
|
all_ints = List(Int)
|
||||||
|
@ -95,7 +95,7 @@ def test_big_list_of_containers_query_benchmark(benchmark):
|
||||||
class Container(ObjectType):
|
class Container(ObjectType):
|
||||||
x = Int()
|
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):
|
class Query(ObjectType):
|
||||||
all_containers = List(Container)
|
all_containers = List(Container)
|
||||||
|
@ -118,7 +118,7 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
|
||||||
z = Int()
|
z = Int()
|
||||||
o = 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):
|
class Query(ObjectType):
|
||||||
all_containers = List(Container)
|
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):
|
def resolve_o(self, args, context, info):
|
||||||
return self.o
|
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):
|
class Query(ObjectType):
|
||||||
all_containers = List(Container)
|
all_containers = List(Container)
|
||||||
|
|
|
@ -36,7 +36,7 @@ def test_enum():
|
||||||
assert isinstance(graphql_enum, GraphQLEnumType)
|
assert isinstance(graphql_enum, GraphQLEnumType)
|
||||||
assert graphql_enum.name == 'MyEnum'
|
assert graphql_enum.name == 'MyEnum'
|
||||||
assert graphql_enum.description == 'Description'
|
assert graphql_enum.description == 'Description'
|
||||||
values = graphql_enum.get_values()
|
values = graphql_enum.values
|
||||||
assert values == [
|
assert values == [
|
||||||
GraphQLEnumValue(name='foo', value=1, description='Description foo=1', deprecation_reason='Is deprecated'),
|
GraphQLEnumValue(name='foo', value=1, description='Description foo=1', deprecation_reason='Is deprecated'),
|
||||||
GraphQLEnumValue(name='bar', value=2, description='Description bar=2'),
|
GraphQLEnumValue(name='bar', value=2, description='Description bar=2'),
|
||||||
|
@ -59,7 +59,7 @@ def test_objecttype():
|
||||||
assert graphql_type.name == 'MyObjectType'
|
assert graphql_type.name == 'MyObjectType'
|
||||||
assert graphql_type.description == 'Description'
|
assert graphql_type.description == 'Description'
|
||||||
|
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.fields
|
||||||
assert list(fields.keys()) == ['foo', 'gizmo']
|
assert list(fields.keys()) == ['foo', 'gizmo']
|
||||||
foo_field = fields['foo']
|
foo_field = fields['foo']
|
||||||
assert isinstance(foo_field, GraphQLField)
|
assert isinstance(foo_field, GraphQLField)
|
||||||
|
@ -82,7 +82,7 @@ def test_dynamic_objecttype():
|
||||||
assert list(MyObjectType._meta.fields.keys()) == ['bar', 'own']
|
assert list(MyObjectType._meta.fields.keys()) == ['bar', 'own']
|
||||||
graphql_type = typemap['MyObjectType']
|
graphql_type = typemap['MyObjectType']
|
||||||
|
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.fields
|
||||||
assert list(fields.keys()) == ['bar', 'own']
|
assert list(fields.keys()) == ['bar', 'own']
|
||||||
assert fields['bar'].type == GraphQLString
|
assert fields['bar'].type == GraphQLString
|
||||||
assert fields['own'].type == graphql_type
|
assert fields['own'].type == graphql_type
|
||||||
|
@ -92,7 +92,7 @@ def test_interface():
|
||||||
class MyInterface(Interface):
|
class MyInterface(Interface):
|
||||||
'''Description'''
|
'''Description'''
|
||||||
foo = String(bar=String(description='Argument description', default_value='x'), description='Field 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)
|
own = Field(lambda: MyInterface)
|
||||||
|
|
||||||
def resolve_foo(self, args, info):
|
def resolve_foo(self, args, info):
|
||||||
|
@ -105,9 +105,10 @@ def test_interface():
|
||||||
assert graphql_type.name == 'MyInterface'
|
assert graphql_type.name == 'MyInterface'
|
||||||
assert graphql_type.description == 'Description'
|
assert graphql_type.description == 'Description'
|
||||||
|
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.fields
|
||||||
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
|
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
|
||||||
assert fields['own'].type == graphql_type
|
assert fields['own'].type == graphql_type
|
||||||
|
assert (fields['gizmo'].args.keys()) == ['firstArg', 'oth_arg']
|
||||||
foo_field = fields['foo']
|
foo_field = fields['foo']
|
||||||
assert isinstance(foo_field, GraphQLField)
|
assert isinstance(foo_field, GraphQLField)
|
||||||
assert foo_field.description == 'Field description'
|
assert foo_field.description == 'Field description'
|
||||||
|
@ -134,7 +135,7 @@ def test_inputobject():
|
||||||
assert graphql_type.name == 'MyInputObjectType'
|
assert graphql_type.name == 'MyInputObjectType'
|
||||||
assert graphql_type.description == 'Description'
|
assert graphql_type.description == 'Description'
|
||||||
|
|
||||||
fields = graphql_type.get_fields()
|
fields = graphql_type.fields
|
||||||
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
|
assert list(fields.keys()) == ['foo', 'gizmo', 'own']
|
||||||
assert fields['own'].type == graphql_type
|
assert fields['own'].type == graphql_type
|
||||||
foo_field = fields['foo']
|
foo_field = fields['foo']
|
||||||
|
|
|
@ -213,6 +213,7 @@ class TypeMap(GraphQLTypeMap):
|
||||||
for arg_name, arg in field.args.items():
|
for arg_name, arg in field.args.items():
|
||||||
map = cls.reducer(map, arg.type)
|
map = cls.reducer(map, arg.type)
|
||||||
arg_type = cls.get_field_type(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(
|
args[arg_name] = GraphQLArgument(
|
||||||
arg_type,
|
arg_type,
|
||||||
description=arg.description,
|
description=arg.description,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user