-
-
Notifications
You must be signed in to change notification settings - Fork 120
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: Extract interface definition in optimizer to fix django-polymorphic #556
Conversation
Reviewer's Guide by SourceryThis pull request addresses a bug by extracting the GraphQL definition from a strawberry definition based on whether it is an interface or an object type. The changes primarily involve refactoring the code to use a new helper function File-Level Changes
Tips
|
for more information, see https://pre-commit.ci
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.
Hey @ManiacMaxo - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@ManiacMaxo this looks good, could you add a test? 😊 |
I'll try to add a unit test |
Hey @ManiacMaxo , I saw that you mentioned on #550 (comment) that this might only be reproducible by django-polymorphic. If that's the case, feel free to add Let me know if you have any issues/doubts about that or anything else in here (e.g. the failing typing tests) |
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.
Thanks! :)
Seems it don't work if the type class is a relay node. I've added a test for it here: https://github.com/stygmate/strawberry-django/tree/test-optimizer-with-polymorphic-relay-node you can test on the test-optimizer-with-polymorphic-relay-node branch of my fork by running: If you disable the optimizer in the schema of this test, the test pass. |
Thanks for the test @stygmate , Will use it to investigate and try to fix the issue :) |
@bellini666 I have made a patch. I modified two asserts of instance type. Here is the patch: https://github.com/stygmate/strawberry-django/tree/test-optimizer-with-polymorphic-relay-node Do you want me to make a pull request ? |
Hey @stygmate , Oh, I lost your comment, sorry. Yes please, open the PR :) obs. PRs are always welcomed, no need to wait for my approval 😊 |
Description
Extracting GraphQL definition from a strawberry definition based on the type (interface or object type)
Types of Changes
Issues Fixed or Closed by This PR
Checklist
Summary by Sourcery
This pull request addresses a bug in the optimizer by correctly extracting GraphQL definitions from Strawberry definitions, handling both interface and object types. It also includes a refactoring to improve code clarity and maintainability.
_get_gql_definition
for determining the GraphQL definition based on the type.