This function isn't working properly
function getRolesOfUser(parent, args, context, info) {
return context.prisma.userHasRoles({user:args.user});
}
I have tried changing the paremeter in the query
{where: {user:user}}
{['User.id']:args.user}
This is the schema
type Query {
getRolesOfUser(user: String): [UserHasRole]
}
type User {
id: ID!
email: String!
roles: [UserHasRole]
}
type Role {
id: ID!
name: String!
}
type UserHasRole {
id: ID!
role: Role!
user: User!
}
Error message:
Could not find argument user for type UserHasRole",
Expected to receive the list of roles related to a certain user
Please consider using the following code
function getRolesOfUser(parent, args, context, info) {
return context.prisma.userHasRoles({ where: { user: { id: args.user.id } } })
}
In your schema, user
is a field of UserHasRole
. First select the user
that meets the condition by user.id
, and then filter out the UserHasRole
containing user
by user
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.