Expose GraphQL field with different name (#12289)

This commit is contained in:
Muhammad Abdullah Azam Khan 2022-06-01 01:35:54 +04:00 committed by GitHub
parent 97b2c4d6ea
commit aef4affc28
3 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -12,4 +12,9 @@ public class PostResolver implements GraphQLResolver<Post> {
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);
}
}

View File

@ -4,6 +4,7 @@ type Post {
text: String!
category: String
author: Author!
first_author: Author!
}
type Author {