我使用lacinia-pedestal作为服务器,使用re用于客户端clojuresript
我的客户端代码看起来像这样
(re-frame/dispatch [::re-graph/init {:http-url
"http://localhost:8888/graphql"
:ws-url nil
:http-parameters {:headers {"Content-Type" "application/graphql"}
}}])
(re-frame/dispatch [::re-graph/query
"{current_user(token: ss) {id}}"
nil some-func])
但是,当我连接到我的服务器时,我在控制台日志中看到以下错误
"message":"Failed to parse GraphQL query.","extensions":{"errors":[{"locations":[{"line":1,"column":null}],"message":"mismatched input '\"query\"' expecting {'query', 'mutation', 'subscription', '...', NameId}"}
在curl请求之后,它可以工作,
curl http://localhost:8888/graphql
-H 'Content-Type: application/graphql'
-d 'query {
current_user(token: "foo"){
id
}}'
任何帮助我们都将不胜感激。
我附上了我的网络控制台日志
发布于 2019-03-03 23:15:23
默认情况下,re-graph使用application/json将查询和变量作为JSON负载发送。您不需要覆盖init调用中的content-type。
https://stackoverflow.com/questions/54945062
复制相似问题