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
Limit ParentType to only contain fields from the @key and @requires directives #4232
Limit ParentType to only contain fields from the @key and @requires directives #4232
Conversation
I don't intend for this PR to be merged yet, but I do want to open it up for discussion. Since this has a high risk of breaking backward compatibility, I think it'd be best to offer it as an experimental feature for now. What would be the best way to do this? Should I add it as a config option or maybe move this feature to its own plugin altogether? |
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.
One type is too complex to read so we either need to add comments or break it into multiple types.
This sounds like a very nice solution for that. @jakeblaxon can you please fix @kamilkisiela 's suggestions? And do you think we need more test cases for this change? maybe add tests with GraphQL |
@jakeblaxon looks like a great progress :) What are the remaining tasks for this PR? @kamilkisiela can you please take a look again? |
I apologize for the delay on this. I've updated the types to pascal case. The last few remaining tasks I want to add are tests for interface and union types (and any other cases that you suggest) and documentation for how to use the |
Sounds good, thanks @jakeblaxon ! Not sure about the need for a feature flag, because this is actually a bug fix and anyway it's better than what we have now. @kamilkisiela what do you think? |
@dotansimha I think this PR is in a good state so I've opened it up. I added an interface test, but I'm skipping it for now since this PR doesn't support them. However, I think it's better to just get this in now since it works for types and is non-breaking for interfaces. I ended up not adding a test for unions since they don't really make sense in this context. I also didn't add documentation for the |
@dotansimha is there anything preventing us from merging this PR? I noticed this has been open for a while. |
I could really use this fix, too. Would love to see this merged 👍 |
@jakeblaxon No reason. You got @kamilkisiela 's approval so we are good to go :) |
The latest changes of this PR are available as alpha in npm: Quickly update your package.json by running:
|
@jakeblaxon @eurostar-fennec-cooper can you please try the latest alpha? |
@dotansimha 1.17.4-alpha-48e09323.0 works perfectly/resolves the issue for me. |
Great! Thank you for the feedback, @eurostar-fennec-cooper ! |
This PR seeks to address #4089. It modifies the
ParentType
for resolvers of federated types to only contain fields from the@key
and@requires
directives, since these fields are the only ones guaranteed to be available by federation.This is my first PR with this project, so it's a little rough. My goal was to lay a foundation to solve this issue, but certain edge cases may not be fully addressed (such as unwrapped types and type mappings) and may break backwards compatibility. I furthermore only focused on adding this feature to Typescript, so it remains unimplemented in Flow for now. I think it would be best if we make this an experimental feature, but I'm unsure of the best way to do so. Please feel free to make any recommendations/modifications you see necessary. Thanks!