-
Notifications
You must be signed in to change notification settings - Fork 2
GraphQL
Kersul edited this page Sep 6, 2017
·
5 revisions
This example will create a user and returns the fields id and password.
mutation {
createUser(user: {
name: "Kersul",
email: "kersul@kersul.com",
password: "1234",
birthday: "1990-02-01T10:00:00.000Z"
}) {
id,
password,
}
}
Example of return:
{
"data": {
"createUser": {
"id": "59b03e568ce6e41d50459410",
"password": "$2a$10$mmUyPGv1DJtgLpwG7DULu.tgz0srAxOtrUd3b.fEul9WhG1qTrcce"
}
}
}
The example below, will get id and name from all users:
{
users {
id,
name
}
}
Example of return:
{
"data": {
"users": [
{
"id": "59b03e568ce6e41d50459410",
"name": "Kersul"
},
{
"id": "59b03f158ce6e41d50459411",
"name": "John"
},
{
"id": "59b03f198ce6e41d50459412",
"name": "Rich"
}
]
}
}
The example below, will delete user from the given id:
mutation {
deleteUser(id: "59b03f198ce6e41d50459412") {
id
}
}
Example of return:
{
"data": {
"deleteUser": {
"id": "59b03f198ce6e41d50459412"
}
}
}
The example below we are getting a token for a user:
mutation {
authUser(auth: {
email: "kersul@kersul.com",
password: "1234"
}){
token
}
}
Example of return:
{
"data": {
"authUser": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjU5YjAzZTU2OGNlNmU0MWQ1MDQ1OTQxMCIsImVtYWlsIjoia2Vyc3VsQGtlcnN1bC5jb20iLCJjcmVhdGVkQXQiOiIyMDE3LTA5LTA2VDIwOjIwOjE4LjYyN1oiLCJpYXQiOjE1MDQ3MjkyMTh9.X_95Rswd56hXKQiCx0rVpL1qCso45QX_WibSUsXz68s"
}
}
}