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

feat: The Federation #6100

Merged
merged 31 commits into from
Feb 14, 2020
Merged

feat: The Federation #6100

merged 31 commits into from
Feb 14, 2020

Conversation

mikemurray
Copy link
Member

@mikemurray mikemurray commented Feb 12, 2020

Resolves #6099
Impact: major
Type: feature

Issue

The Reaction API must be a participant in the (Apollo) federation gateway

Solution

Follow steps as outlined by the Apollo docs to make Reaction a participant, which lead to...

  • Build a federated schema
  • Remove subscriptions (not compatible)
  • Remove schema stitching (not compatible, and federation supersedes it)
  • Fix all double-quotes in block comments and escaped double-quotes in all loaded .graphql files

Breaking changes

  • GraphQL subscriptions will not work. It is not compatible with apollo-server 2.x. It may make a re-appearance in apollo-server 3.0, whenever that's released.

  • Schema stitching has been removed. It is not compatible with federation.

Backwards compatibility over breaking changes

Reaction API will run like it always has with GQL subscriptions and schema stitching enabled by default.

If you want Apollo Federation support, then you will sacrifice the above two features. You'll have to enable federation and disable subscriptions to get the full federation support in the federated gateway.

REACTION_APOLLO_FEDERATION_ENABLED=true
REACTION_GRAPHQL_SUBSCRIPTIONS_ENABLED=false

q: If subscriptions aren't supported by Apollo federation, then why do I need to disable them. Why don't you do it in code?

a: Subscriptions aren't supported yet, but might be supported in [email protected]. Best to leave the flag as a simple yes/no without automatic overrides based on some other variable.

Testing

auth token might not yet be supported for requests through the gateway

  1. Ensure all tests pass, as you do
  2. Start the API like normal and run your favorite queries/mutations
  3. Stop the API and update your env vars like so
REACTION_APOLLO_FEDERATION_ENABLED=true
REACTION_GRAPHQL_SUBSCRIPTIONS_ENABLED=true
  1. See this error when starting up Error: Subscriptions are not supported with Apollo Federation. Set REACTION_GRAPHQL_SUBSCRIPTIONS_ENABLED=false to disable subscriptions.
  2. Update your env vars to this:
REACTION_APOLLO_FEDERATION_ENABLED=true
REACTION_GRAPHQL_SUBSCRIPTIONS_ENABLED=false
  1. The app should start, test your favorite queries and mutation with the gateway.

Subscriptions are not currently compatible with Apollo Server 2.x

Signed-off-by: Mike Murray <[email protected]>
Subscriptions are not currently compatible with Apollo Server 2.x

Signed-off-by: Mike Murray <[email protected]>
Subscriptions are not currently compatible with Apollo Server 2.x

Signed-off-by: Mike Murray <[email protected]>
Subscriptions are not currently compatible with Apollo Server 2.x

Signed-off-by: Mike Murray <[email protected]>
Signed-off-by: Mike Murray <[email protected]>
Signed-off-by: Mike Murray <[email protected]>
@mikemurray mikemurray changed the title feat: The Federation [WIP] feat: The Federation Feb 13, 2020
@mikemurray
Copy link
Member Author

Put back into WIP to see if there are options to make this not a breaking change.

@mikemurray mikemurray changed the title [WIP] feat: The Federation feat: The Federation Feb 13, 2020
@mikemurray mikemurray marked this pull request as ready for review February 13, 2020 21:39
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

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

This works as it's expected to.

API & Gateway work when the correct env vars are set.
API works as expected when no envs are set
API gives you a warning when envs are set incorrectly

One "issue", which is expected here, is that Authenticated queries and mutations do not work through the Gateway. They continue to work through the API directly even when Gateway is enabled, so I see this as OK to merge. @rosshadden thoughts on that?

Copy link
Contributor

@rosshadden rosshadden left a comment

Choose a reason for hiding this comment

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

It's okay to merge. We will have to figure out authorization but it's not a blocker for merging this as it will not affect our existing workflow.

@rosshadden
Copy link
Contributor

I changed the "breaking" in the OP to match latest changes.

@rosshadden rosshadden merged commit 04f6771 into trunk Feb 14, 2020
@rosshadden rosshadden deleted the feat-6099-mikemurray-federation branch February 14, 2020 15:24
@kieckhafer kieckhafer mentioned this pull request Feb 26, 2020
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.

Add Reaction to Federation
3 participants