对Wiki.js的Graphql API的响应是;“禁止”;
我正在使用as docker容器,并且知道它确实支持Graphql来响应API请求(例如:获取wiki页面内容)。 当我试图查询一个页面的标题时,我会收到一条“禁止”的响应消息 请求:对Wiki.js的Graphql API的响应是;“禁止”;,graphql,wiki.js,Graphql,Wiki.js,我正在使用as docker容器,并且知道它确实支持Graphql来响应API请求(例如:获取wiki页面内容)。 当我试图查询一个页面的标题时,我会收到一条“禁止”的响应消息 请求: query{ pages { single(id: 2 ){ title } } } 答复: { "errors": [ { "message": "Forbidden", "locations": [ {
query{
pages {
single(id: 2 ){
title
}
}
}
答复:
{
"errors": [
{
"message": "Forbidden",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"pages",
"single"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Forbidden",
" at field.resolve (/wiki/server/graph/directives/auth.js:47:17)",
" at field.resolve (/wiki/node_modules/graphql-extensions/dist/index.js:133:26)",
" at resolveFieldValueOrError (/wiki/node_modules/graphql/execution/execute.js:467:18)",
" at resolveField (/wiki/node_modules/graphql/execution/execute.js:434:16)",
" at executeFields (/wiki/node_modules/graphql/execution/execute.js:275:18)",
" at collectAndExecuteSubfields (/wiki/node_modules/graphql/execution/execute.js:713:10)",
" at completeObjectValue (/wiki/node_modules/graphql/execution/execute.js:703:10)",
" at completeValue (/wiki/node_modules/graphql/execution/execute.js:591:12)",
" at /wiki/node_modules/graphql/execution/execute.js:492:16",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
}
],
"data": {
"pages": {
"single": null
}
}
}
有人能告诉我通过wiki.js的GraphQLAPI获取页面标题的错误吗
感谢您的帮助。假设我们正在从Graphql游乐场启动查询 我花了一些时间来理解它,但下面是如何激发需要授权用户权限的graphql查询 您需要确保该请求来自授权用户的服务器,为此激发一个登录请求并为该用户获取一个令牌(jwt)
mutation {
authentication {
login(
username: "username@test.com",
password: "yourpassword",
strategy: "local"
) {
jwt
}
}
}
然后在HTTP头中添加从登录请求中收到的令牌,如
{
"Authorization": "Bearer longStringOfYourJwtToken"
}
希望这能帮助像我这样的新手理解Wiki.js和GraphQL