问题描述
即。
context: async ({ ctx }) => {
// console.log(ctx);
ctx.user = await COOKIEAUTH.GetAsync(ctx,AuthRefreshQuery);
return ctx;
},
优势:
缺点:
- 为需要身份验证的属性创建中央身份验证对象
即。
graphql
type AuthSecureMutation {
Settings(input: SettingsArgs!): Settings!
}
type AuthSecureQuery {
Settings: Settings!
}
解析器
const AuthSecureMutation = async (parent,args,context,info) => {
const user = await COOKIEAUTH.GetAsync(context);
if (!user) {
throw new AuthorizationError();
}
// context.user = user; // optional?
return user;
};
const AuthSecureQuery = AuthSecureMutation;
优势
缺点
- @authorize之类的指令将无效
选项2是我想出的,我打算使用它,但是我从未在任何生产示例中看到它。有人知道选项2有什么问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)