I am trying to find the results that match a certain enum, this is my type
:
type User {
id: ID! @id
fname:String!
lname:String!
email:String! @unique
password: String
school_ID: String #@relation(Link: INLINE)
role: [Role] @scalarList(strategy: RELATION)
resetToken: String
resetTokenExpiry: String
}
I can search for email because it has the @unique
key to it, but Role
is an enum and I can't add the @unique
key to it and that makes sense, because the results are not going to be unique.
However I keep getting this message:
"Variable \"$_v0_where\" got invalid value {\"role\":\"TEACHER\"}; Field \"role\" is not defined by type UserWhereUniqueInput."
Using email gives me the result I want if I want to use email to find the items.
What I am after is to get an array return with all the objects matching the selected enum result.
In my schema I have this:
users: [User]!
user(where: UserWhereInput!): User
findUser(role: Role, id: ID, email: String): User
In my query resolvers I have the following that I am playing with:
users: forwardTo('db'),
user: forwardTo('db'),
async findUser(parent, args, ctx, info) {
return ctx.db.query.user({
where: {email: args.email, id: args.id, role: args.role}
}, info)
},
I am using prisma (1.17.1) to generate my schemas
How do I alter my code, or the findUser
function to give me the desired result?