Skip to content
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

Finish removing old composition code #1208

Merged
merged 4 commits into from
Nov 22, 2021
Merged

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Nov 15, 2021

The core of the old (pre-federation 2.0) composition code has been removed by #1155 but this still left some tangential code that isn't used anymore and should be remove.

This commit remove the whole federation-js/src/composition directory, which "make sense" since the composition code has otherwise moved to a dedicated module (composition-js directory).

I will note that there was some method within the removed files that were exported in practice by federation-js/src/index.ts that this remove and could theoretically have been used by federation users, but I didn't spot any obvious candidate (most of what was exported was more related to the supergraph handling). That said, could be worth a double-check during review.

@pcmanus
Copy link
Contributor Author

pcmanus commented Nov 15, 2021

@trevor-scheer, @martijnwalraven: I'd appreciate if you guys could have a quick look at this to see if you something removed here that might actually be of genuine use for federation users and should not be removed. Thinking of composition-js/src/types.ts and composition-js/src/utils.ts in particular.

@@ -1,8 +1,8 @@
import { buildSubgraphSchema } from '@apollo/subgraph';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is all that's left of the exports, should we just remove the package and stop publishing it? Its 2 purposes (subgraph and composition) are both completely owned by separate packages, seems reasonable to remove this altogether going into v2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is directed at the whole file, not just the one line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable to remove this altogether going into v2

I would agree (and double-checking, it doesn't seem the module is used anymore within federation itself after this PR). I think the only concerns is that many people will still have imports on @apollo/federation for buildSubgraphSchema and so the question is whether we want to maintain compatibility for that. But as fed 2 is a major, I'd personally say it's a good time for that (if anything, stopping to publish the package would be a good sign that people should move to use @apollo/subgraph).

The type I felt was maybe imported by users (and that the PR moves directly into federation-js/src/index.ts for that reason) is the ServiceDefinition interface because it's used for local gateway configs. But it would arguably make more sense that this interface is exported by @apollo/gateway so we could make it so.

@abernix Opinions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with all of the above! v2 seems like exactly the time to remove deprecated bits like this, especially if it means we can stop publishing a package altogether. Also agree with the ServiceDefinition export finding a new home in @apollo/gateway, that sgtm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevor-scheer @pcmanus I support this, but it would be worth opening an issue that ensures that we at some point run npm deprecate <pkg> <msg> on this package. Doing that will start outputting the deprecation warnings during installation of the package by package managers and be a good signal to developers to make the (remarkably straightforward) change to the new package name. We might even want to do this quite soon to get the gears in motion?

It's worth calling out the impact this has on tutorials and education content that we and others have produced — and even printed books! Those things can all be updated, but in my mind the sooner we get the deprecation warning up and the longer we keep it working (perhaps by having @apollo/federation depend on a caret semver range that automatically gets minor/patch updates to @apollo/subgraph for some time?). We may even want to communicate this directly to those that are thinking about developer experience / docs / blogs / etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think deprecating only applies to v2 (which we maybe just shouldn't have ever published given that we're open to killing it). The v0.x gateway continues to use @apollo/federation for its composition capabilities, so I don't think we want to deprecate it (unless we broke out composition as well, which I'm not sure is worth the effort).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see what you're saying. Perhaps what we might consider is then adding a runtime deprecation warning to the use of @apollo/federation for its buildFederatedSchema / buildSubgraphSchema, rather than at the npm level?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to:

  • npm deprecate v2+ versions of @apollo/federation
  • Runtime deprecate buildSubgraphSchema (currently re-exported from @apollo/subgraph)

Currently buildFederatedSchema is already runtime deprecated in @apollo/federation and isn't exported by @apollo/subgraph at all.

@trevor-scheer
Copy link
Member

@pcmanus I finalized the cleanup mostly in the latest commit. Feel free to revert if it's decided that we won't remove it completely for now.

///
/// [`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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed an additional commit that modifies those (that, for completeness sake, ensuring we ship codes will all errors and documenting them is one of the TODO for federation 2 before GA, but "some" of the errors do get code already and I've link to an example of those).

@pcmanus
Copy link
Contributor Author

pcmanus commented Nov 16, 2021

Thanks @trevor-scheer, and this lgtm. I did push a final commit to address the links in js_types.rs you pointed, make sure ServiceDefinition is exported by the gateway now as mentioned above (since after all, it's part of the gateway public API) and remove a few small remaining mentions of federation-js/@apollo/federation.

@trevor-scheer
Copy link
Member

Pinged @abernix to have a look

Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with my most notable comment being #1208 (comment) but one comment below about removing the callout in the docs that might be worth preserving.

Comment on lines 12 to 13
> This method previously existed in the `@apollo/federation` package and was renamed from `buildFederatedSchema` after `@apollo/federation` v0.28.0 (the previous name still works, but it might be removed in a future release).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this here seems like a good thing to maintain for the foreseeable future, particularly since it'll likely be years before everyone actually updates? (We could, however, stop mentioning that it still works.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, probably worth keeping this. Added it back with a minor edit to mention that @apollo/federation is no more.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Sylvain Lebresne and others added 4 commits November 22, 2021 11:41
- Export `ServiceDefinition` from `@apollo/gateway` since it's use by
  public methods.
- Remove a few more mentions and links to remove `@apollo/federation`.
@pcmanus pcmanus force-pushed the finish-removing-old-composition branch from 130c17a to 3d27ce1 Compare November 22, 2021 11:20
@pcmanus pcmanus merged commit cd0a56b into main Nov 22, 2021
@pcmanus pcmanus deleted the finish-removing-old-composition branch November 22, 2021 12:07
@pcmanus
Copy link
Contributor Author

pcmanus commented Nov 22, 2021

Sorry for the slow turnaround. Rebased and committed and created #1228 to follow-up on the npm deprecation of @apollo/federation (at least the version we published for fed 2 alpha).

I will note that rebasing this on main, I run into a small dependency issue with ts-jest and I ended up fixing that in 3d27ce1 (essentially bumping the version slightly, which seemed to require a minor import change). Please feel free to yell at me if I did something wrong in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants