From 130c17a657c58068f787e9bd36e8cdf9536f5b55 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Tue, 16 Nov 2021 10:15:21 +0100 Subject: [PATCH] A few more cleanups - Export `ServiceDefinition` from `@apollo/gateway` since it's use by public methods. - Remove a few more mentions and links to remove `@apollo/federation`. --- DEVELOPMENT.md | 2 +- gateway-js/CHANGELOG.md | 1 + gateway-js/src/index.ts | 2 ++ harmonizer/README.md | 2 +- harmonizer/RELEASING.md | 2 +- harmonizer/src/js_types.rs | 13 ++++++------- harmonizer/src/lib.rs | 6 +++--- package-lock.json | 27 +-------------------------- 8 files changed, 16 insertions(+), 39 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5de5cd2c8..cf5a5b0ea 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -8,7 +8,7 @@ For now, this will be a collection of tips and tricks for the maintainers of the Depending on the size of the release, it may be ideal to have a staging PR which gathers the various features we're intending on releasing into the version. This can be a great way for the community to understand the scope of a release and a clear way for maintainers to publicize it and gather feedback. -> Note: The instructions here cater to a world where the packages in a repository are published in lock-step, as is the case with all of the `apollo-server-*` packages in the Apollo Server repository. Release branches are still a good idea, but in this repository it quite possible that there are multiple versions involved (e.g., a version of `@apollo/federation` and a version of `@apollo/gateway`). In that regard, it's expected that the branch names and the PR title will deviate from the suggestion below. The branch should still be prefixed with `release-` (for _Branch protection rules_ to match easily), but the rest of the branch name might be different, e.g., `release-federation-X.Y.Z`. +> Note: The instructions here cater to a world where the packages in a repository are published in lock-step, as is the case with all of the `apollo-server-*` packages in the Apollo Server repository. Release branches are still a good idea, but in this repository it quite possible that there are multiple versions involved (e.g., a version of `@apollo/subgraph` and a version of `@apollo/gateway`). In that regard, it's expected that the branch names and the PR title will deviate from the suggestion below. The branch should still be prefixed with `release-` (for _Branch protection rules_ to match easily), but the rest of the branch name might be different, e.g., `release-federation-X.Y.Z`. 1. Create a branch off `main` named `release-X.Y.Z`, where `X.Y.Z` is the intended release. 2. Edit the appropriate `CHANGELOG.md` (in the appropriate package directory; e.g. `./gateway-js/CHANGELOG.md`), removing the `vNEXT` section entirely. This section will remain on `main` and be resolved during the merge. diff --git a/gateway-js/CHANGELOG.md b/gateway-js/CHANGELOG.md index 566e72c5d..f72df9687 100644 --- a/gateway-js/CHANGELOG.md +++ b/gateway-js/CHANGELOG.md @@ -5,6 +5,7 @@ > The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the appropriate changes within that release will be moved into the new section. - Conditional schema update based on ifAfterId [PR #1152](https://github.com/apollographql/federation/pull/1152) +- The `@apollo/federation` module is not longer used, and the `ServiceDefinition` interface that may be used when passing using a local "service list" gateway configuration is now exported by this module (`@apollo/gateway`). ## v2.0.0-alpha.1 diff --git a/gateway-js/src/index.ts b/gateway-js/src/index.ts index 239f517d1..4413f866a 100644 --- a/gateway-js/src/index.ts +++ b/gateway-js/src/index.ts @@ -85,6 +85,8 @@ type WarnedStates = { remoteWithLocalConfig?: boolean; }; +export { ServiceDefinition } from '@apollo/federation-internals'; + export function getDefaultFetcher() { const { name, version } = require('../package.json'); return fetcher.defaults({ diff --git a/harmonizer/README.md b/harmonizer/README.md index ab6a6878e..ac01f60e3 100644 --- a/harmonizer/README.md +++ b/harmonizer/README.md @@ -18,7 +18,7 @@ While we intend for a future version of composition to be done natively within Rust, this allows us to provide a more stable transition using an already stable composition implementation while we work toward something else. -[`@apollo/federation`]: https://npm.im/@apollo/federation +[`@apollo/composition`]: https://npm.im/@apollo/composition [IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE [Rollup.js]: http://rollupjs.org/ [`deno_core`]: https://crates.io/crates/deno_core diff --git a/harmonizer/RELEASING.md b/harmonizer/RELEASING.md index de7cab882..40f5d729c 100644 --- a/harmonizer/RELEASING.md +++ b/harmonizer/RELEASING.md @@ -29,6 +29,6 @@ The reason this command is useful is that we're including JavaScript-built sources in this crate. (See the [`README.md`](./README.md) for details.) Therefore, it's critical that `dist/composition.js` and `js/do_compose.js` are included, in addition to `src/**/.rs` and `Cargo.toml` to ensure the package doesn't try to re-compile those sources in the consuming environment (which it will attempt to do with Node.js tooling which we don't want to push the burden of having onto the Rust consumers). - **The `--allow-dirty` flag is required because** Cargo: will not `include` files that are `.gitignore`'d **and** Cargo refuses to publish packages that have untracked files in the working tree. Since `dist/composition.js` is a larger, `rollup`'d bundle of the entire `@apollo/federation` package that is generated during a build (e.g., in CI, eventually), we don't check it into Git. There might be another way to manage the inclusion/exception rules here, or we could just check the file into Git in a CI action, but that would seem to create a lot of unnecessary churn on the repository. + **The `--allow-dirty` flag is required because** Cargo: will not `include` files that are `.gitignore`'d **and** Cargo refuses to publish packages that have untracked files in the working tree. Since `dist/composition.js` is a larger, `rollup`'d bundle of the entire `@apollo/composition` package that is generated during a build (e.g., in CI, eventually), we don't check it into Git. There might be another way to manage the inclusion/exception rules here, or we could just check the file into Git in a CI action, but that would seem to create a lot of unnecessary churn on the repository. 10. Next, also optional, but should be already built if you ran the previous step: `cargo publish --dry-run --allow-dirty` 11. Finally, `cargo publish --allow-dirty`. diff --git a/harmonizer/src/js_types.rs b/harmonizer/src/js_types.rs index e6bad5f65..e766dce09 100644 --- a/harmonizer/src/js_types.rs +++ b/harmonizer/src/js_types.rs @@ -62,14 +62,13 @@ impl Error for CompositionError {} /// Mimicking the JavaScript-world from which this error comes, this represents /// the `extensions` property of a JavaScript [`GraphQLError`] from the /// [`graphql-js`] library. Such errors are created when errors have prevented -/// successful composition, which is accomplished using [`errorWithCode`]. An -/// [example] of this can be seen within the `composition-js` JavaScript library. +/// successful composition, which is accomplished using [`error`] from the `internals-js` module. +/// An [example] of this can be seen within the `composition-js` JavaScript library. /// /// [`graphql-js']: https://npm.im/graphql /// [`GraphQLError`]: https://github.com/graphql/graphql-js/blob/3869211/src/error/GraphQLError.js#L18-L75 -/// TODO: replace with `composition-js` equivalents? -/// [`errorWithCode`]: https://github.com/apollographql/federation/blob/d7ca0bc2/federation-js/src/composition/utils.ts#L200-L216 -/// [example]: https://github.com/apollographql/federation/blob/d7ca0bc2/federation-js/src/composition/validate/postComposition/executableDirectivesInAllServices.ts#L47-L53 +/// [`errorWithCode`]: https://github.com/apollographql/federation/blob/714826efdcc3462c4f91dfe91c7ff8c3c76bad9b/internals-js/src/error.ts#L3-L25 +/// [example]: https://github.com/apollographql/federation/blob/714826efdcc3462c4f91dfe91c7ff8c3c76bad9b/composition-js/src/merging/merge.ts#L448 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub(crate) struct JsCompositionErrorExtensions { /// An Apollo Federation composition error code. @@ -83,7 +82,7 @@ pub(crate) struct JsCompositionErrorExtensions { /// - KEY_NOT_SPECIFIED /// - PROVIDES_FIELDS_MISSING_EXTERNAL /// - /// ...and many more! See the `federation-js` composition library for - /// more details (and search for `errorWithCode`). + /// ...and many more! See the `composition-js` composition library for + /// more details (and search for the `error` method). code: String, } diff --git a/harmonizer/src/lib.rs b/harmonizer/src/lib.rs index fbf8cdede..df1d913f9 100644 --- a/harmonizer/src/lib.rs +++ b/harmonizer/src/lib.rs @@ -2,12 +2,12 @@ # Harmonizer This _harmonizer_ offers the ability to invoke a bundled version of the -JavaScript library, [`@apollo/federation`], which _composes_ multiple subgraphs +JavaScript library, [`@apollo/composition`], which _composes_ multiple subgraphs into a supergraph. The bundled version of the federation library that is included is a JavaScript Immediately Invoked Function Expression ([IIFE]) that is created by running the -[Rollup.js] bundler on the `@apollo/federation` package. +[Rollup.js] bundler on the `@apollo/composition` package. When the [`harmonize`] function that this crate provides is called with a [`ServiceList`] (which is synonymous with the terminology and service list @@ -19,7 +19,7 @@ While we intend for a future version of composition to be done natively within Rust, this allows us to provide a more stable transition using an already stable composition implementation while we work toward something else. -[`@apollo/federation`]: https://npm.im/@apollo/federation +[`@apollo/composition`]: https://npm.im/@apollo/composition [IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE [Rollup.js]: http://rollupjs.org/ [`deno_core`]: https://crates.io/crates/deno_core diff --git a/package-lock.json b/package-lock.json index 96adae284..080474018 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "license": "SEE LICENSE IN ./LICENSE", "dependencies": { "@apollo/composition": "file:composition-js", - "@apollo/federation": "file:federation-js", "@apollo/federation-internals": "file:internals-js", "@apollo/gateway": "file:gateway-js", "@apollo/harmonizer": "file:harmonizer", @@ -169,6 +168,7 @@ "federation-js": { "name": "@apollo/federation", "version": "2.0.0-alpha.1", + "extraneous": true, "license": "SEE LICENSE IN ./LICENSE", "dependencies": { "@apollo/subgraph": "file:../subgraph-js", @@ -190,7 +190,6 @@ "dependencies": { "@apollo/composition": "file:../composition-js", "@apollo/core-schema": "^0.1.0", - "@apollo/federation": "file:../federation-js", "@apollo/query-planner": "file:../query-planner-js", "@opentelemetry/api": "^1.0.1", "@types/node-fetch": "2.5.12", @@ -365,10 +364,6 @@ "graphql": "^14.5.0 || ^15.0.0" } }, - "node_modules/@apollo/federation": { - "resolved": "federation-js", - "link": true - }, "node_modules/@apollo/federation-internals": { "resolved": "internals-js", "link": true @@ -17255,11 +17250,6 @@ "lodash._reinterpolate": "^3.0.0" } }, - "node_modules/lodash.xorby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.xorby/-/lodash.xorby-4.7.0.tgz", - "integrity": "sha1-nBmm+fBjputT3QPBtocXmYAUY9c=" - }, "node_modules/log-ok": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/log-ok/-/log-ok-0.1.1.tgz", @@ -24163,15 +24153,6 @@ "@apollo/query-planner": "file:../query-planner-js" } }, - "@apollo/federation": { - "version": "file:federation-js", - "requires": { - "@apollo/subgraph": "file:../subgraph-js", - "apollo-graphql": "^0.9.3", - "apollo-server-types": "^3.0.2", - "lodash.xorby": "^4.7.0" - } - }, "@apollo/federation-internals": { "version": "file:internals-js", "requires": { @@ -24187,7 +24168,6 @@ "requires": { "@apollo/composition": "file:../composition-js", "@apollo/core-schema": "^0.1.0", - "@apollo/federation": "file:../federation-js", "@apollo/query-planner": "file:../query-planner-js", "@opentelemetry/api": "^1.0.1", "@types/node-fetch": "2.5.12", @@ -38003,11 +37983,6 @@ "lodash._reinterpolate": "^3.0.0" } }, - "lodash.xorby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.xorby/-/lodash.xorby-4.7.0.tgz", - "integrity": "sha1-nBmm+fBjputT3QPBtocXmYAUY9c=" - }, "log-ok": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/log-ok/-/log-ok-0.1.1.tgz",