缺少升级到apollo server express 2.0.0的上下文

缺少升级到apollo server express 2.0.0的上下文,express,graphql,apollo-server,express-graphql,Express,Graphql,Apollo Server,Express Graphql,在升级之前,我们正在进行 import express from 'express'; import { graphqlExpress, graphiqlExpress } from 'apollo-server-express'; const app = express(); app.use( '/graphql', bodyParser.json(), graphqlExpress(req => ({ schema, tracing: true,

在升级之前,我们正在进行

import express from 'express';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';

const app = express();

app.use(
   '/graphql',
   bodyParser.json(),
   graphqlExpress(req => ({
   schema,
   tracing: true,
   context: { req },
 })),
);

app.use(
 '/graphiql',
 graphiqlExpress({
   endpointURL: '/graphql',
 }),
);
在我们的解析器中,我们可以获得req并设置req.session.token,如下所示

const customResover = {
Query: {
   custom: async (root, args, context) => {
   console.log(' resolver called with args', args);
   const { req } = context;  
   ... fetch token info and set 
   req.session.token = ${token};
   ...
但是随着版本2.0.0的升级,代码更改为以下内容,我不知道如何修复CustomResolver,设置会话令牌,是否知道如何实现上述功能

import express from 'express';
import { ApolloServer, gql } from 'apollo-server-express';
import { typeDefs, resolvers } from './schema/';

const app = express();
const apollo = new ApolloServer({
   typeDefs
   resolvers,
   engine: false
});

apollo.applyMiddleware({
   app,
});

解决了此问题,但出现了Cookie和令牌无法访问浏览器的问题

const apollo = new ApolloServer({
  typeDefs
  resolvers,
  context: ({ req }) => ({ req })
  engine: false
});