-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
Update accessing parent data guide with lazy type declaration #3714
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis PR updates the "Accessing Parent Data" documentation guide to fix incorrect type declarations by introducing lazy type declarations for parent references. The changes ensure that the code examples work correctly when the parent class hasn't been defined yet at the point of resolver definition. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @mattalbr - 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: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Checking the changes to the docs here I wonder if straightforward cases like this, where i.e. lazy is mostly useful for when we want to avoid circular import issues, and because of that, we need to import the other type inside a For the cases documented here, Maybe we should try to fix the issue instead? What do you think @mattalbr ? |
@bellini666 I agree that the Some ideas I could think of:
Option 2 is definitely my preferred solution, I'm just not sure how much work it would take to get it working here. I see that strawberry already tries to do some recognition of string types and swapping them out for forward declarations, but it doesn't seem to work in this case (I tried in my own repo and it tried to resolve the type immediately and errored). I'm not familiar enough with the typing code to know where to make those changes, unfortunately. |
Description
The "accessing parent data" guide did not actually work as written because the strawberry.Parents need to use lazy declarations if the class is not yet defined.
This was identified and discussed in #3481 (comment)
The strawberry lazy incantation is quite verbose, hence why "self" remains useful.
I'm definitely not a doc writer, so just did my best. Feel free to suggest edits.
Types of Changes
Issues Fixed or Closed by This PR
strawberry.Parent
not supporting forward refs #3481Checklist
Summary by Sourcery
Documentation: