gpt4 book ai didi

curl - GraphQL 突变体解析器

转载 作者:行者123 更新时间:2023-12-03 10:54:25 27 4
gpt4 key购买 nike

刚刚更新到 'graphql-server-express' 版本 1.3.0,现在我在运行任何突变时收到此错误:

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请求中的 header ( docs )

curl 'http://localhost:5050/graphql' \
-H "Content-Type: application/json" \
-H 'authorization: Bearer xxxxxxxxxxx.xxxxxxxxxxx' \
-d '{
"query": "mutation { sensorData(sensorValue: \u0027asdasdasdasd \u0027)}",
"variables": {}
}
}'

关于curl - GraphQL 突变体解析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47861621/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com