User
Signup
The signup
mutation can be used to register and automatically authenticate a new user. Some unrequired arguments such as user.langISO
and user.address.countryISO
are deduced if not provided based on available IP information.
mutation Signup($user: SignUpInput!) {
signup(user: $user) {
accessToken
refreshToken
user {
firstname
lastname
}
}
}
1
2
3
4
5
6
7
8
9
10
{
"user": {
"firstname": "John",
"lastname": "Doe",
"email": "john.doe@example.com",
"password": "my-password"
}
}
1
2
3
4
5
6
7
8
{
"data": {
"signup": {
"accessToken": "USER_ACCESS_TOKEN",
"refreshToken": "USER_REFRESH_TOKEN",
"user": {
"firstname": "John",
"lastname": "Doe"
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
Signin
The signin
mutation provides multiple methods of authentication as arguments, such as credentials
, refreshToken
, facebookToken
, etc.
mutation Signin($credentials: SignInInput) {
signin(credentials: $credentials) {
accessToken
refreshToken
user {
firstname
lastname
}
}
}
1
2
3
4
5
6
7
8
9
10
{
"credentials": {
"email": "john.doe@example.com",
"password": "my-password"
}
}
1
2
3
4
5
6
{
"data": {
"signup": {
"accessToken": "USER_ACCESS_TOKEN",
"refreshToken": "USER_REFRESH_TOKEN",
"user": {
"firstname": "John",
"lastname": "Doe"
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
The accessToken
from the response can then be set in the HTTP Authorization header to perform authenticated requests :
{
"Authorization": "Bearer USER_ACCESS_TOKEN"
}
1
2
3
Anonymous Session
Some authenticated API paths allow the usage of a temporary session that can be associated to a newly created account in the future (e.g.: Cart
operations).
An Anonymous Session is created by using the signin
mutation without arguments.
mutation Signin {
signin {
accessToken
refreshToken
anonymous
user {
firstname
lastname
}
}
}
1
2
3
4
5
6
7
8
9
10
11
{
"data": {
"signup": {
"accessToken": "ACCESS_TOKEN",
"refreshToken": "REFRESH_TOKEN",
"anonymous": "c8cf2519-1d3c-4812-ab56-12f6062ab731",
"user": null
}
}
}
1
2
3
4
5
6
7
8
9
10
To upgrade the Anonymous Session into a regular user account, the signup
mutation should be called with the HTTP Authorization header containing the accessToken
of the Anonymous Session.
Password Reset
The password reset process is started with the retrievePassword
mutation, which sends an url in an email with a token
.
mutation PasswordReset {
retrievePassword(email: "john.doe@example.com")
}
1
2
3
{
"data": {
"retrievePassword": true
}
}
1
2
3
4
5
When the user navigates to the url, you can retrieve the token
parameter and use it in the updateCredentials
mutation as a validator :
mutation UpdateCredentials {
updateCredentials(
password: {
value: "new password"
validator: {
token: "token_received_in_email"
}
}
) {
password
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"data": {
"updateCredentials": {
"password": true
}
}
}
1
2
3
4
5
6
7