How do I validate already existing users?


Hello, I am using React and auth0. I added this mutation to the callback components and works perfectly

const createUserMutation = gql`
 mutation createUserMutation($idToken: String!){
    createUser(authProvider: {auth0: {idToken: $idToken}}) {

And the create user functions is

_createUser = async () => {
		try {
			const token = this.state.idtoken
			let response = await this.props.createUserMutation({
				variables: {
					idToken : token
		} catch (err) {
			if (err == "Error: GraphQL error: User already exists with that information(…)") {
				console.log("user already exists")

Honestly, this works.
But, is the right way to do it? Is there a better way?

I was thinking about wrapping the component with a user query and checking if that user exists BEFORE performing the mutation.

What do you think?