Learn-GraphQL icon indicating copy to clipboard operation
Learn-GraphQL copied to clipboard

Starting a server gives Error - TypeError: expressGraphQL is not a function

Open michaelmiscanuk opened this issue 3 years ago • 1 comments

Hi, found a solution for this error when starting a server, so sharing:

I just changed a line when requiring express-graphql to:

const expressGraphQL = require('express-graphql').graphqlHTTP

Now it starts ok.

michaelmiscanuk avatar Nov 24 '21 14:11 michaelmiscanuk

and another simple fix for it would be

// const expressGraphql = require("express-graphql");
const { graphqlHTTP } = require("express-graphql");

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

LucidMach avatar Mar 11 '22 17:03 LucidMach