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

fix: same type list #1492

Merged
merged 2 commits into from Jan 20, 2024
Merged

fix: same type list #1492

merged 2 commits into from Jan 20, 2024

Conversation

superlevure
Copy link
Collaborator

@superlevure superlevure commented Jan 18, 2024

Fix for #1225

Allow to use a recursive type for DjangoListField

(fix suggested by @tcleonard)

@superlevure superlevure requested review from sjdemartini, kiendang and jaw9c and removed request for sjdemartini January 18, 2024 16:07
Copy link
Collaborator

@sjdemartini sjdemartini left a comment

Choose a reason for hiding this comment

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

Looks good to me based on the tests, thanks for adding support for this!


with pytest.raises(AssertionError):
DjangoListField(TestType)
with pytest.raises(TypeError):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like in code, this failure condition is still caused by an assert statement. Just curious then why this is manifesting as a TypeError now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question! The AssertionError is now caught and re-raised as a TypeError by graphql-core here: https://github.com/graphql-python/graphql-core/blob/0c93b8452eed38d4f800c7e71cf6f3f3758cd1c6/src/graphql/type/definition.py#L734

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, thanks! Maybe it's worth adding a final line to the test to validate that the assertion message (about only using DjangoObjectTypes) is present in the raised exception string, since it seems it will be and that would make for a more thorough test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point, done in cc45b0b

Copy link
Collaborator

@kiendang kiendang left a comment

Choose a reason for hiding this comment

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

LGTM

On a side note I notice a lot of propertys (if not all of them) in DjangoListField and DjangoConnectionField are things that don't change. We could consider using functools.cached_property, but that's for a future issue/PR.

@superlevure
Copy link
Collaborator Author

Thanks for the review @kiendang @sjdemartini, I'll let one of you merge as I don't have the authorization

@sjdemartini
Copy link
Collaborator

I'm also unable to merge ("Merging is blocked...base branch restricts merging to authorized users"), but looks good to go!

@kiendang kiendang merged commit b85177c into graphql-python:main Jan 20, 2024
12 checks passed
superlevure added a commit to loft-orbital/graphene-django that referenced this pull request Jan 30, 2024
* fix: same type list

* chore: improve test
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.

None yet

4 participants