admin管理员组文章数量:1401623
In some Spring Boot projects, I use QueryDSL to filter the results when a request with parameters is sent to the REST controllers. Each request may include different parameters to retrieve a filtered result. By using QueryDSL, I can achieve this. I am not very familiar with GraphQL, which is why I am asking this question: Does GraphQL provide an approach to implementing parameterized queries for retrieving filtered results, similar to QueryDSL?
In some Spring Boot projects, I use QueryDSL to filter the results when a request with parameters is sent to the REST controllers. Each request may include different parameters to retrieve a filtered result. By using QueryDSL, I can achieve this. I am not very familiar with GraphQL, which is why I am asking this question: Does GraphQL provide an approach to implementing parameterized queries for retrieving filtered results, similar to QueryDSL?
Share Improve this question edited Apr 4 at 8:18 Brian Clozel 59.3k15 gold badges179 silver badges181 bronze badges asked Mar 23 at 0:05 kake.38kake.38 316 bronze badges 5- GraphQL uses variables for parameterised operations. Whether this allows filtering results or not depends on the particular API and the schema fields that you're using, but often yes. – Bergi Commented Mar 23 at 0:17
- @Bergi Thank you for your help. So I do not need to do any thing with my JPA repository methods? For example just having a method like findAll() to fetch all the data in my JPA repository and then GraphQL applies filters on the fetched result by using variables ? Is it right? – kake.38 Commented Mar 23 at 1:52
- It's not quite clear what you are talking about. Are you implementing a server with a GraphQL API? Are you using a GraphQL API as a client? Something else? – Bergi Commented Mar 23 at 2:48
- Just like in a REST API, the parameters do not appear automagically, you have to declare and explicitly use them in your methods. – Bergi Commented Mar 23 at 2:49
- Ok. I got it. Thank you so much. – kake.38 Commented Mar 23 at 10:25
1 Answer
Reset to default 2Your question is not very clear.
As you mentioned, for implementing QueryDSL, your repository probably extends QuerydslPredicateExecutor
. Based on the predicates you define, your JPA repository returns the results that match the parameters you send through the requests. Then, GraphQL returns the result to the clients.
本文标签: spring bootParameterized queries using GraphQLStack Overflow
版权声明:本文标题:spring boot - Parameterized queries using GraphQL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744300155a2599542.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论