mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 09:37:07 +03:00
Rename get_resolver -> wrap_resolve and fix tests
This commit is contained in:
parent
62f95f2858
commit
da9f41c295
|
@ -58,7 +58,7 @@ class DjangoListField(Field):
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def get_resolver(self, parent_resolver):
|
def wrap_resolve(self, parent_resolver):
|
||||||
_type = self.type
|
_type = self.type
|
||||||
if isinstance(_type, NonNull):
|
if isinstance(_type, NonNull):
|
||||||
_type = _type.of_type
|
_type = _type.of_type
|
||||||
|
@ -217,7 +217,7 @@ class DjangoConnectionField(ConnectionField):
|
||||||
|
|
||||||
return on_resolve(iterable)
|
return on_resolve(iterable)
|
||||||
|
|
||||||
def get_resolver(self, parent_resolver):
|
def wrap_resolve(self, parent_resolver):
|
||||||
return partial(
|
return partial(
|
||||||
self.connection_resolver,
|
self.connection_resolver,
|
||||||
parent_resolver,
|
parent_resolver,
|
||||||
|
|
|
@ -417,12 +417,14 @@ def test_global_id_field_relation_with_filter():
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
filter_fields = ["first_name", "articles"]
|
filter_fields = ["first_name", "articles"]
|
||||||
|
|
||||||
class ArticleFilterNode(DjangoObjectType):
|
class ArticleFilterNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Article
|
model = Article
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
filter_fields = ["headline", "reporter"]
|
filter_fields = ["headline", "reporter"]
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
|
@ -472,12 +474,14 @@ def test_global_id_field_relation_with_filter_not_valid_id():
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
filter_fields = ["first_name", "articles"]
|
filter_fields = ["first_name", "articles"]
|
||||||
|
|
||||||
class ArticleFilterNode(DjangoObjectType):
|
class ArticleFilterNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Article
|
model = Article
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
filter_fields = ["headline", "reporter"]
|
filter_fields = ["headline", "reporter"]
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
|
|
|
@ -1122,6 +1122,7 @@ def test_connection_should_limit_after_to_list_length():
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
class Query(graphene.ObjectType):
|
class Query(graphene.ObjectType):
|
||||||
all_reporters = DjangoConnectionField(ReporterType)
|
all_reporters = DjangoConnectionField(ReporterType)
|
||||||
|
@ -1166,6 +1167,7 @@ def test_should_return_max_limit(graphene_settings):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
class Query(graphene.ObjectType):
|
class Query(graphene.ObjectType):
|
||||||
all_reporters = DjangoConnectionField(ReporterType)
|
all_reporters = DjangoConnectionField(ReporterType)
|
||||||
|
@ -1198,6 +1200,7 @@ def test_should_have_next_page(graphene_settings):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
|
fields = "__all__"
|
||||||
|
|
||||||
class Query(graphene.ObjectType):
|
class Query(graphene.ObjectType):
|
||||||
all_reporters = DjangoConnectionField(ReporterType)
|
all_reporters = DjangoConnectionField(ReporterType)
|
||||||
|
|
|
@ -39,7 +39,7 @@ def test_camelize():
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@patch("graphene_django.utils.testing.Client.post")
|
@patch("graphene_django.utils.testing.Client.post")
|
||||||
def test_graphql_test_case_op_name(post_mock):
|
def test_graphql_test_case_operation_name(post_mock):
|
||||||
"""
|
"""
|
||||||
Test that `GraphQLTestCase.query()`'s `operation_name` argument produces an `operationName` field.
|
Test that `GraphQLTestCase.query()`'s `operation_name` argument produces an `operationName` field.
|
||||||
"""
|
"""
|
||||||
|
@ -63,8 +63,8 @@ def test_graphql_test_case_op_name(post_mock):
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@patch("graphene_django.utils.testing.Client.post")
|
@patch("graphene_django.utils.testing.Client.post")
|
||||||
def test_graphql_query_case_op_name(post_mock):
|
def test_graphql_query_case_operation_name(post_mock):
|
||||||
graphql_query("query { }", op_name="QueryName")
|
graphql_query("query { }", operation_name="QueryName")
|
||||||
body = json.loads(post_mock.call_args.args[1])
|
body = json.loads(post_mock.call_args.args[1])
|
||||||
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
|
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
|
||||||
assert (
|
assert (
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -58,7 +58,7 @@ setup(
|
||||||
keywords="api graphql protocol rest relay graphene",
|
keywords="api graphql protocol rest relay graphene",
|
||||||
packages=find_packages(exclude=["tests"]),
|
packages=find_packages(exclude=["tests"]),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"graphene>=3.0.0b1,<4",
|
"graphene>=3.0.0b5,<4",
|
||||||
"graphql-core>=3.1.0,<4",
|
"graphql-core>=3.1.0,<4",
|
||||||
"Django>=2.2",
|
"Django>=2.2",
|
||||||
"promise>=2.1",
|
"promise>=2.1",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user