{"action":"created","issue":{"url":"https://api.github.com/repos/nestjs/nest/issues/598","repository_url":"https://api.github.com/repos/nestjs/nest","labels_url":"https://api.github.com/repos/nestjs/nest/issues/598/labels{/name}","comments_url":"https://api.github.com/repos/nestjs/nest/issues/598/comments","events_url":"https://api.github.com/repos/nestjs/nest/issues/598/events","html_url":"https://github.com/nestjs/nest/issues/598","id":317222192,"number":598,"title":"Nest cant resolve dependency when he actually can","user":{"login":"ToKaTpoHb","id":11059471,"avatar_url":"https://avatars0.githubusercontent.com/u/11059471?v=4","gravatar_id":"","url":"https://api.github.com/users/ToKaTpoHb","html_url":"https://github.com/ToKaTpoHb","followers_url":"https://api.github.com/users/ToKaTpoHb/followers","following_url":"https://api.github.com/users/ToKaTpoHb/following{/other_user}","gists_url":"https://api.github.com/users/ToKaTpoHb/gists{/gist_id}","starred_url":"https://api.github.com/users/ToKaTpoHb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ToKaTpoHb/subscriptions","organizations_url":"https://api.github.com/users/ToKaTpoHb/orgs","repos_url":"https://api.github.com/users/ToKaTpoHb/repos","events_url":"https://api.github.com/users/ToKaTpoHb/events{/privacy}","received_events_url":"https://api.github.com/users/ToKaTpoHb/received_events","type":"User","site_admin":false},"labels":[{"id":913466692,"url":"https://api.github.com/repos/nestjs/nest/labels/type:%20potential%20issue%20%F0%9F%92%94","name":"type: potential issue 💔","color":"f9d0c4","default":false},{"id":532263513,"url":"https://api.github.com/repos/nestjs/nest/labels/type:%20question%20%F0%9F%99%8C","name":"type: question 🙌","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":{"login":"kamilmysliwiec","id":23244943,"avatar_url":"https://avatars0.githubusercontent.com/u/23244943?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilmysliwiec","html_url":"https://github.com/kamilmysliwiec","followers_url":"https://api.github.com/users/kamilmysliwiec/followers","following_url":"https://api.github.com/users/kamilmysliwiec/following{/other_user}","gists_url":"https://api.github.com/users/kamilmysliwiec/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilmysliwiec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilmysliwiec/subscriptions","organizations_url":"https://api.github.com/users/kamilmysliwiec/orgs","repos_url":"https://api.github.com/users/kamilmysliwiec/repos","events_url":"https://api.github.com/users/kamilmysliwiec/events{/privacy}","received_events_url":"https://api.github.com/users/kamilmysliwiec/received_events","type":"User","site_admin":false},"assignees":[{"login":"kamilmysliwiec","id":23244943,"avatar_url":"https://avatars0.githubusercontent.com/u/23244943?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilmysliwiec","html_url":"https://github.com/kamilmysliwiec","followers_url":"https://api.github.com/users/kamilmysliwiec/followers","following_url":"https://api.github.com/users/kamilmysliwiec/following{/other_user}","gists_url":"https://api.github.com/users/kamilmysliwiec/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilmysliwiec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilmysliwiec/subscriptions","organizations_url":"https://api.github.com/users/kamilmysliwiec/orgs","repos_url":"https://api.github.com/users/kamilmysliwiec/repos","events_url":"https://api.github.com/users/kamilmysliwiec/events{/privacy}","received_events_url":"https://api.github.com/users/kamilmysliwiec/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2018-04-24T13:19:33Z","updated_at":"2018-04-27T08:59:12Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n<!-- \r\nPlease search GitHub for a similar issue or PR before submitting.\r\nCheck one of the following options with \"x\" -->\r\n<pre><code>\r\n[ ] Regression <!--(a behavior that used to work and stopped working in a new release)-->\r\n[X ] Bug report\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.\r\n</code></pre>\r\n\r\n## Current behavior\r\n<!-- Describe how the issue manifests. -->\r\nI'm getting following error\r\n```\r\nError: Nest can't resolve dependencies of the AuthGuard (?). Please verify whether [0] argument is available in the current context.\r\n    at Injector.<anonymous> (/home/tymur/learning/nest/mino-crm/node_modules/@nestjs/core/injector/injector.js:160:23)\r\n    at Generator.next (<anonymous>)\r\n    at fulfilled (/home/tymur/learning/nest/mino-crm/node_modules/@nestjs/core/injector/injector.js:4:58)\r\n    at <anonymous>\r\n    at process._tickCallback (internal/process/next_tick.js:182:7)\r\n 1: node::Abort() [node]\r\n 2: 0x8d04d9 [node]\r\n 3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]\r\n 4: 0xb17d2c [node]\r\n 5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]\r\n 6: 0x343a137042fd\r\nAborted (core dumped)\r\n```\r\n## Expected behavior\r\n<!-- Describe what the desired behavior would be. -->\r\nNo errors, app launching.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n<!-- Please share a repo, a gist, or step-by-step instructions. -->\r\nI've followed guide on how to setup GraphQL in nest. I have two modules: users and auth. both are linked with forwardRef:\r\nauth module:\r\n```\r\n@Module({\r\n  imports: [\r\n    forwardRef(() => UsersModule),\r\n  ],\r\n  components: [\r\n    JwtAuthStrategy,\r\n    AuthService,\r\n    AuthMiddleware,\r\n    AuthGuard,\r\n  ],\r\n  controllers: [\r\n    AuthController,\r\n  ],\r\n  exports: [\r\n    AuthMiddleware,\r\n    AuthGuard,\r\n  ],\r\n})\r\nexport class AuthModule {\r\n}\r\n```\r\n\r\nusers module:\r\n```\r\n@Module({\r\n  imports: [\r\n    forwardRef(() => AuthModule),\r\n  ],\r\n  controllers: [\r\n    UsersController,\r\n  ],\r\n  components: [\r\n    UsersService,\r\n    ...usersProviders,\r\n    UsersResolver\r\n  ],\r\n  exports: [\r\n    UsersService,\r\n  ],\r\n})\r\nexport class UsersModule implements NestModule {\r\n  configure(consumer: MiddlewaresConsumer): void {\r\n    const authRoutes = UsersController.getAuthRoutes();\r\n    consumer\r\n      .apply(AuthMiddleware)\r\n      .forRoutes(...authRoutes);\r\n  }\r\n}\r\n```\r\nHere is the problem:\r\nUsersResolver:\r\n```\r\n@Resolver('User')\r\nexport class UsersResolver {\r\n  constructor(\r\n    private readonly usersService: UsersService,\r\n  ) {}\r\n\r\n  @Query()\r\n  @UseGuards(AuthGuard)\r\n  async user(obj, args, context, info) {\r\n    console.log(obj.currentUser);\r\n    const {_id} = args;\r\n    return await this.usersService.getById(_id);\r\n  }\r\n\r\n  @ResolveProperty()\r\n  acl(user) {\r\n    return user.acl;\r\n  }\r\n}\r\n```\r\nWhen i'm trying to use guard i'm getting error, but when i commenting its usage, everything starts normally.\r\n```\r\n  @Query()\r\n  // @UseGuards(AuthGuard)\r\n  async user(obj, args, context, info) {\r\n```\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n<!-- Describe the motivation or the concrete use case. -->\r\nHandle authentication with GraphQL\r\n## Environment\r\n\r\n<pre><code>\r\nNest version: 4.6.6\r\n<!-- Check whether this is still an issue in the most recent Nest version -->\r\n \r\nFor Tooling issues:\r\n- Node version: v9.11.1\r\n- Platform:  Linux\r\n\r\nOthers:\r\n - GraphQL package version 2.0.0\r\n</code></pre>\r\n"},"comment":{"url":"https://api.github.com/repos/nestjs/nest/issues/comments/384910272","html_url":"https://github.com/nestjs/nest/issues/598#issuecomment-384910272","issue_url":"https://api.github.com/repos/nestjs/nest/issues/598","id":384910272,"user":{"login":"kamilmysliwiec","id":23244943,"avatar_url":"https://avatars0.githubusercontent.com/u/23244943?v=4","gravatar_id":"","url":"https://api.github.com/users/kamilmysliwiec","html_url":"https://github.com/kamilmysliwiec","followers_url":"https://api.github.com/users/kamilmysliwiec/followers","following_url":"https://api.github.com/users/kamilmysliwiec/following{/other_user}","gists_url":"https://api.github.com/users/kamilmysliwiec/gists{/gist_id}","starred_url":"https://api.github.com/users/kamilmysliwiec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamilmysliwiec/subscriptions","organizations_url":"https://api.github.com/users/kamilmysliwiec/orgs","repos_url":"https://api.github.com/users/kamilmysliwiec/repos","events_url":"https://api.github.com/users/kamilmysliwiec/events{/privacy}","received_events_url":"https://api.github.com/users/kamilmysliwiec/received_events","type":"User","site_admin":false},"created_at":"2018-04-27T08:59:12Z","updated_at":"2018-04-27T08:59:12Z","author_association":"OWNER","body":"Thanks @ToKaTpoHb.\r\nIn general, what you should do is:\r\n1. Remove `AuthGuard` from both `components` and `exports` (you don't have to explicitly define guards/interceptors as a part of the module)\r\n2. Add `JwtAuthStrategy` to the `exports` section (done already)\r\n\r\nThis is an expected behavior then :)"}}
{"actor":{"display_login":"kamilmysliwiec"}}