I just started learning NestJS and GraphQL. I started with a single resolver class UserResolver defined in UserModule. This class provides methods to read a list of users or a specific user. Methods are decorated with @Query(), a user.graphqlfile is provided, GraphQL is initialized in AppModule, all as described in the docs. All works well, I can get a list of users or specific user through Insomnia Tool or through Playground. I am happy!
Now I have created a second module, RoleModule. I created a role.graphql file and a RoleResolver class, I basically replicated all the work done for User but this time for Role. The GraphQL type definition for type Role as well as the Query definitions in the role.graphql file are recognized. What is not recognized are my Query() implementations in the RoleResolver class, they are not getting invoked.
If I put all these Role related @Query() definitions into the UserResolver class, these Role related queries are now getting invoked.
Is that expected behavior? Do I need to put all my GraphQL query definitions into a single class? Is it possible to spread NestJS-GraphQL resolver implementations over several modules? Am I doing something wrong? Please help.
providersarray? Is the name in the@Query('role')correct? Also make sure that you importQueryfrom@nestjs/graphqland not from@nestjs/common. If this does not help, please include the source code for the role resolver. - Kim Kern@nestjs/common, that was the problem... Sometimes a second pair of eyes are quite helpful! - Andreas