在创建新的 ApolloServer 对象时得到预期的 0 个参数但得到 1 个 - 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}`);