开发者

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

开发者 https://www.devze.com 2022-12-07 18:05 出处:网络
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.

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

精彩评论

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