title: GraphQL - POST body missing. Did you forget use body-parser middleware?
body: <p>I keep getting the following error on my <code>graphql</code> queries and not sure why:</p>
  
  <p><code>POST body missing. Did you forget use body-parser middleware?</code></p>
  
  <p>Am I doing something weird here? I have tried different recommendations with body-parser online, but still can't seem to fix it. </p>
  
  <h3>Server:</h3>
  
  <pre><code>require('babel-polyfill')
  
  const express = require('express')
  const router = require('./middleware')
  const expressStaticGzip = require('express-static-gzip')
  const app = express()
  const port = process.env.EXPRESS_PORT || 4000
  const bodyParser = require('body-parser')
  
  app.use(/\/((?!graphql).)*/, bodyParser.urlencoded({ extended: true }))
  app.use(/\/((?!graphql).)*/, bodyParser.json())
  app.use('/search/data', expressStaticGzip('public'))
  app.use('/', router)
  
  app.listen(port, () =&gt; {
    console.log(`Server is running on port ${port}`)
  })
  </code></pre>
  
  <h3>Router</h3>
  
  <pre><code>
  const router = express.Router()
  const server = new ApolloServer({
    typeDefs,
    resolvers,
    context: ({ req }) =&gt; {
      const { authorization = '' } = req.headers
      const universalFetch = (url, opts = {}) =&gt; {
        return fetch(url, {
          ...opts,
          headers: {
            ...opts.headers,
            authorization,
          },
        })
      }
      const request = createRpcClient(universalFetch)
  
      const methods = {}
  
      const catalog = Object.keys(methods).reduce((catalog, method) =&gt; {
        catalog[method] = params =&gt; request(methods[method], params)
        return catalog
      }, {})
      return { catalog, fetch: universalFetch }
    },
  })
  
  router.use(bodyParser.json())
  router.use(bodyParser.text({ type: 'application/graphql' }))
  router.use('*', renderer)
  server.applyMiddleware({ app: router })
  </code></pre>