Use resolver classes for queries by default #4513
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After raising #4468 and getting a thumbs-up from @rmosolgo about it, I've finally gotten around to issuing this PR.
I've updated the install generator to generate a base resolver class, and directed readers of the Getting Started guide to use this class when defining fields. Similar changes have been made elsewhere in the documentation as well.
Ultimately, the goal of this change is to alter the way types such as
QueryType
are defined. Currently, the suggestion is:After this change, it will be:
With each of those resolver classes defining the types, arguments and resolution techniques for the fields themselves.
I've intentionally left the definition and structure of those resolvers "loose", as I think it's one of those areas where every developer would have an opinion about The One True Way(tm) to structure these classes.
Where I work, we follow this pattern with some decent success, with those resolver classes typically having resolution methods that pass the GraphQL args down to operations, which then resolve however they need to. The operations themselves are tested in isolation and also with GraphQL request specs. Seems to work for us!