1
剛剛更新爲「graphql服務器-Express的1.3.0版本和運行任何突變時,現在我收到此錯誤:GraphQL突變體分析器
POST body missing. Did you forget use body-parser middleware?
當初始化服務器,我在內的」 body-parser「包,所以我不確定這裏發生了什麼。有任何想法嗎?
服務器配置:
//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
}
})
);
示例請求:
curl 'http://localhost:5050/graphql' \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'
謝謝祝福設置
Content-Type: application/json
頭球攻門!添加Content-Type爲我工作。欣賞您的意見:) – matt不客氣,不受歡迎。很高興提供幫助,如果此答案解決了您的問題,請通過單擊答案旁邊的複選標記將其標記爲已接受。請參閱:[如何接受答案的工作?](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)瞭解更多信息 – Bless