-
Notifications
You must be signed in to change notification settings - Fork 254
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
Updating docs to explain how composition merges types under the hood (union and intersection) #1839
Updating docs to explain how composition merges types under the hood (union and intersection) #1839
Conversation
👷 Deploy request for apollo-federation-docs pending review.Visit the deploys page to approve it
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
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.
Looks good!
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.
Some copyedits, plus a recommendation for the enum section
Co-authored-by: Stephen Barlow <barlow.stephen+git@gmail.com>
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.
Co-authored-by: Stephen Barlow <barlow.stephen+git@gmail.com>
|
||
If a particular GraphQL type is defined _differently_ by different subgraphs, composition uses one of two strategies to merge those definitions: **union** or **intersection**. | ||
|
||
* **Union**: The supergraph schema includes _all_ parts of _all_ subgraph definitions for the type. |
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.
The downside of structuring it this way is that you never really have the opportunity to talk about the "why" of the reason each strategy is employed. In the case of input object types, we use intersection because it allows us to guarantee that no subgraph ever has to deal with input that it didn't expect. In the case of output types, it's safe to compose all the different options together because you don't have the restriction the same way you do with input validation.
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.
So, we do have one sentence in the "Input types and field arguments" section mentioning the logic behind the intersection strategy:
Composition always uses the intersection strategy to merge input types and field arguments. This ensures that the gateway never passes an argument to a subgraph that doesn't define that argument.
Would you like me to add some more emphasis on this point, @clenfest?
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.
If not, @StephenBarlow can you merge this? (I don't have write access)
I can also always add more context to this later if folks need it! :)
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.
@rkoron007 Build is currently failing for unrelated reasons 🤔 I will explore in a bit and we can get this merged!
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.
Running npm run codegen
and checking in the subsequent changed files should fix the build. I don't mind doing that, let me know (didn't want to step on toes if you're already on it).
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.
Oh! I think I've done that previously. Might be best to merge the latest from main
.
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.
Thank you @benweatherman! Did as you suggested, and it looks like everything should be good to go now @StephenBarlow ✨
# [2.0.5] - 2022-06-07 ## 🐛 Fixes - Fix bug with unsatisfiable query branch when handling federation 1 supergraph [PR #1908](#1908). ## 📚 Documentation - Update docs to explain how composition merges types under the hood (union and intersection) [PR #1839](#1839). - Update `@override` docs with multiple usage note [PR #1871](#1871). - Update AWS subgraph compatibility test results [PR #1901](#1901).
Inspired by @clenfest's original PR: #1764
Intended to fix #1763