Replies: 1 comment 4 replies
-
You can write your field resolvers inline as a methods of the model class. However, placing queries as the model class methods would be a horrible designs. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
When I was looking to start a new GraphQL project, I almost went for this library paired with TypeORM, because colocation is an important concept to me - writing code that belongs together as close as possible instead of building abstractions in-between. Using (parts of) the same model to describe my GraphQL schema and the underlying database table, as shown directly on the front page of TypeGraphQL, is very powerful. One can immediately see the connection between the two, and it makes it easier to change something without surprises. However, it appears that this logic does not extend to resolvers, which are to be placed in a separate class. This is different from f.e. Nexus, where the resolver of a schema field is colocated in the same object as the field itself, and comes with all the previously mentioned drawbacks attached.
Describe the solution you'd like
Going from the code examples, it would seem very intuitive to be able to write Query/Mutation fields and field resolvers in the same model they belong to, in addition to being able to add unrelated resolvers in a separate file/class as it is being done right now.
Describe alternatives you've considered
I'm not aware of a documented way to do the above
Beta Was this translation helpful? Give feedback.
All reactions