-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(gateway): New federation composition format #4405
Conversation
fa4f22f
to
3ac7406
Compare
This work is separated out from #4405, and is important to unblock progress on the new composition format. This upgrade could've happened at any time. Now that composition is being updated to a fork of the latest graphql schema printer, v15 is now a requirement. This comes with a few test updates, mostly around the sorting of AST nodes (i.e. in the query plan).
This work is separated out from #4405, and is important to unblock progress on the new composition format. This upgrade could've happened at any time. Now that composition is being updated to a fork of the latest graphql schema printer, v15 is now a requirement. This comes with a few test updates, mostly around the sorting of AST nodes (i.e. in the query plan).
2be570a
to
37aca46
Compare
0e1c6d1
to
c085470
Compare
This commit introduces a fresh copy of graphql-js schema printer. Copying it here as the first commit gives us a good diffing point for review.
c085470
to
d998e06
Compare
@@ -1,87 +1,119 @@ | |||
/* |
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.
Reviewer: this entire file change is a copy/paste of newPrintFederatedSchema.ts
from previous commits. Nothing from this file change is new code - this is the drop-in update for the schema printer.
61a2c39
to
71f5b58
Compare
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.
😍 Wow, what an incredible PR! This is super exciting, and very well organized / easy to review. The annotations explaining the federated adjustments are super useful for posterity, too.
(Glad we've brought in updated, upstream printer bits too!)
Two bits:
- I believe that
newPrintFederatedSchema.ts
is equal toprintComposedSdl.ts
by the end of this. I don't seenewPrintFederatedSchema.ts
beingrequire
'd /import
'd anywhere; is there meant to be one final commit that removesnewPrintFederatedSchema.ts
? - I had one naming thought I mentioned in Directives for SDL representation of composed schema federation#61 (comment) that might be worth tweaking (easy, rename) that I'd be curious in getting your thoughts on.
Copy over the now validated `newPrintFederatedSchema.ts` contents into the former `printFederatedSchema.ts` as an "under-the-hood" swap.
This forks from the newly updated schema printer. However, the goal of this printer is to print the FINAL composition, rather than the schema for a single federated service. By peeking at the existing annotations in the `extensions` on the composed `GraphQLSchema`, the composition printer can gather important metadata like type and field ownership which is then annotated in the final SDL.
71f5b58
to
0784ff7
Compare
…o-server#4405) The output of composition as it stands is not a portable one. In its current form, the output of composition is an executable GraphQLSchema object whose types and fields are annotated via the extensions field. This is problematic for the future of composition at Apollo - as we move query planning to Rust, moving away from this JS native object and towards a portable format (SDL) is ideal, and also allows us to: * parse and consume this format more easily with tooling * create / consume this format in any language which can parse valid GraphQL * standardize the format for other implementors All of that being said, this commit creates an additional output to composition - the printed SDL of the new composition format. We're calling this CSDL C(omposed)SDL to distinguish that this SDL ought to include all of the annotations / metadata necessary about the composed graph in order to perform query planning and execution. Apollo-Orig-Commit-AS: apollographql/apollo-server@1c58ea3
Design / ref: apollographql/federation#61
Note: this PR is intended to be reviewed by commit. The steps taken to first update the
existing fork and then continue with the new implementation should be fairly clear.
The format of composition as it stands is not a portable one. In its current form,
the result of composition is an executable
GraphQLSchema
object whose types and fieldsare annotated via the
extensions
field.This is problematic for the future of composition at Apollo - as we move query planning to
Rust, moving away from this JS native object and towards a portable format (SDL) is ideal,
and also allows us to:
I imagine there's some overlap in my bullets but the points still hold for us.
All of that being said, this PR creates an additional output to composition - the printed
SDL of the new composition format. We're calling this CSDL C(omposed)SDL to distinguish
that this SDL ought to include all of the annotations / metadata necessary about the
composed graph in order to perform query planning and execution.
I included updating our existing fork of
graphql-js
printSchema
as part of the worksince it fit nicely into my iterative transition while building the new printer. As a
side effect, this PR also resolves an outstanding issue related to printing block descriptions
which include double quote characters. This issue made such a schema unparseable. cc @watson
Fixes #4400
Fixes #4339
Fixes #3864