-
Notifications
You must be signed in to change notification settings - Fork 228
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
Stricter non-null fields for relationships #367
Stricter non-null fields for relationships #367
Conversation
Codecov ReportBase: 96.34% // Head: 96.36% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #367 +/- ##
==========================================
+ Coverage 96.34% 96.36% +0.02%
==========================================
Files 9 9
Lines 903 908 +5
==========================================
+ Hits 870 875 +5
Misses 33 33
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I really like this idea and I think it makes sense, given that the SQLAlchemy relationships (be it a vector or a scalar) always return the |
This really makes sense. Additionally, we should also change Relay's behavior (connectionFields and nodes) to keep everything nice and consistent. Another concern I have is future support of the Here's a snapshot from the https://github.com/apollographql/apollo-server/blob/defer-support/docs/source/defer-support.md#caveats-regarding-defer-usage Will have a more detailed look at that this week! |
I haven't found an elegant approach to the Models that rely on the foreign on the other model still won't benefit from this, as a required foreign key on the joined model doesn't imply anything about the existance of a model to join. So design-wise it's hard to use a general rule for both sides here, and the only solution I see are user-declared ORMFields for each We should discuss if it makes sense to include the to-one relationships in this PR if there is no clearer approach for both sides of the relationship. |
@erikwrede Yeah, the to-many relationship scenario is much more straightforward. I'd be ok punting on that. I haven't dug into it more than I did in the original PR, but what I came up with was unfortunately the most elegant approach I could come up with. :) |
Okay, let's push back the to-one case and focus on to-many relationships here! We're still missing
When that is done, I'll merge it for 3.0 🙂 |
So in that case, should I remove the |
I believe we should make the |
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! Thanks for getting this started 🙂
Thanks! I wasn't sure if there were some other more comprehensive unit tests you wanted, but I added ones to cover the changes. |
The logic behind this change is quite simple and there shouldn't be any complex collisions, so making change the new behavior works and the legacy behavior should suffice in this case. 😊 |
Following on the heels of my first successful PR 😉, I wanted to float another suggestion for your consideration. It seems like it would be closer to ORM semantics if:
user_id
) is non-null, the relationship field should be alsoFor example:
The Schema should be:
This should probably be the default (version 3 maybe?), but in the interests of backward compatibility, we can make it an opt-in feature. This would help my UI team immensely by cleaning up the schema, and not having to deal with unnecessary
null
s all over the place.Obviously more tests and docs would be forthcoming, but I wanted to float the idea first.
cc: @erikwrede @flipbit03