bundle
rails db:migrate
rails db:seed
rails s
Open
localhost:3000/gi
- This will load the GraphiQL in-browser IDE
Here are some sample queries
{
testField(name: "<your_name>")
}
{
author(id: 199) {
id
birth_year
full_name
is_alive
coordinates {
latitude
longitude
}
publication_years
}
}
mutation createAuthor($author:AuthorInputType) {
createAuthor(author:$author) {
full_name
}
}
Query Variables:
{
"author": {
"first_name": "Bill",
"last_name": "Smith",
"birth_year": 1965,
"is_alive": false
}
}
mutation updateAuthor($author:AuthorInputType) {
updateAuthor(id: 7, author: $author) {
id
full_name
}
}
Query Variables:
{
"author": {
"first_name": "John",
"last_name": "Smith",
"birth_year": 1963,
"is_alive": true
}
}
mutation {
deleteAuthor(id:<any_id>) {}
}
- Gives front-end engineers the errors that occur in the back-end
- A validation for last_name presence true can be used in the next example
mutation createAuthor($author:AuthorInputType) {
createAuthor(author:$author) {
full_name
errors
}
}
{
"author": {
"first_name": "<any>",
"birth_year": 1965,
"is_alive": false
}
}
- The password for users is '123456'
{
login(email: "felicita_schulist@kling.com", password: "123456")
}
mutation {logout}
Many thanks to Alex Deva for his Udemy Tutorial on Rails5 and GraphQL.