简体   繁体   中英

Migrating Apollo Server from v3 to v4 in next.js

In v3 you could write "createHandler" like that:

export default async (req, res) => {
  await startServer;

  await apolloServer.createHandler({
    path: "/api/graphql",
  })(req, res);
};

This is not possible in v4. The error is:

Property 'createHandler' does not exist on type 'ApolloServer<BaseContext>'.

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.

import { startServerAndCreateNextHandler } from '@as-integrations/next';'

Nevermind me. When I tried to install "@as-integrations/next", I somehow typed "apollo-server-integration-next"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM