From 59f4ddcd94dbdf1df00e0d23d4569d65e190f4dd Mon Sep 17 00:00:00 2001 From: Daniel Johnston Date: Fri, 5 May 2017 14:23:21 -0700 Subject: [PATCH 1/4] Removed white space. --- graphene/types/tests/test_argument.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene/types/tests/test_argument.py b/graphene/types/tests/test_argument.py index b4cc3d58..5bec9b24 100644 --- a/graphene/types/tests/test_argument.py +++ b/graphene/types/tests/test_argument.py @@ -48,7 +48,7 @@ def test_to_arguments_raises_if_field(): with pytest.raises(ValueError) as exc_info: to_arguments(args) - + assert str(exc_info.value) == 'Expected arg_string to be Argument, but received Field. Try using Argument(String).' From 7642644d82cf287d83aaf4779dabfa83ef739184 Mon Sep 17 00:00:00 2001 From: Daniel Johnston Date: Fri, 5 May 2017 14:23:51 -0700 Subject: [PATCH 2/4] Removed white space. --- graphene/types/tests/test_argument.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene/types/tests/test_argument.py b/graphene/types/tests/test_argument.py index 5bec9b24..558afd44 100644 --- a/graphene/types/tests/test_argument.py +++ b/graphene/types/tests/test_argument.py @@ -59,5 +59,5 @@ def test_to_arguments_raises_if_inputfield(): with pytest.raises(ValueError) as exc_info: to_arguments(args) - + assert str(exc_info.value) == 'Expected arg_string to be Argument, but received InputField. Try using Argument(String).' From 388253ede47c2b998c0fb20030f86d908fb383ce Mon Sep 17 00:00:00 2001 From: Daniel Johnston Date: Fri, 5 May 2017 14:27:46 -0700 Subject: [PATCH 3/4] Added type consistency. --- graphene/types/argument.py | 7 ++++++- graphene/types/tests/test_argument.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/graphene/types/argument.py b/graphene/types/argument.py index c884b017..cb28ee5e 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -4,6 +4,7 @@ from itertools import chain from .mountedtype import MountedType from .structures import NonNull from .dynamic import Dynamic +from .utils import get_type class Argument(MountedType): @@ -15,10 +16,14 @@ class Argument(MountedType): type = NonNull(type) self.name = name - self.type = type + self._type = type self.default_value = default_value self.description = description + @property + def type(self): + return get_type(self._type) + def __eq__(self, other): return isinstance(other, Argument) and ( self.name == other.name, diff --git a/graphene/types/tests/test_argument.py b/graphene/types/tests/test_argument.py index 558afd44..256df86b 100644 --- a/graphene/types/tests/test_argument.py +++ b/graphene/types/tests/test_argument.py @@ -1,4 +1,5 @@ import pytest +from functools import partial from ..argument import Argument, to_arguments from ..field import Field @@ -61,3 +62,15 @@ def test_to_arguments_raises_if_inputfield(): to_arguments(args) assert str(exc_info.value) == 'Expected arg_string to be Argument, but received InputField. Try using Argument(String).' + + +def test_argument_with_lazy_type(): + MyType = object() + arg = Field(lambda: MyType) + assert arg.type == MyType + + +def test_argument_with_lazy_partial_type(): + MyType = object() + arg = Field(partial(lambda: MyType)) + assert arg.type == MyType \ No newline at end of file From 83857bfcfe02c9eb7d9baee367d54c0e2d887e9d Mon Sep 17 00:00:00 2001 From: Daniel Johnston Date: Fri, 5 May 2017 14:38:46 -0700 Subject: [PATCH 4/4] Fixed typo. --- graphene/types/tests/test_argument.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphene/types/tests/test_argument.py b/graphene/types/tests/test_argument.py index 256df86b..e485c01b 100644 --- a/graphene/types/tests/test_argument.py +++ b/graphene/types/tests/test_argument.py @@ -66,11 +66,11 @@ def test_to_arguments_raises_if_inputfield(): def test_argument_with_lazy_type(): MyType = object() - arg = Field(lambda: MyType) + arg = Argument(lambda: MyType) assert arg.type == MyType def test_argument_with_lazy_partial_type(): MyType = object() - arg = Field(partial(lambda: MyType)) + arg = Argument(partial(lambda: MyType)) assert arg.type == MyType \ No newline at end of file