Just updated to 'graphql-server-express' version 1.3.0 and now I am getting this error when running any mutations:
POST body missing. Did you forget use body-parser middleware?
When initializing the server, I am including the "body-parser" package so I am not sure what is going on here. Any ideas?
Server Config:
//GraphQL Server
graphQLServer.use(
//GRAPHQL Endpoint
`/${settings.public.graphql.endpoint}`,
//Parse JSON
bodyParser.json(),
//authenticate
authenticateRequest,
//GRAPHQL Server
graphqlExpress(req => {
return {
schema: schema,
context: req
}
})
);
Example Request:
curl 'http://localhost:5050/graphql' \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'
Set Content-Type: application/json
header in the request (docs)
curl 'http://localhost:5050/graphql' \
-H "Content-Type: application/json" \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With