diff --git a/spring-boot-postgres-graphql/README.md b/spring-boot-postgres-graphql/README.md index 4004af78..ffc12962 100644 --- a/spring-boot-postgres-graphql/README.md +++ b/spring-boot-postgres-graphql/README.md @@ -134,6 +134,22 @@ To test the app, start Keploy in test mode. In the root directory, run: ```bash keploy test -c "mvn spring-boot:run" --delay 15 ``` +### Note on Mutations + +Currently, this GraphQL API supports only query operations for reading data. Mutations for adding or updating books/authors are not yet implemented in the codebase. + +Contributors are welcome to add mutation support in future updates. +### Example Mutation + +You can use the following mutation to add a new book: + +```graphql +mutation { + addBook(name: "New Book", pageCount: 250, authorId: 1) { + id + name + } +} This will run the tests and generate the report in the `Keploy/reports` directory in the current working directory. diff --git a/spring-boot-postgres-graphql/postgres_demo_docker/init.sql b/spring-boot-postgres-graphql/postgres_demo_docker/init.sql index 858d335e..934dbb94 100644 --- a/spring-boot-postgres-graphql/postgres_demo_docker/init.sql +++ b/spring-boot-postgres-graphql/postgres_demo_docker/init.sql @@ -2,7 +2,10 @@ DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'library_demo') THEN - CREATE DATABASE library_demo; + RAISE NOTICE 'Creating database: library_demo'; + CREATE DATABASE library_demo; + ELSE + RAISE NOTICE 'Database library_demo already exists, skipping creation'; END IF; END $$; diff --git a/user-manager/src/main/java/com/example/user/model/User.java b/user-manager/src/main/java/com/example/user/model/User.java index 4fffc845..0afc1bdd 100644 --- a/user-manager/src/main/java/com/example/user/model/User.java +++ b/user-manager/src/main/java/com/example/user/model/User.java @@ -4,6 +4,15 @@ import lombok.ToString; import lombok.experimental.Accessors; import org.springframework.data.annotation.Id; +import jakarta.validation.constraints.*; + +@NotBlank +private String name; + +@Min(0) +@Max(150) +private Integer age; + @Data @ToString @@ -16,4 +25,4 @@ public class User { private Integer age; private String birthday; -} \ No newline at end of file +}