| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This is a Spring Boot application implementing a GraphQL service to handle requests related to books and authors.
The controller provides four queries:
Follow the steps to start the application:
First, clone the repository:
git clone https://github.com/keploy/samples-javaNavigate to the project folder:
cd samples-java/spring-boot-postgres-graphqlcurl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.shIf you have Docker installed and prefer a PostgreSQL instance in a container, follow these steps:
Build the Docker image:
docker build -t postgres_library:demo ./postgres_demo_dockerRun a container from the generated image:
docker run -d -p 5432:5432 --name postgres postgres_library:demoYour application is ready to be executed!! To start Keploy in record mode, in the root directory, run:
keploy record -c "mvn spring-boot:run"Now, go to localhost:8081/graphiql and access the GraphQL interface to make requests to the application.
Make a getAllBooks query:
query {
getAllBooks {
name
author {
id
firstName
lastName
}
}
}Make a getBookByName query:
query {
getBookByName(name: "The Secret of the Moon") {
id
name
pageCount
author {
firstName
lastName
}
}
}Make a getAllAuthors query:
query {
getAllAuthors {
id
firstName
lastName
}
}Make a getAuthorById query:
query {
getAuthorById(id: 2) {
firstName
}
}You can experiment with the data you want to retrieve from the query by removing or rearranging fields.
The generated tests and mocks are stored in the Keploy directory in the current working directory.
To test the app, start Keploy in test mode. In the root directory, run:
keploy test -c "mvn spring-boot:run" --delay 15This will run the tests and generate the report in the Keploy/reports directory in the current working directory.
| Back | FazBrowse Home | New Git URL |