-
Notifications
You must be signed in to change notification settings - Fork 764
fix: same type list #1492
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
Conversation
There was a problem hiding this 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!
graphene_django/tests/test_fields.py
Outdated
|
||
with pytest.raises(AssertionError): | ||
DjangoListField(TestType) | ||
with pytest.raises(TypeError): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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 property
s (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.
Thanks for the review @kiendang @sjdemartini, I'll let one of you merge as I don't have the authorization |
I'm also unable to merge ("Merging is blocked...base branch restricts merging to authorized users"), but looks good to go! |
* fix: same type list * chore: improve test
Fix for #1225
Allow to use a recursive type for
DjangoListField
(fix suggested by @tcleonard)