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

Typescript does not compile with gateway 0.x and Apollo Server v2 #2077

Closed
smyrick opened this issue Aug 17, 2022 · 2 comments
Closed

Typescript does not compile with gateway 0.x and Apollo Server v2 #2077

smyrick opened this issue Aug 17, 2022 · 2 comments

Comments

@smyrick
Copy link
Member

smyrick commented Aug 17, 2022

If you use gateway version 0.29.0+ with Apollo Server v2 you will start relying on apollo-server-types both ^0.9.0 OR ^3.0.0. See code

[email protected] -> AS2
[email protected] -> AS3

"apollo-server-types": "^0.9.0 || ^3.0.0",

Normally in dependencies, this would be ok, that we can use either version, however, the underlying dependency apollo-server-env also has a major version change. We updated the GraphQLRequest.headers to instead defined in apollo-server-env to be the Headers from node-fetch. This was an unintentional "breaking change" that got populated. It appears to have no effect on the runtime of most users but what it does break is Typescript compile steps. So if users have a tsc step they can't even use these versions together.

A potential fix is to instead have npm pull in the dependency of one or the other, we pull in both libs and define in the typed source code that the types themselves could be one or the other.

I believe we should also apply this fix to main if we want @apollo/gateway v2 to still work with AS2.


After this large refactoring, it will require more work to re-apply my initial PR: #2050


Initial PR to solve that now needs to be rewritten: #1964

Reproducible Stackblitz: https://stackblitz.com/edit/apolloserver-2-with-gateway-45?file=README.md

@glasser
Copy link
Member

glasser commented Aug 18, 2022

I think two small fixes will fix this:

  • Backport apollographql/apollo-server@191d427 to AS2 and put out a quick apollo-server-env release
  • Tweak overallCachePolicy in @apollo/server-gateway-interface to explicitly support either AS2 or AS3 versions (which actually simplifies the relevant code in @apollo/gateway)

glasser added a commit to apollographql/apollo-utils that referenced this issue Aug 18, 2022
The consumer of this in `@apollo/gateway` is already doing some weird
stuff with `Omit` around this field, so just explicitly allow the AS2
case.

See apollographql/federation#2077
glasser added a commit to apollographql/apollo-utils that referenced this issue Aug 18, 2022
The consumer of this in `@apollo/gateway` is already doing some weird
stuff with `Omit` around this field, so just explicitly allow the AS2
case.

See apollographql/federation#2077
glasser added a commit to apollographql/apollo-server that referenced this issue Aug 18, 2022
glasser added a commit to apollographql/apollo-server that referenced this issue Aug 18, 2022
glasser added a commit to apollographql/apollo-server that referenced this issue Aug 18, 2022
@smyrick
Copy link
Member Author

smyrick commented Aug 18, 2022

This has now been resolved with the following versions:

"@apollo/gateway": "0.52.1",
"apollo-server": "2.26.0"

OR if you have a hard set dependency on apollo-server-types

"@apollo/gateway": "0.52.1",
"apollo-server": "2.26.0",
"apollo-server-types": "0.10.0"

See the linked issues above for more details.

@smyrick smyrick closed this as completed Aug 18, 2022
trevor-scheer pushed a commit to apollographql/apollo-server that referenced this issue Oct 17, 2022
The consumer of this in `@apollo/gateway` is already doing some weird
stuff with `Omit` around this field, so just explicitly allow the AS2
case.

See apollographql/federation#2077
trevor-scheer pushed a commit to apollographql/apollo-server that referenced this issue Oct 17, 2022
The consumer of this in `@apollo/gateway` is already doing some weird
stuff with `Omit` around this field, so just explicitly allow the AS2
case.

See apollographql/federation#2077
trevor-scheer pushed a commit to apollographql/apollo-server that referenced this issue Oct 19, 2022
The consumer of this in `@apollo/gateway` is already doing some weird
stuff with `Omit` around this field, so just explicitly allow the AS2
case.

See apollographql/federation#2077
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

No branches or pull requests

2 participants