mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-14 05:36:45 +03:00
Improved name in Field. Could be an Argument
This commit is contained in:
parent
e27af63f3a
commit
2eea03cb62
|
@ -8,8 +8,8 @@ from ..classtypes.base import FieldsClassType
|
||||||
from ..classtypes.inputobjecttype import InputObjectType
|
from ..classtypes.inputobjecttype import InputObjectType
|
||||||
from ..classtypes.mutation import Mutation
|
from ..classtypes.mutation import Mutation
|
||||||
from ..exceptions import SkipField
|
from ..exceptions import SkipField
|
||||||
from .argument import ArgumentsGroup, snake_case_args
|
from .argument import Argument, ArgumentsGroup, snake_case_args
|
||||||
from .base import GroupNamedType, LazyType, MountType, NamedType, OrderedType
|
from .base import GroupNamedType, LazyType, MountType, NamedType, ArgumentType, OrderedType
|
||||||
from .definitions import NonNull
|
from .definitions import NonNull
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ class Field(NamedType, OrderedType):
|
||||||
self, type, description=None, args=None, name=None, resolver=None,
|
self, type, description=None, args=None, name=None, resolver=None,
|
||||||
required=False, default=None, *args_list, **kwargs):
|
required=False, default=None, *args_list, **kwargs):
|
||||||
_creation_counter = kwargs.pop('_creation_counter', None)
|
_creation_counter = kwargs.pop('_creation_counter', None)
|
||||||
|
if isinstance(name, (Argument, ArgumentType)):
|
||||||
|
kwargs['name'] = name
|
||||||
|
name = None
|
||||||
super(Field, self).__init__(name=name, _creation_counter=_creation_counter)
|
super(Field, self).__init__(name=name, _creation_counter=_creation_counter)
|
||||||
if isinstance(type, six.string_types):
|
if isinstance(type, six.string_types):
|
||||||
type = LazyType(type)
|
type = LazyType(type)
|
||||||
|
|
|
@ -104,6 +104,14 @@ def test_field_custom_arguments():
|
||||||
assert 'p' in schema.T(args)
|
assert 'p' in schema.T(args)
|
||||||
|
|
||||||
|
|
||||||
|
def test_field_name_as_argument():
|
||||||
|
field = Field(None, name=String())
|
||||||
|
schema = Schema()
|
||||||
|
|
||||||
|
args = field.arguments
|
||||||
|
assert 'name' in schema.T(args)
|
||||||
|
|
||||||
|
|
||||||
def test_inputfield_internal_type():
|
def test_inputfield_internal_type():
|
||||||
field = InputField(String, description='My input field', default='3')
|
field = InputField(String, description='My input field', default='3')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user