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

Make possible run loggers and other middleware after graphqlExpress(); #3115

Closed
pks1989 opened this issue Jul 31, 2019 · 2 comments
Closed
Labels
🖇️ express Relates to the Express integration

Comments

@pks1989
Copy link

pks1989 commented Jul 31, 2019

Hello all!

I use graphqlExpress() in my project to send graphQL queries, and its work fine:

...

server.use(
    '/graphql',
    bodyParser.json(),
    graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
    cors(),
    graphqlExpress(async request => ({
      schema,
      context: { headers: request ? request.headers : null },
    })),
  );

...

after some time I want to add the story of queries in my project so I try to do something like this:

...
server.use(
    '/graphql',
    bodyParser.json(),
    graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
    cors(),
    graphqlExpress(async request => ({
      schema,
      context: { headers: request ? request.headers : null },
    })),
    logger((tokens, req, res) => {
      // parse res.body stuff and logging
    })
  );
...

and it's not working, I going to graphqlExpress() code and see that part:

...
 if (typeof res.send === 'function') {
    res.send(graphqlResponse);
  }
...

with no next() after send.

if i add next(), after send() my middleware code works fine:

if (typeof res.send === 'function') {
  res.send(graphqlResponse);
  next();
}

Sorry, if this dumb question, but why reason don't add next() after send() ?

@abernix abernix added the 🖇️ express Relates to the Express integration label Aug 26, 2019
@abernix
Copy link
Member

abernix commented Aug 26, 2019

Are you sure this is still problematic after the landing of #2842 in v2.8.0?

If not this will likely not be fixed until 3.x via #3184.

@glasser
Copy link
Member

glasser commented Oct 20, 2022

This is essentially a duplicate of #5560.

@glasser glasser closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🖇️ express Relates to the Express integration
Projects
None yet
Development

No branches or pull requests

3 participants