Replies: 1 comment
-
I think that the Apollo docs state really clearly what a resolver is:
GraphQL is all about types and fields. The way that you get data for complex type or computed fields is through resolvers. "Controllers" are used in Spring to designate beans/components that have methods that are meant to intercept/handle incoming requests. In the past, you'd see Controllers created for MVC applications, but nowadays, you more often see them created to encapsulate the handling of REST endpoints that are directly related to one another or just the different HTTP methods of the same REST endpoint. In the official Spring GraphQL library, they've chosen to use the Controller annotation to designate classes which contain individual field resolvers (which are implemented as methods). I personally think this is a bad way to go. I feel it is misleading as to what the class is actually for. IMO, They should've opted for a "Resolver" annotation to make things more clear. It would have made it so that you wouldn't need annotations on every field resolver method in the controller class too. But it is what it is. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm new to spring boot and graphql so my question might be dump but I didn't see any answer on internet so i'm asking it here.
What's the difference between the graphql resolvers and the sring boot Controller ?
Most of the tutorials I see on google and youtube are using these specific ways (some are also using services but it seems less popular) of mapping a query to an execution that will retrieve data from a repository.
I can't find are the differences, do they have the same purpose or maybe I am misunderdanting something ? What is the best way to make that schema mapping between query and execution ?
I would be glad to have your thoughts about this, if my question isn't clear, tell me how i can explain it better.
Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions