-
-
Notifications
You must be signed in to change notification settings - Fork 528
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 codegen crash on nullable lists of non-scalars #3653
Fix codegen crash on nullable lists of non-scalars #3653
Conversation
Reviewer's Guide by SourceryThis pull request fixes a bug in the codegen tool where it would crash when working with a nullable list of non-scalar types. The fix involves modifying the _unwrap_type function in the query_codegen.py file to correctly handle nested optional and list types. Additionally, new test cases and snapshots have been added to ensure the functionality works as expected. Sequence DiagramsequenceDiagram
participant Caller
participant _unwrap_type
participant StrawberryOptional
participant StrawberryList
Caller->>_unwrap_type: Call with type
alt type is StrawberryOptional
_unwrap_type->>StrawberryOptional: Unwrap of_type
StrawberryOptional-->>_unwrap_type: Return unwrapped type
_unwrap_type->>_unwrap_type: Recursive call
_unwrap_type->>_unwrap_type: Create wrapper with previous_wrapper
else type is StrawberryList
_unwrap_type->>StrawberryList: Unwrap of_type
StrawberryList-->>_unwrap_type: Return unwrapped type
_unwrap_type->>_unwrap_type: Recursive call
_unwrap_type->>_unwrap_type: Create wrapper with previous_wrapper
end
_unwrap_type-->>Caller: Return unwrapped type and wrapper
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @enoua5 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟡 Documentation: 1 issue found
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Thanks for adding the Here's a preview of the changelog: Fixes an issue where the codegen tool would crash when working with a nullable list of types. Here's the tweet text:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3653 +/- ##
==========================================
+ Coverage 96.76% 96.82% +0.05%
==========================================
Files 522 503 -19
Lines 33824 33410 -414
Branches 5635 5583 -52
==========================================
- Hits 32731 32350 -381
+ Misses 863 830 -33
Partials 230 230 |
CodSpeed Performance ReportMerging #3653 will not alter performanceComparing Summary
|
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.
Hi @enoua5, thanks for the PR. I had to read the corresponding issue to understand the changes and what was going on. Thanks for fixing the recursion. I left two minor suggestions regarding the test's readability/verifiability.
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.
Awesome, thanks again @enoua5. This looks good to me now
Description
Codegen would previously crash when working with a nullable list of non-scalars. This was due to a lambda referencing a value that would get rewritten with that same lambda causing an endless recursion.
Types of Changes
Issues Fixed or Closed by This PR
Checklist
My change requires a change to the documentation.I have updated the documentation accordingly.Summary by Sourcery
Fix the code generation crash when processing nullable lists of non-scalar types by adjusting the lambda function handling and add corresponding tests.
Bug Fixes:
Tests:
Chores: