diff --git a/spring-boot-modules/spring-boot-libraries/README.md b/spring-boot-modules/spring-boot-libraries/README.md index b72815e4a9..cc7e511ac8 100644 --- a/spring-boot-modules/spring-boot-libraries/README.md +++ b/spring-boot-modules/spring-boot-libraries/README.md @@ -14,6 +14,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring Boot and Caffeine Cache](https://www.baeldung.com/spring-boot-caffeine-cache) - [Spring Boot and Togglz Aspect](https://www.baeldung.com/spring-togglz) - [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql) +- [Expose GraphQL Field with Different Name](https://www.baeldung.com/expose-graphql-field-with-different-name) - More articles: [[next -->]](/spring-boot-modules/spring-boot-libraries-2) ### GraphQL sample queries diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java index 329d1f469a..d4dff23a29 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java +++ b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java @@ -12,4 +12,9 @@ public class PostResolver implements GraphQLResolver { public Author getAuthor(Post post) { return authorDao.getAuthor(post.getAuthorId()).orElseThrow(RuntimeException::new); } + + public Author getFirst_author(Post post) { + return authorDao.getAuthor(post.getAuthorId()).orElseThrow(RuntimeException::new); + } + } diff --git a/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls b/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls index 0e42f7255c..e426f3508f 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls +++ b/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls @@ -4,6 +4,7 @@ type Post { text: String! category: String author: Author! + first_author: Author! } type Author {