[英]Migrating Apollo Server from v3 to v4 in next.js
In v3 you could write "createHandler" like that:在 v3 中你可以这样写“createHandler”:
export default async (req, res) => {
await startServer;
await apolloServer.createHandler({
path: "/api/graphql",
})(req, res);
};
This is not possible in v4.这在 v4 中是不可能的。 The error is:错误是:
Property 'createHandler' does not exist on type 'ApolloServer<BaseContext>'. “ApolloServer<BaseContext>”类型上不存在属性“createHandler”。
I read the documentation but can't grasp how I could do the equivalent我阅读了文档,但无法理解如何做等效的
I tried using this https://github.com/apollo-server-integrations/apollo-server-integration-next but I don't understand how I would import something when I can't install it through npm. I don't even know if this is the equivalent but it seems like that.我尝试使用这个https://github.com/apollo-server-integrations/apollo-server-integration-next但我不明白当我无法通过 npm 安装它时我将如何导入它。我不甚至知道这是否等价,但似乎是这样。
import { startServerAndCreateNextHandler } from '@as-integrations/next';'
Nevermind me.别管我。 When I tried to install "@as-integrations/next", I somehow typed "apollo-server-integration-next"当我尝试安装“@as-integrations/next”时,我以某种方式输入了“apollo-server-integration-next”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.