棱镜解析器查询&& GraphQL Shield

时间:2019-07-19 10:09:03

标签: graphql graphql-js prisma

我正在使用GraphQL Shield来测试Prisma GraphQL,顺便说一下!

A,我正在尝试使用JWT创建登录系统,但是我发现了瓶颈。

这将起作用

Mutation: {
    login: (_, data: UserWhereUniqueInput, ctx) => {
      return ctx.db
        .user({ email: ctx.request.body.variables.email, password: ctx.request.body.variables.password })
        .then(res => {
          console.log(res)
        })
        .catch(err => err)
    },

  ...
}

但这确实

如果我更改为密码,它将起作用。 (所以只有一个条件在哪里)

Mutation: {
    login: (_, data: UserWhereUniqueInput, ctx) => {
      return ctx.db
        .user({ email: ctx.request.body.variables.email })
        .then(res => {
          console.log(res)
        })
        .catch(err => err)
    },

  ...
}

那是为什么?

另一件事是:

如果我像这样向ctx.db添加查询:

Mutation: {
    login: (_, data: UserWhereUniqueInput, ctx) => {
      return ctx.db.query
        .user({ email: ctx.request.body.variables.email })
        .then(res => {
          console.log(res)
        })
        .catch(err => err)
    },

  ...
}

我知道

  

错误:未经授权!

即使我在graphQL盾上使用allow

Mutation: {
  login: allow,
},
Query: {
  user: allow,
}

有什么想法吗? :/

如果一个知识水平超过我的人可以指出正确的方向,我将不胜感激

0 个答案:

没有答案
相关问题