Merge pull request #1 from graphql-python/master

sync
This commit is contained in:
Dan 2018-05-25 21:25:12 -07:00 committed by GitHub
commit 4787cdc200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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

View File

@ -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'