Skip to content

Express handler receiving HTTP response reference #141

Open
@asieraduriz

Description

@asieraduriz

Hello! I just started with my pet project using express and this library to serve my graphql endpoint, and I hit a snag when developing some authentication methods.

It is my understanding that in order to log out, the server should be the one setting the cookies to expire to abstract it from the Frontend, but I wasn't capable of finding that snippet of code in your documentation.

I sort of pieced together what might be helpful and this is what I came up with

import express from "express";
import { schema } from "./schema";
import { createHandler } from "graphql-http/lib/use/express";
const app = express();

app.use("/graphql", (req, res, next) =>
  createHandler({
    schema,
    context: (req) => ({ req, res }),
  })(req, res, next)
);

// Start the server
const PORT = 4000;
app.listen(PORT, () => {
  console.log(`Server is running at http://localhost:${PORT}/graphql`);
});

I would very much appreciate any validation if there's any issue applying such code.
My intention is that for the logout mutation, the resolver can influence the response by setting some headers.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions