Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Middleware hangs when using getGraphQLParams function #745

Open
mimo84 opened this issue Mar 18, 2021 · 5 comments
Open

Middleware hangs when using getGraphQLParams function #745

mimo84 opened this issue Mar 18, 2021 · 5 comments

Comments

@mimo84
Copy link

mimo84 commented Mar 18, 2021

When using the getGraphQLParams function inside a middleware function, the response hangs.
I've created a simple repo with the minimum required to replicate the issue here: https://github.com/mimo84/getGraphQLParamsBug

The code:

const express = require('express');
const graphql = require('express-graphql');
const {
  GraphQLObjectType,
  GraphQLSchema,
  GraphQLString,
} = require('graphql');

const app = express();

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      oneField: {
        type: GraphQLString,
        resolve(parent, args) {
          return 'oneField value';
        },
      },
    },
  })
});


app.use(async (req, res, next) => {
  // just comment out this line to see the request being successful
  const params = await graphql.getGraphQLParams(req);
  console.log(params);
  next();
});

app.use(
  '/graphql',
  graphql.graphqlHTTP({
    schema,
    graphiql: true,
  })
);


app.listen(1234, () => {
  console.log(`http://localhost:1234/graphql`);
});

Node Version: 15.6.0
OS: MacOS 11.2.1

@acao
Copy link
Member

acao commented Apr 4, 2021

Do you have time to open a pull request to addres this?

@mimo84
Copy link
Author

mimo84 commented Apr 21, 2021

I tried an attempt to fix it and I've created a branch with the test, however it seems that I cannot reproduce the bug in the test. Do you think I am missing something?

main...mimo84:middleware-hang

@kag359six
Copy link

kag359six commented Jul 3, 2021

Is there a solution to this issue? I'm facing the same problem in a similar situation using middleware @mimo84

@squamos
Copy link

squamos commented Aug 17, 2022

I'm also having the same problem. Curious if anyone has found a good workaround for parsing graphql params?

@enisdenjo
Copy link
Member

This library has been deprecated and this repo will be archived soon. It has been superseded by graphql-http.

Furthermore, if you seek a fully-featured, well-maintained and performant server - I heavily recommend GraphQL Yoga!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants