-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix/explicit requires with mutli entity resolver #3744
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/explicit requires with mutli entity resolver #3744
Conversation
Thanks for working on this! |
I decided to limit these changes to explicit requires. Computed requires will need a similar fix from what I can tell, but I am less familiar with it. @clayne11 - tagging you as you seem to have introduced the computed_requires changes. From what I can tell, those changes will also fail generation when |
size: Int! @requires(fields: "world{ foo }") | ||
sizes: [Int!] @requires(fields: "worlds{ foo }") |
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.
This would have failed generation in previous versions.
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.
@clayne11 this is the bug I was referencing. It will fail generation for both options, explicit and computed when mutli is enabled.
I think I addressed both issues in this PR, the computed fix was incredibly simple.
As far as I know, My opinion is that |
@clayne11 If you take a look at the old code it was still generating explicit mapping unlike resolveEntity which was skipping it. Also generation would fail on the bug I have listed in the PR using computed_requires also. I just pushed up a fix I would love for you to take a look? |
}), | ||
&resp, | ||
client.Var("representations", representations), | ||
) | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, "first name - 1", resp.Entities[0].Name) | ||
require.Equal(t, "key1 - 1", resp.Entities[0].Key1) |
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.
Computed requires should not populate external entity fields like this as far as I know, as they are now passed into the resolver. This would fail if not for Multi true, which still has the explicit mapping in its path.
I really appreciate your engaging with this. There haven't been enough folks carefully going over federation recently and the more eyes on this the better. I'm going to merge this as is for now, but I would love for further follow-up PRs. |
@parkerroan I tried to connect with you on https://www.linkedin.com/in/steve-coffman-79322175/ because it might be easier to talk over a few things in a quick chat, if you are up for that. |
This is a PR addressing this issue: #3742
These changes ensure that
explicit_requires
is respected and used even when@entityResolver(multi: true)
.Prior to this schema generation would fail if you required fields from an field of type [object]. Also the Populate functions for
explicit_requires
would not be respected when@entityResolver(multi: true)
.Example of failed generation schema:
I have: