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
Add a comment  | 

1 Answer 1

Reset to default 2

Your 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