【发布时间】:2020-11-14 13:16:30
【问题描述】:
我是 Keystone.js 和 GraphQL 的新手。到目前为止,我已经能够通过 POST 请求成功执行以下 API 查询(取自 page):
const SIGNIN = `mutation signin($identity: String, $secret: String) {
authenticate: authenticateUserWithPassword(email: $identity, password: $secret) {
item {
id
name
}
}
}`;
// Returns id and name of authenticated user
和
const GET_ALL_POSTS = `query GetPosts {
allPosts {
name
id
}
}`;
// Returns id and name of all posts (if no access controls)
如果我为列表 Post 设置 access controls,我会按预期从第二个查询中收到访问错误,但我无法工作如何对 allPosts 执行经过身份验证的查询,例如我要:
- (以编程方式)通过用户的电子邮件和密码对用户进行身份验证
- 如果成功,运行
allPosts的查询并返回结果
我做错了什么?
【问题讨论】:
标签: node.js authentication graphql keystonejs