I'm working on a GraphQL schema for my Laravel project using the lighthouse library. But I'm running into a problem when trying to validate the user confirmed their password. The issue occurs when I try to register a user. Consider the following type for my user
type User {
id: ID
first_name: String!
last_name: String!
email: String!
password: String!
phone_number: String
avatar: String
email_verified_at: DateTime
}
I try to register my user using the following mutation
extend type Mutation {
createUser(input: CreateUser @spread): User! @create
}
Where my CreateUser input looks like this
input CreateUser {
first_name: String!
last_name: String!
email: String! @rules(apply: ["email"])
password: String! @rules(apply: ["confirmed"])
phone_number: String
}
I get the expected error for my failed validation: "Validation failed for the field [createUser]" so that is fine. But when I try to add a password_confirmation
within my request the following error is encountered: "Field \"password_confirmation\" is not defined by type CreateUser."
. Thats when I thought I should add the password_confirmation
field to the CreateUser input. But when I try that the validation passes but I get a database error that the password_confirmation
is an Undefined column. Which makes sense because it isn't in my migration and I feel this shouldn't be required to be able to validate passwords.
tldr; How can I use the laravel confirmed
validation within the lighthouse @rules directive