Signup new users in your app using phone number and device ID and receive a token in return.
- Your app calls the Graphcool mutation
signupPhoneUser(phoneNumber: String!, deviceId: String!) - If no user exists yet that corresponds to the passed
phoneNumber, a newUsernode will be created with the deviceId (after being hashed and salted) - If a user with the passed
phoneNumberexists, aUsernode is not created and an error is returned - If a user is created, then the
signupPhoneUser(phoneNumber: String!, deviceId: String!)mutation returns the id for the new user
- Create a new Schema Extension Function and paste the schema from
schema-extension.graphqland code fromsignup.js. - add a PAT to the project called the same as your function. The token can be obtained from the Authentication tab in the project settings.
- Remove all Create permissions for the
Usertype. The function uses a Permanent Access Token to create users via the API so the permissions are not needed.
Go to the Graphcool Playground:
graphcool playgroundRun this mutation to create a user:
mutation {
# replace __PHONE_NUMBER__ and __DEVICE_ID__
signupPhoneUser(phoneNumber: "__PHONE_NUMBER__", deviceId: "__DEVICE_ID__") {
id
}
}You should see that a new user has been created. The returned id can be used to query your Graphcool API for that user. Note that running the mutation again with the same phoneNumber will return an error stating that the phoneNumber is already in use.