Hello, I am currently using Auth0 for authorization for my react app where I am also using Hasura. I have created this rule that is suppose to insert an auth0 user into a table within my Hasura.
function syncUserToHasura (user, context, callback) {
const query = `
mutation($userId: String!, $email: String, $name: String, $avatar: String) {
insert_organizations(
objects: [{
auth0_id: $userId
email: $email
name: $name
profile_picture: $avatar
}],
on_conflict: {
constraint: organizations_auth0_id_key,
update_columns: [updated_at]
}) {
affected_rows
}
}
`;
const variables = {
userId: user.user_id,
email: user.email,
name: user.name,
avatar: user.picture,
};
const payload = {
headers: {
"content-type": "application/json",
"x-hasura-admin-secret": configuration.ACCESS_KEY
},
url: `Redacted`,
body: JSON.stringify({ query, variables }),
};
request.post(payload, (error, response, body) => callback(error, user, context));
}
When I manually create a user from my Auth0 dashboard, this rule seems to not get triggered. It is only until the user tries to login does it seem to trigger as a new row is added into my table. I am new to this so it is very possible I overlooked something; however, I was wondering if this is possible. If so, what am I missing?