I am experimenting Prisma GraphQL with GraphQL Shield, btw awesome stuff!
Alas I am trying to create a login system using JWT, but I am finding a bottleneck.
This will NOT work
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)
},
...
}
But this DOES
If I change to password, it will work to. (so only one condition on the where)
Mutation: {
login: (_, data: UserWhereUniqueInput, ctx) => {
return ctx.db
.user({ email: ctx.request.body.variables.email })
.then(res => {
console.log(res)
})
.catch(err => err)
},
...
}
why is that?
Another thing is:
if I add query to the ctx.db
like so:
Mutation: {
login: (_, data: UserWhereUniqueInput, ctx) => {
return ctx.db.query
.user({ email: ctx.request.body.variables.email })
.then(res => {
console.log(res)
})
.catch(err => err)
},
...
}
I get
Error: Not Authorised!
Even though I am using the allow on graphQL shield
Mutation: {
login: allow,
},
Query: {
user: allow,
}
Any Ideas? :/
If someone with better knowledge than me could point me to the right direction I would be very grateful