Skip to content

Commit

Permalink
A few more cleanups
Browse files Browse the repository at this point in the history
- Export `ServiceDefinition` from `@apollo/gateway` since it's use by
  public methods.
- Remove a few more mentions and links to remove `@apollo/federation`.
  • Loading branch information
Sylvain Lebresne committed Nov 16, 2021
1 parent a6aec74 commit 130c17a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 39 deletions.
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions gateway-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions gateway-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion harmonizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion harmonizer/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
13 changes: 6 additions & 7 deletions harmonizer/src/js_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}
6 changes: 3 additions & 3 deletions harmonizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 1 addition & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 130c17a

Please sign in to comment.