创建新的ApolloServer对象时出现预期0个参数但实际得到1个参数的TypeScript错误。根据文档,它应该接受一个参数,尽管代码执行没有错误,但不确定为什么会收到这个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}`);