apollographql / fullstack-tutorial

🚀 The Apollo platform tutorial app

Home Page:https://www.apollographql.com/docs/tutorial/introduction.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Types mismatch: ApolloServer/ApolloServerBase

kettanaito opened this issue · comments

Following the example of an integration test:

const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => ({ userAPI, launchAPI }),
context,
});

const {query} = createTestClient(server);

Environment

  • apollo-server-express@2.8.1
  • apollo-server-testing@2.9.2
  • typescript@3.5.3

The issue

The output type of new ApolloServer is ApolloServer, while the input type to createTestClient is ApolloServerBase. This makes these functions not compatible.

I'm using TypeScript, therefore I can experience this error.

Expected behavior

a) createTestClient(server: ApolloServer)
b) Change the example of creating a server instance to return expected ApolloServerBase.

apollo-server-testing@2.9.5 fixed

Thank you, @shkolyar! Updating to verify...

I've updated to the apollo-server-testing@2.9.6 and the issue is still there.

Expecting the distributed node module I can see that the function still requires ApolloServerBase, which is incompatible with ApolloServer interface.

// node_modules/apollo-server-testing/src/createTestClient.ts
export default (server: ApolloServerBase): ApolloServerTestClient => {

The same can be found in the generated type definitions in build/createTestClient.d.ts.

What do you think may be the issue here?

commented

I had the same issue with:

"apollo-server-express": "^2.9.9",
"apollo-server-testing": "^2.9.12",

I then downgraded which seems to have resolved the issue:

"apollo-server-express": "^2.9.9",
"apollo-server-testing": "2.9.9",

I just had the same issue. In my case upgrading both apollo-server and apollo-server-testing to 2.9.13 fixed the problem. I think the solution is just to make sure the apollo-server, or apollo-server-express, version is in sync with apollo-server-testing.

I confirm that updating to the following versions of packages fixed the issue for me:

{
  "apollo-server-express": "2.9.13",
  "apollo-server-testing": "2.9.13
}

I had a same issue on apollo-server-koa
Key point is matching versions of packages (apollo-server-[express, koa], apollo-server-testing)

{
  "apollo-server-koa": "2.17.0",
  "apollo-server-testing": "2.17.0",
}