mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-25 19:13:57 +03:00
commit
4787cdc200
|
@ -35,7 +35,7 @@ from .utils.resolve_only_args import resolve_only_args
|
|||
from .utils.module_loading import lazy_import
|
||||
|
||||
|
||||
VERSION = (2, 1, 0, 'final', 0)
|
||||
VERSION = (2, 1, 1, 'final', 0)
|
||||
|
||||
__version__ = get_version(VERSION)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import inspect
|
||||
from functools import partial
|
||||
|
||||
from .mountedtype import MountedType
|
||||
|
||||
|
@ -11,7 +12,7 @@ class Dynamic(MountedType):
|
|||
|
||||
def __init__(self, type, with_schema=False, _creation_counter=None):
|
||||
super(Dynamic, self).__init__(_creation_counter=_creation_counter)
|
||||
assert inspect.isfunction(type)
|
||||
assert inspect.isfunction(type) or isinstance(type, partial)
|
||||
self.type = type
|
||||
self.with_schema = with_schema
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from functools import partial
|
||||
from ..dynamic import Dynamic
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
|
@ -25,3 +26,11 @@ def test_list_non_null():
|
|||
dynamic = Dynamic(lambda: List(NonNull(String)))
|
||||
assert dynamic.get_type().of_type.of_type == String
|
||||
assert str(dynamic.get_type()) == '[String!]'
|
||||
|
||||
|
||||
def test_partial():
|
||||
def __type(_type):
|
||||
return _type
|
||||
dynamic = Dynamic(partial(__type, String))
|
||||
assert dynamic.get_type() == String
|
||||
assert str(dynamic.get_type()) == 'String'
|
||||
|
|
Loading…
Reference in New Issue
Block a user