Fey all, do you know how to add user details that ...
# prisma-whats-new
t
Fey all, do you know how to add user details that I got from facebook login on graphcool functions?
e
Care to elaborate more?
t
Hey @eruby, Basically Facebook login is working on my system by using graphcool functions. But the problem is normally I have permission to get other info of user (such as email, profile photo, …etc.)
On the graphcool side, I couldn’t find save other info of user to User table. I want to send also email data to Users.
but right now, It just gets Facebook ID because of the CreateUser mutation
e
Ok so I haven't used the social auth before, so I can't speak in detail, but you can definitely add fields to the system generated user schema
Are you doing Facebook login through autho?
Also show me the exact mutation or query you are referring to (what the body of the payload looks like)
In general, you can always specify what is returned from a createuser mutation. By default there's the extra { id } toward the end, which indicates the fields returned. You are able to add in another field freely, such as email, by adding email to the same section. (I'm on my phone so I can't elaborately write snippets)
Copy code
mutation CreateUserMutation(
    # pass in variables
    $name: String!
    $email: String!
    $password: String!
  ) {
    createUser(
      # user variables in the actual mutation as needed
      name: $name
      authProvider: { email: { email: $email, password: $password } }
    ) {
      # specify what you need in the response body
      id
    }
    # perform the sign in after creation, using the same variables (assumes that creation is successful)
    signinUser(email: { email: $email, password: $password }) {
      # this is what is returned from the signinUser mutation
      token
      user {
        id
        # here I could add email to have it be returned to the browser function
      }
    }
  }
This is from the hackernews tutorial and shows the general syntax for making a createUser mutation. This only uses simple auth, but it should be a somewhat similar approach. I've annotated with what I hope are helpful comments to digest what is happening here
n
hey @the_bluescreen, in this example you can see how to obtain the user's email and put it into the new user object: https://github.com/graphcool/modules/blob/master/authentication/facebook/src/facebook-authentication.js#L15
for this you need to add the
email
grant thing as mentioned here: https://github.com/graphcool/modules/tree/master/authentication/facebook#add-the-email-permission this is just one example how you can make it work.