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

Error: ApolloServer<BaseContext>' is not assignable to type 'ApolloServer<ExpressContext> #7827

Closed
simpyparveen opened this issue Jan 30, 2024 · 3 comments

Comments

@simpyparveen
Copy link
Contributor

Issue Description

Type 'Promise<{ my_apolloServer: ApolloServer; my_httpServer: Server<typeof IncomingMessage, typeof ServerResponse>; }>' is not assignable to type 'Promise<{ apolloServer: ApolloServer; httpServer: Server<typeof IncomingMessage, typeof ServerResponse>; }>'.
Type '{ my_apolloServer: ApolloServer; my_httpServer: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>; }' is not assignable to type '{ my_apolloServer: ApolloServer; my_httpServer: Server<typeof IncomingMessage, typeof ServerResponse>; }'.
Types of property 'my_apolloServer' are incompatible.
Type 'ApolloServer' is not assignable to type 'ApolloServer'.
Type 'BaseContext' is missing the following properties from type 'ExpressContext': req, rests(2322)
const my_server_instance: Promise<{
my_apolloServer: ApolloServer;
my_httpServer: http.Server;
}>
I wanted to upgrade Apolloserver from ver3 to ver 4. Following documentation:

Two types in apollo-server-express now have more explicit names exported from @apollo/server/express4. GetMiddlewareOptions is now ExpressMiddlewareOptions and ExpressContext is now ExpressContextFunctionArgument. Ref: https://www.apollographql.com/docs/apollo-server/migration/

Link to Reproduction

https://www.apollographql.com/docs/apollo-server/migration/

Reproduction Steps

No response

@trevor-scheer
Copy link
Member

It looks like your types are incompatible based on the error:

Type 'Promise<{ my_apolloServer: ApolloServer; my_httpServer: Server<typeof IncomingMessage, typeof ServerResponse>; }>' is not assignable to type 'Promise<{ apolloServer: ApolloServer; httpServer: Server<typeof IncomingMessage, typeof ServerResponse>; }>'.

The my_ prefix you're using is incompatible. Can you provide a reproduction or a code snippet at the very least?

@trevor-scheer trevor-scheer closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2024
@simpyparveen
Copy link
Contributor Author

simpyparveen commented Jan 31, 2024

@trevor-scheer I added those pre-fixes purposefully when i was posting here, those do not exist in the code.

I have tried to to use the type everywhere, just like a hack to get through this. But I am not happy with it.

I stumbled into a gateway problem, later #7828

Copy link
Contributor

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants