After cloning the repository, install the bundle.
$ bundle install
Migrate and seed the DB.
$ rails db:migrate
$ rails db:seed
Run the Rails server.
$ rails server
GraphiQL is an in-browser GraphQL user interface. Type localhost:3000/graphiql
in your browser to open the Graphiql UI.
To fetch all games, type the following query in the query section of the Graphiql.
Operation
query Games {
games {
id,
title
reviewsCount
platformNames
}
}
To fetch a specific game, the query takes a game id.
Operation
query Game($id: ID!) {
game(id: $id) {
id
title
}
}
Provide the game id in the "variables" section of the Graphiql UI. Variables
{
"id": 1
}
Operation
mutation CreateGame($attributes: GameInput!) {
createGame(input: {
attributes: $attributes
})
{
game {
id,
title,
platformNames
}
errors
}
}
Variables
{
"attributes": {
"title": "XCOM3",
"description": "Lorem ipsum",
"platformIds": [1, 2]
}
}
mutation DeleteGame($id: ID!){
deleteGame(
input: { id: $id }
)
{
game {
title
}
errors
}
}
variables
{
"id": 6
}