Jon
02/19/2019, 12:06 PM[GraphQL error]: Message: You provided an invalid argument for the where selector on User., Location: , Path: updateUser
Uncaught (in promise) Error: GraphQL error: You provided an invalid argument for the where selector on User.
schema.graphql
...
# import * from './generated/prisma-client/prisma.graphql'
updateUser(email: String, firstName: String, lastName: String, password: String): User!
...
Mutation.js
async updateUser(parent, args, ctx, info) {
// First check if there is a user with that email
const user = await ctx.db.query.user({ where: { email: args.email } });
if (user) {
throw new Error(`The email ${args.email} is already being used`);
}
const updatedUser = await ctx.db.mutation.updateUser({
where: { id: args.id },
data: {
email: args.email,
firstName: args.firstName,
lastName: args.lastName
}
});
return updatedUser;
}
Frontend Mutation:
const UPDATE_USER_MUTATION = gql`
mutation UPDATE_USER_MUTATION(
$email: String!
$firstName: String!
$lastName: String!
) {
updateUser(email: $email, firstName: $firstName, lastName: $lastName) {
id
email
firstName
lastName
}
}
`;
What am I doing wrong here?Jidé
02/19/2019, 12:38 PMJidé
02/19/2019, 12:39 PM