graphql / graphql/graphql-http

Express handler receiving HTTP response reference

Open
#141 3 comments 0 reactions 1 assignee Claimed by @ayushvyas-dev View on GitHub
good first issue question
Dominant language
TypeScript
Stars
363
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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

```typescript
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.