Search code examples
typescriptgraphqlapollo-server

ApolloServer 4 - Expected 0 Arguments but got 1 - Typescript Error


Getting Expected 0 Arguments but got 1 - Typescript Error while creating new ApolloServer objects. As per the doc it should accept one param, also code execute without error but not sure why getting this warning from typescript.

import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { schema } from "./api/schema";
import ContextValue from "./api/context";

const server = new ApolloServer({
  schema,
});

const { url } = await startStandaloneServer(server, {
  listen: { port: 4000 },
  context: async ({ req }) => new ContextValue({ req, server }),
});

console.log(`🚀  Server ready asst: ${url}`);

Solution

  • I figured out this issue, it was happening due to the version mismatch in the typescript used by vscode vs the project. Check the version used by vscode and try to update it if not matched.

    enter image description here

    Update the vscode version in the setting like below.

    enter image description here