{"action":"created","issue":{"url":"https://api.github.com/repos/nestjs/graphql/issues/20","repository_url":"https://api.github.com/repos/nestjs/graphql","labels_url":"https://api.github.com/repos/nestjs/graphql/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/nestjs/graphql/issues/20/comments","events_url":"https://api.github.com/repos/nestjs/graphql/issues/20/events","html_url":"https://github.com/nestjs/graphql/issues/20","id":321414835,"node_id":"MDU6SXNzdWUzMjE0MTQ4MzU=","number":20,"title":"use dataloader","user":{"login":"zuohuadong","id":11203929,"node_id":"MDQ6VXNlcjExMjAzOTI5","avatar_url":"https://avatars0.githubusercontent.com/u/11203929?v=4","gravatar_id":"","url":"https://api.github.com/users/zuohuadong","html_url":"https://github.com/zuohuadong","followers_url":"https://api.github.com/users/zuohuadong/followers","following_url":"https://api.github.com/users/zuohuadong/following{/other_user}","gists_url":"https://api.github.com/users/zuohuadong/gists{/gist_id}","starred_url":"https://api.github.com/users/zuohuadong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zuohuadong/subscriptions","organizations_url":"https://api.github.com/users/zuohuadong/orgs","repos_url":"https://api.github.com/users/zuohuadong/repos","events_url":"https://api.github.com/users/zuohuadong/events{/privacy}","received_events_url":"https://api.github.com/users/zuohuadong/received_events","type":"User","site_admin":false},"labels":[{"id":948482429,"node_id":"MDU6TGFiZWw5NDg0ODI0Mjk=","url":"https://api.github.com/repos/nestjs/graphql/labels/discussion","name":"discussion","color":"fbca04","default":false},{"id":779847856,"node_id":"MDU6TGFiZWw3Nzk4NDc4NTY=","url":"https://api.github.com/repos/nestjs/graphql/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-05-09T03:07:15Z","updated_at":"2018-11-02T16:57:08Z","closed_at":null,"author_association":"NONE","body":"Are there any relevant examples?\r\n\r\n\r\nhttps://github.com/facebook/dataloader"},"comment":{"url":"https://api.github.com/repos/nestjs/graphql/issues/comments/435444077","html_url":"https://github.com/nestjs/graphql/issues/20#issuecomment-435444077","issue_url":"https://api.github.com/repos/nestjs/graphql/issues/20","id":435444077,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTQ0NDA3Nw==","user":{"login":"babbarankit","id":666940,"node_id":"MDQ6VXNlcjY2Njk0MA==","avatar_url":"https://avatars0.githubusercontent.com/u/666940?v=4","gravatar_id":"","url":"https://api.github.com/users/babbarankit","html_url":"https://github.com/babbarankit","followers_url":"https://api.github.com/users/babbarankit/followers","following_url":"https://api.github.com/users/babbarankit/following{/other_user}","gists_url":"https://api.github.com/users/babbarankit/gists{/gist_id}","starred_url":"https://api.github.com/users/babbarankit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babbarankit/subscriptions","organizations_url":"https://api.github.com/users/babbarankit/orgs","repos_url":"https://api.github.com/users/babbarankit/repos","events_url":"https://api.github.com/users/babbarankit/events{/privacy}","received_events_url":"https://api.github.com/users/babbarankit/received_events","type":"User","site_admin":false},"created_at":"2018-11-02T16:57:08Z","updated_at":"2018-11-02T16:57:08Z","author_association":"NONE","body":"### Sample Code\r\n```\r\nexport class ApplicationModule implements NestModule {\r\n  constructor(\r\n    private readonly articleService: ArticleService,\r\n    private readonly graphQLFactory: GraphQLFactory,\r\n    private readonly userService: UserService,\r\n    private readonly cinemaClassicsService: CinemaClassicsService,\r\n    private readonly artformCategoryService: ArtformCategoryService,\r\n    private readonly configService: ConfigService,\r\n    private readonly geoChapterService: GeoChapterService,\r\n    private readonly downloadCategoryService: DownloadCategoryService,\r\n    private readonly artformService: ArtformService,\r\n    private readonly personalProfileService: PersonalProfileService,\r\n    private readonly artistProfileService: ArtistProfileService,\r\n    private readonly artistListService: ArtistListService,\r\n  ) {}\r\n  configure(consumer: MiddlewareConsumer) {\r\n    const awsSettings = this.configService.getAWSConfig();\r\n    const disableCors = this.configService.disableCors();\r\n    let headers: {\r\n      'Access-Control-Allow-Origin'?: string;\r\n    } = {};\r\n    if (disableCors) {\r\n      headers = { 'Access-Control-Allow-Origin': 'http://localhost:3010' };\r\n    }\r\n    consumer\r\n      .apply(\r\n        require('react-s3-uploader/s3router')({\r\n          bucket: awsSettings.defaultBucket,\r\n          region: awsSettings.defaultRegion,\r\n          signatureVersion: 'v4',\r\n          headers,\r\n          ACL: 'public-read',\r\n          uniquePrefix: true,\r\n        }),\r\n      )\r\n      .forRoutes('/s3');\r\n    consumer.apply(AuthMiddleware).forRoutes('/health/anonymous');\r\n\r\n    consumer.apply(AuthMiddleware).forRoutes('/health/authenticated');\r\n\r\n    consumer.apply(AuthMiddleware).forRoutes('/query');\r\n\r\n    const typeDefs = this.graphQLFactory.mergeTypesByPaths('./**/*.graphql', './../node_modules/@ankitbabbar/instiapp-api-core/src/**/*.graphql');\r\n    const resolvers = {\r\n      DateTime: GraphQLDateTime,\r\n      Date: GraphQLDate,\r\n      Time: GraphQLTime,\r\n    };\r\n\r\n    const schema = this.graphQLFactory.createSchema({\r\n      typeDefs,\r\n      resolvers,\r\n      resolverValidationOptions: {\r\n        requireResolversForResolveType: false,\r\n      },\r\n    });\r\n\r\n    consumer\r\n      .apply(\r\n        graphqlExpress((req, res) => {\r\n          const viewer = res.locals.viewer;\r\n          const dataLoaders: ContribDataLoaders = {\r\n            user: new DataLoader((ids: number[]) => this.userService.getManyByIds(viewer, ids)),\r\n            article: new DataLoader((ids: number[]) => this.articleService.getManyByIds(viewer, ids)),\r\n            cinemaClassics: new DataLoader((ids: number[]) => this.cinemaClassicsService.getManyByIds(viewer, ids)),\r\n            artform: new DataLoader((ids: number[]) => this.artformService.getManyByIds(viewer, ids)),\r\n            geoChapter: new DataLoader((ids: number[]) => this.geoChapterService.getManyByIds(viewer, ids)),\r\n            artformCategory: new DataLoader((ids: number[]) => this.artformCategoryService.getManyByIds(viewer, ids)),\r\n            downloadCategory: new DataLoader((ids: number[]) => this.downloadCategoryService.getManyByIds(viewer, ids)),\r\n            personalProfile: new DataLoader((ids: number[]) => this.personalProfileService.getManyByIds(viewer, ids)),\r\n            artistList: new DataLoader((ids: number[]) => this.artistListService.getManyByIds(viewer, ids)),\r\n            artistProfile: new DataLoader((ids: number[]) => this.artistProfileService.getManyByIds(viewer, ids)),\r\n          };\r\n          const context: IGQLContext = {\r\n            viewer,\r\n            dataLoaders,\r\n          };\r\n          return {\r\n            schema,\r\n            rootValue: req,\r\n            formatError,\r\n            context,\r\n          };\r\n        }),\r\n      )\r\n      .forRoutes('/query');\r\n  }\r\n}\r\n```"}}
{"actor":{"display_login":"babbarankit"}}