This was a small project impleted in JAVA 17 to understand how does Spring for GraphQL works.
To handle the data I used PostgresQL.
In order to run this project you will need Docker and Java 17 - or higher.
In order to run this project the simpler way would be to make the following:
make run
This way you will start a container running the database and the app. Everything will start automatically.
To stop it, you can simply do the following:
make stop
Once your application has started you can go tolocalhost:8080/graphiql
and try the following queries:
- Get All Books:
query { books { ISBN title publisher } }
- Get Book By Id:
query { booksById(bookISBN: "857904910-5") { title publisher } }
- Get All Authors:
query { authors { id name } }
- Get Author By Id:
query { authorsById(authorId: 1) { name } }
-
Add new Book:
mutation{ books(newBook: { ISBN: "0321349601", title: "Java Concurrency in Practice", publisher: "Addison-Wesley Professional", authorId: 1 }){ title } }
-
Add new User:
mutation{ authors(newAuthor:{ name: "Joshua Bloch" }){ id } }
-
Delete Book by Id:
mutation{ deleteBook(bookISBN: "857904910-5") }
-
Update User Name By Id:
mutation{ updateAuthorName(authorId: 1, updatedAuthor: { name: "John Who" }) { id name } }
These are just some examples to guide you. Feel free to use them as you want and play around with it!