mat*_*att 3 post curl graphql express-graphql
刚刚更新为“ graphql-server-express”版本1.3.0,现在在运行任何突变时出现此错误:
POST body missing. Did you forget use body-parser middleware?
Run Code Online (Sandbox Code Playgroud)
初始化服务器时,我包括“ 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
}
})
);
Run Code Online (Sandbox Code Playgroud)
请求示例:
curl 'http://localhost:5050/graphql' \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'
Run Code Online (Sandbox Code Playgroud)
Content-Type: application/json
在请求中设置标头(docs)
curl 'http://localhost:5050/graphql' \
-H "Content-Type: application/json" \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3456 次 |
最近记录: |