This project demonstrates a graphql crud application together using smallrye-graphql, panache and hibernate reactive(with ORM). It presents a set of movies together with actors and can be queried and mutated accordingly.
This project uses Quarkus, the Supersonic Subatomic Java Framework.
This project is presented in the following article.
docker run -d --rm --name my_reative_db -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_DB=my_db -p 5432:5432 postgres:10.5
docker rm $(docker ps -a -q) -f
docker volume prune
./mvnw compile quarkus:dev
./mvnw package -Pnative -Dquarkus.native.container-build=true
http://localhost:8080/q/graphql-ui/
query allMovies {
allMovies {
title
releaseDate
director
id
}
}
{
"data": {
"allMovies": [
{
"title": "Reservoir Dogs",
"releaseDate": "1993-02-26",
"director": "Quentin Tarantino",
"id": 1
},
{
"title": "Pulp Fiction",
"releaseDate": "1994-11-25",
"director": "Quentin Tarantino",
"id": 2
},
{
"title": "The Mask",
"releaseDate": "1994-12-25",
"director": "Chuck Russel",
"id": 3
}
]
}
}
query getMovie {
movie(movieId: 1) {
title
director
releaseDate
}
}
{
"data": {
"movie": {
"title": "Reservoir Dogs",
"director": "Quentin Tarantino",
"releaseDate": "1993-02-26"
}
}
}
query allMovies {
movie1: movie(movieId: 1) {
title
releaseDate
director
}
movie2: movie(movieId: 2) {
title
releaseDate
director
}
}
}
{
"data": {
"movie1": {
"title": "Reservoir Dogs",
"releaseDate": "1993-02-26",
"director": "Quentin Tarantino"
},
"movie2": {
"title": "Pulp Fiction",
"releaseDate": "1994-11-25",
"director": "Quentin Tarantino"
}
}
}
query getMovie {
movie(movieId: 1) {
title
director
releaseDate
actors {
name
}
}
}
{
"data": {
"movie": {
"title": "Reservoir Dogs",
"director": "Quentin Tarantino",
"releaseDate": "1993-02-26",
"actors": [
{
"name": "John Travolta"
}
]
}
}
}
query allMovies {
allMovies {
title
releaseDate
director
id
actors {
name
}
}
}
{
"data": {
"allMovies": [
{
"title": "Reservoir Dogs",
"releaseDate": "1993-02-26",
"director": "Quentin Tarantino",
"id": 1,
"actors": [
{
"name": "John Travolta"
}
]
},
{
"title": "Pulp Fiction",
"releaseDate": "1994-11-25",
"director": "Quentin Tarantino",
"id": 2,
"actors": [
{
"name": "Quentin Tarantino"
},
{
"name": "John Travolta"
},
{
"name": "Samuel L Jackson"
}
]
},
{
"title": "The Mask",
"releaseDate": "1994-12-25",
"director": "Chuck Russel",
"id": 3,
"actors": [
{
"name": "Jim Carrey"
}
]
}
]
}
}
mutation addMovie {
createMovie(
movie: {title: "The Mask", releaseDate: "1994-12-25", director: "Chuck Russell"}
) {
title
releaseDate
director
}
}
{
"data": {
"createMovie": {
"title": "The Mask",
"releaseDate": "1994-12-25",
"director": "Chuck Russell"
}
}
}
mutation updateMovie {
updateMovie(
movieId: 1
movie: {title: "The One"}
) {
title
}
}
{
"data": {
"updateMovie": {
"title": "The One"
}
}
}
mutation deleteMovie {
deleteMovie(movieId: 1)
}
{
"data": {
"deleteMovie": true
}
}
query allActors {
allActors {
name
id
}
}
{
"data": {
"allActors": [
{
"name": "Quentin Tarantino",
"id": 1
},
{
"name": "Quentin Tarantino",
"id": 2
},
{
"name": "John Travolta",
"id": 3
},
{
"name": "Samuel L Jackson",
"id": 4
}
]
}
}
query allActors {
allActors {
name
movies {
title
director
}
}
}
{
"data": {
"allActors": [
{
"name": "Quentin Tarantino",
"movies": [
{
"title": "Pulp Fiction",
"director": "Quentin Tarantino"
}
]
},
{
"name": "John Travolta",
"movies": [
{
"title": "Reservoir Dogs",
"director": "Quentin Tarantino"
},
{
"title": "Pulp Fiction",
"director": "Quentin Tarantino"
}
]
},
{
"name": "Samuel L Jackson",
"movies": [
{
"title": "Pulp Fiction",
"director": "Quentin Tarantino"
}
]
},
{
"name": "Jim Carrey",
"movies": [
{
"title": "The Mask",
"director": "Chuck Russel"
}
]
}
]
}
}
mutation addActorToMovie {
addActorToMovie(movieId: 1, actorId: 4) {
title
releaseDate
director
actors {
name
}
}
}
{
"data": {
"addActorToMovie": {
"title": "The One",
"releaseDate": "1993-02-26",
"director": "Quentin Tarantino",
"actors": [
{
"name": "John Travolta"
},
{
"name": "Jim Carrey"
}
]
}
}
}
mutation addMovieToActor {
addMovieToActor(movieId: 2, actorId: 4) {
name
id
movies {
title
actors {
name
}
}
}
}
{
"data": {
"addMovieToActor": {
"name": "Jim Carrey",
"id": 4,
"movies": [
{
"title": "Pulp Fiction",
"actors": [
{
"name": "Quentin Tarantino"
},
{
"name": "John Travolta"
},
{
"name": "Samuel L Jackson"
},
{
"name": "Jim Carrey"
}
]
},
{
"title": "The Mask",
"actors": [
{
"name": "Jim Carrey"
}
]
}
]
}
}
}