Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union, tests and fixes #24

Open
wants to merge 7 commits into
base: migration
Choose a base branch
from
Open

Union, tests and fixes #24

wants to merge 7 commits into from

Conversation

timuralchin
Copy link
Contributor

No description provided.

@timuralchin timuralchin self-assigned this Mar 23, 2022
"""Base union type."""

class Meta:
types = (None,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверное, стоит добавить проверку, что здесь лежат только DjangoObjectType в методе init_subclass_with_meta

@@ -191,7 +207,8 @@ def merge_model_and_interface_fields(cls, django_fields, interface_fields) -> Di
for field_name, field_description in interface_fields.items():
# replace description from interface if it is not none.
if field_description.description:
merged_fields.get(field_name).description = field_description.description
merged_fields.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можешь плз поправить везде переносы

from tests.django_setup.models import Article, Author, Post


class PostType(DjangoObjectType):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут для тестов, наверное, лучше стоит использовать наш BaseDjangoObjectType

@classmethod
def resolve_type(cls, instance, info):
"""Resolving grapql type by models instance."""
for type in cls._meta.types:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь бы переименовать на type_, чтобы не перезаписывать внутреннюю функцию python-а

@@ -36,6 +35,21 @@ class PatchedDjangoObjectTypeOptions(ObjectTypeOptions):
default_resolver = None


class BaseUnion(graphene.Union):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут бы тоже переименовать, что это DjangoModelUnion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants