Created
September 4, 2019 10:14
-
-
Save shark-h/02a1d1a06d28c24a20c9488fea654062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SYNC WITH HASURA ON USER CREATE | |
exports.processSignUp = functions.auth.user().onCreate(async user => { | |
const id = user.uid; | |
const email = user.email; | |
const name = user.displayName || "No Name"; | |
const mutation = `mutation($id: String!, $email: String, $name: String) { | |
insert_users(objects: [{ | |
id: $id, | |
email: $email, | |
name: $name, | |
}]) { | |
affected_rows | |
} | |
}`; | |
try { | |
const data = await client.request(mutation, { | |
id: id, | |
email: email, | |
name: name | |
}) | |
return data; | |
} catch (e) { | |
throw new functions.https.HttpsError('sync-failed'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment