-
Notifications
You must be signed in to change notification settings - Fork 259
feat(gateway): Remove internal dep on schema
from composition
#278
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trevor-scheer
commented
Nov 11, 2020
federation-js/src/composition/__tests__/composeAndValidate.test.ts
Outdated
Show resolved
Hide resolved
trevor-scheer
commented
Nov 11, 2020
trevor-scheer
commented
Nov 11, 2020
trevor-scheer
commented
Nov 11, 2020
trevor-scheer
commented
Nov 11, 2020
trevor-scheer
commented
Nov 11, 2020
89c7ed9
to
5e77db9
Compare
trevor-scheer
commented
Dec 8, 2020
9ed1d16
to
2d61e3e
Compare
abernix
approved these changes
Dec 17, 2020
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.
There's a package-lock.json
change that seems unexpected, but presuming you back that out or if I'm missing something, and with the addition of a CHANGELOG.md
, then LGTM.
(Squash in the end?)
abernix
reviewed
Dec 21, 2020
abernix
reviewed
Dec 21, 2020
This commit cuts the gateway over to relying solely on the `composedSdl` output from composition. This unlocks the ability for either a user or Apollo Studio to serve the gateway CSDL instead of each SDL file per service. This is fairly straightforward, as `schema` was only depended on in one place by query plan execution, during the final pass of graphql-js `execute()`. Instead, we now construct a `GraphQLSchema` ourselves from the CSDL. This comes with a caveat: the schema we're creating doesn't have all of the annotations that once existed in the schema that we were using from `composeAndValidate()`. However, this is inconsequential for the way the schema is currently being used during the final execution pass.
2d61e3e
to
d2d7878
Compare
d2d7878
to
d8aeb2a
Compare
keys aren't actually provided on the owner when they should be.
schema
from compositionschema
from composition
3 tasks
abernix
added a commit
that referenced
this pull request
Feb 23, 2021
… in Rust. Note: The names and final form of this is subject to change after this lands. None of the changes introduced in this commit are meant to be acted on by users today. This commit: - Introduces a `harmonizer` Rust crate which composes schemas using the existing JavaScript/TypeScript composition function and returns a string representation of the composed schema -- tentatively, known as "CSDL" (composed schema definition language). The name "CSDL" is subject to change. Today, CSDL is already an internal implementation detail which acts as a format that we could pass between the TypeScript runtime and the query planner, which is written in Rust. By providing the mechanism to produce a static CSDL artifact, the gateway can be absolved from the responsibility to create this artifact in an opaque manner at runtime. The ability to pass CSDL into a Gateway as configuration has been possible ever since the landing of #278, though until this commit, there hasn't been a way to produce it. As an implementation detail of the `harmonizer` library, this is accomplished by invoking a [Rollup.js]-bundled [IIFE] of the `@apollo/federation` package, in V8, via the [`deno_core`] V8 bindings. The IIFE JavaScript bundle itself is generated by bundling a (small) stub, native ECMAScript module that depends on `@apollo/federation` and calls its `composeAndValidate` function. The Rollup.js build is invoked via a Rust `build.rs` script ([Build Scripts]). While the intention exists on the team to offer composition and validation written in native Rust, this intermediary is a short-cut that allows us to use the well-tested TypeScript logic that powers Federation today to achieve an immediate "win" without blocking other work while we move toward that future. - Introduces a `harmonizer-cli` that invokes the `harmonize` lib. Again, this will not be the (sole, at least) long-term home for where the production of this artifact will take place. Today, it acts as an easy tool for those interfacing with this project. [Rollup.js]: http://rollupjs.org/ [IIFE]: Instantly Invoked Function Expression [`deno_core`]: https://crates.io/crates/deno_core [Build Scripts]: https://doc.rust-lang.org/cargo/reference/build-scripts.html Co-authored-by: Ashi Krishnan <[email protected]>
abernix
added a commit
that referenced
this pull request
Mar 2, 2021
… in Rust. Note: The names and final form of this is subject to change after this lands. None of the changes introduced in this commit are meant to be acted on by users today. This commit: - Introduces a `harmonizer` Rust crate which composes schemas using the existing JavaScript/TypeScript composition function and returns a string representation of the composed schema -- tentatively, known as "CSDL" (composed schema definition language). The name "CSDL" is subject to change. Today, CSDL is already an internal implementation detail which acts as a format that we could pass between the TypeScript runtime and the query planner, which is written in Rust. By providing the mechanism to produce a static CSDL artifact, the gateway can be absolved from the responsibility to create this artifact in an opaque manner at runtime. The ability to pass CSDL into a Gateway as configuration has been possible ever since the landing of #278, though until this commit, there hasn't been a way to produce it. As an implementation detail of the `harmonizer` library, this is accomplished by invoking a [Rollup.js]-bundled [IIFE] of the `@apollo/federation` package, in V8, via the [`deno_core`] V8 bindings. The IIFE JavaScript bundle itself is generated by bundling a (small) stub, native ECMAScript module that depends on `@apollo/federation` and calls its `composeAndValidate` function. The Rollup.js build is invoked via a Rust `build.rs` script ([Build Scripts]). While the intention exists on the team to offer composition and validation written in native Rust, this intermediary is a short-cut that allows us to use the well-tested TypeScript logic that powers Federation today to achieve an immediate "win" without blocking other work while we move toward that future. - Introduces a `harmonizer-cli` that invokes the `harmonize` lib. Again, this will not be the (sole, at least) long-term home for where the production of this artifact will take place. Today, it acts as an easy tool for those interfacing with this project. - Sets up and installs Node.js and npm - which are required to build and test this Rust implementation - in our Rust GitHub Actions runs. This builds on the work in: #480 [Rollup.js]: http://rollupjs.org/ [IIFE]: Instantly Invoked Function Expression [`deno_core`]: https://crates.io/crates/deno_core [Build Scripts]: https://doc.rust-lang.org/cargo/reference/build-scripts.html Co-authored-by: Ashi Krishnan <[email protected]>
abernix
added a commit
that referenced
this pull request
Mar 5, 2021
… in Rust. Note: The names and final form of this is subject to change after this lands. None of the changes introduced in this commit are meant to be acted on by users today. This commit: - Introduces a `harmonizer` Rust crate which composes schemas using the existing JavaScript/TypeScript composition function and returns a string representation of the composed schema -- tentatively, known as "CSDL" (composed schema definition language). The name "CSDL" is subject to change. Today, CSDL is already an internal implementation detail which acts as a format that we could pass between the TypeScript runtime and the query planner, which is written in Rust. By providing the mechanism to produce a static CSDL artifact, the gateway can be absolved from the responsibility to create this artifact in an opaque manner at runtime. The ability to pass CSDL into a Gateway as configuration has been possible ever since the landing of #278, though until this commit, there hasn't been a way to produce it. As an implementation detail of the `harmonizer` library, this is accomplished by invoking a [Rollup.js]-bundled [IIFE] of the `@apollo/federation` package, in V8, via the [`deno_core`] V8 bindings. The IIFE JavaScript bundle itself is generated by bundling a (small) stub, native ECMAScript module that depends on `@apollo/federation` and calls its `composeAndValidate` function. The Rollup.js build is invoked via a Rust `build.rs` script ([Build Scripts]). While the intention exists on the team to offer composition and validation written in native Rust, this intermediary is a short-cut that allows us to use the well-tested TypeScript logic that powers Federation today to achieve an immediate "win" without blocking other work while we move toward that future. - Introduces a `harmonizer-cli` that invokes the `harmonize` lib. Again, this will not be the (sole, at least) long-term home for where the production of this artifact will take place. Today, it acts as an easy tool for those interfacing with this project. - Sets up and installs Node.js and npm - which are required to build and test this Rust implementation - in our Rust GitHub Actions runs. This builds on the work in: #480 [Rollup.js]: http://rollupjs.org/ [IIFE]: Instantly Invoked Function Expression [`deno_core`]: https://crates.io/crates/deno_core [Build Scripts]: https://doc.rust-lang.org/cargo/reference/build-scripts.html Co-authored-by: Ashi Krishnan <[email protected]>
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In an effort to more fully embrace CSDL within the Apollo ecosystem, this PR expands the Gateway's API to consume CSDL.
Currently, the query planner already depends on CSDL as input. This covers the majority of the Gateway's schema needs. All that remains is an internal dependency on a
GraphQLSchema
coming from composition.It's fairly trivial to generate a
GraphQLSchema
from the CSDL itself, which unlocks the ability to provide CSDL directly to the gateway as input. This means that we can provide CSDL as configuration directly, or in the case of managed federation, host CSDL and significantly simplify the startup process of a managed gateway.This change does introduce the ability to provide CSDL directly to the Gateway, however the remaining bits are strictly changes to internal details. With this change in place, our infra team can ship the work required to host CSDL which we can in turn depend on and simplify our waterfall of fetches and composition.