Tutorial: How to build a GraphQL server
Jonas Helfer
5.6K58

HI, I got a problem.
As I set up my apollo engine as this article and i run my server.

My editor show this up
`TypeError: Cannot read property ‘middlewareParams’ of undefined`

And here is my code, help plz.

const express = require(‘express’);
const bodyParser = require(‘body-parser’);
const { graphqlExpress, graphiqlExpress } = require(‘apollo-server-express’);
const compression = require(‘compression’);
const { Engine } = require(‘apollo-engine’);
const app = express();
const engine = new Engine({
 engineConfig: {
 apiKey: /* API key*/,
 },
 graphqlPort: process.env.PORT || 3000,
 dumpTraffic: true,
 startupTimeout: 5000,
});
engine.start();
app.use(engine.expressMiddleware); // must be first middleware
const buildOptions = async (req, res) => {
 return {
 schema,
 tracing: true,
 cacheControl: true,
 };
};
app.use(
 ‘/graphql’,
 graphqlExpress(buildOptions),
 bodyParser.urlencoded({ extended: false }),
 bodyParser.json(),
);
app.use(‘/graphiql’, graphiqlExpress({ endpointURL: ‘/graphql’ }));
app.listen(3000, () =>
console.log(
 `GraphiQL is now running on http://localhost:3000/graphiql`
 )
);
module.exports = app;
Like what you read? Give 吳啟碩 a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.