/poc_spring_graphql

Project made in Java to understand to basics of Spring for GraphQl. Also using PostgresQL

Primary LanguageJava

poc_spring_graphql

Description:

This was a small project impleted in JAVA 17 to understand how does Spring for GraphQL works.
To handle the data I used PostgresQL.

How to run it:

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

How to test it:

Once your application has started you can go tolocalhost:8080/graphiql and try the following queries:

Queries:

  1. Get All Books:
       query {
           books {
             ISBN
             title
             publisher
           }
        }
  2. Get Book By Id:
       query {
           booksById(bookISBN: "857904910-5") {
                   title
                   publisher
         }
       }
  3. Get All Authors:
       query {
           authors {
             id
             name
           }
        }
  4. Get Author By Id:
       query {
           authorsById(authorId: 1) {
              name
           }
       }

Mutations:

  1. Add new Book:

        mutation{
            books(newBook: {
                ISBN: "0321349601",
                title: "Java Concurrency in Practice",
                publisher: "Addison-Wesley Professional",
                authorId: 1
            }){
                title
            }
        }
  2. Add new User:

        mutation{
          authors(newAuthor:{
               name: "Joshua Bloch"
             }){
                 id
             }
         }
  3. Delete Book by Id:

        mutation{
            deleteBook(bookISBN: "857904910-5")
        }
  4. 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!