Important - Except login
and createUser
mutations, all GraphQL requests need Authorization header. To get the authorization token, run login
mutation.
- Get all users -
query {
user {
id
name
createdTime
posts {
postData
createdTime
}
}
}
- Get all posts -
query {
posts {
id
postData
createdTime
user {
id
name
}
}
}
- Login -
mutation {
login (credentials: {
email: "[email protected]"
password: "P@ssw0rd"
})
{
token
}
}
- Create new user -
mutation {
createUser (userInput: {
name: "Test User"
email: "[email protected]"
password: "P@ssw0rd"
})
{
user {
id
name
createdTime
}
}
}
- Create new post -
mutation {
createPost (postData: {
postData: "Yayyyyy! Hello GraphQL."
userId: "d10cac6672994ba4eb0b08d8db1413c5"
})
{
post {
id
postData
createdTime
user {
name
}
}
}
}