开发者

How can i pass express Request and Response objects into graphql-yoga context using the createYoga function?

I want to pass the express req and res object to my context because i want to use express-sessions to do session-based-auth because the default requests from the context does not know about sessions. Here is what I have tried

app.use("/graphql", (req, res) => {
    return createYoga({
      context: ({ params }) => {
        return {
          req,
          params,
          res,
          prisma,
          redis: redisClient,
        };
      },
开发者_JAVA技巧      graphiql: true,
      landingPage: false,
      cors: false,
      schema,
    });
});

But if i try this it seems like the request is not going through.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜