mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-03 05:04:14 +03:00
Fixed List, NonNull accessors as functions instead of properties
This commit is contained in:
parent
ee19445290
commit
2f6fb89f23
|
@ -1,5 +1,6 @@
|
||||||
import copy
|
import copy
|
||||||
import inspect
|
import inspect
|
||||||
|
from functools import partial
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
@ -48,8 +49,8 @@ class ClassTypeMeta(type):
|
||||||
|
|
||||||
if not cls._meta.abstract:
|
if not cls._meta.abstract:
|
||||||
from ..types import List, NonNull
|
from ..types import List, NonNull
|
||||||
setattr(cls, 'NonNull', NonNull(cls))
|
setattr(cls, 'NonNull', partial(NonNull, cls))
|
||||||
setattr(cls, 'List', List(cls))
|
setattr(cls, 'List', partial(List, cls))
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,26 @@ def test_classtype_advanced():
|
||||||
def test_classtype_definition_list():
|
def test_classtype_definition_list():
|
||||||
class Character(ClassType):
|
class Character(ClassType):
|
||||||
'''Character description'''
|
'''Character description'''
|
||||||
assert isinstance(Character.List, List)
|
assert isinstance(Character.List(), List)
|
||||||
assert Character.List.of_type == Character
|
assert Character.List().of_type == Character
|
||||||
|
|
||||||
|
|
||||||
def test_classtype_definition_nonnull():
|
def test_classtype_definition_nonnull():
|
||||||
class Character(ClassType):
|
class Character(ClassType):
|
||||||
'''Character description'''
|
'''Character description'''
|
||||||
assert isinstance(Character.NonNull, NonNull)
|
assert isinstance(Character.NonNull(), NonNull)
|
||||||
assert Character.NonNull.of_type == Character
|
assert Character.NonNull().of_type == Character
|
||||||
|
|
||||||
|
|
||||||
|
def test_fieldsclasstype_definition_order():
|
||||||
|
class Character(ClassType):
|
||||||
|
'''Character description'''
|
||||||
|
|
||||||
|
class Query(FieldsClassType):
|
||||||
|
name = String()
|
||||||
|
char = Character.NonNull()
|
||||||
|
|
||||||
|
assert list(Query._meta.fields_map.keys()) == ['name', 'char']
|
||||||
|
|
||||||
|
|
||||||
def test_fieldsclasstype():
|
def test_fieldsclasstype():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user