Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add session context to graphql api #55

Open
aasmal97 opened this issue Nov 3, 2023 · 0 comments · Fixed by #58
Open

Add session context to graphql api #55

aasmal97 opened this issue Nov 3, 2023 · 0 comments · Fixed by #58
Labels
bug Something isn't working task

Comments

@aasmal97
Copy link
Contributor

aasmal97 commented Nov 3, 2023

Describe the problem

const main = startServerAndCreateNextHandler(server, {
  context: async (req, res) => {
    //for testing only, but when writing custom resolver, call the connect function
    prismaDb.$connect();
    let session: Session | null = null;
    try {
      session = await getServerSession(req, res, options);
    } catch (e) {
      session = null;
    }
    const contextData = {
      req,
      res,
      prisma: prismaDb,
      session
    };
    return contextData;
  },
});
export default main;

Actual behavior

GetServerSession returns errors, or null for session despite user being logged in, and next-crsf-cookie being passes in the frontend

Expected behavior
Read and parse session cookie, and get user session data

To Reproduce
Steps to reproduce the behavior:
1.Make any call to the graphql api with this configuration

Additional Information
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working task
Projects
None yet
1 participant