IssueRaiser

Feature: Data loader integration

https://github.com/facebook/dataloader 1. Caching resolving the same data 2. Instead of normal resolving: ```ts @FieldResolver() author(@Root() recipe: Recipe) { return this.userRepository.findById(recipe.authorId); } ``` Introduce batched resolving - taking array of roots: ```ts @FieldResolver() async author(@Root() recipes: Recipe[]) { const ids = recipes.map(r => r.authorId); return this.userRepository.findByIds(ids); } ``` 3. Decorator: ```ts @Mutation() async mutationThatAffectLoader( @Arg("input") input: SomeInput, @DataLoader(User) loader, ) { const result = await this.mutateSomething(input); loader.clear(input.someKey); return result; } ```

Posted by MichalLytek on Mar 27, 2018, 7:59 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Software)

Feature: Data loader integration

MichalLytekMar 27, 2018, 7:59 PM

https://github.com/facebook/dataloader 1. Caching resolving the same data 2. Instead of normal resolving: ```ts @FieldResolver() author(@Root() recipe: Recipe) { return this.userRepository.findById(recipe.authorId); } ``` Introduce batched resolving - taking array of roots: ```ts @FieldResolver() async author(@Root() recipes: Recipe[]) { const ids = recipes.map(r => r.authorId); return this.userRepository.findByIds(ids); } ``` 3. Decorator: ```ts @Mutation() async mutationThatAffectLoader( @Arg("input") input: SomeInput, @DataLoader(User) loader, ) { const result = await this.mutateSomething(input); loader.clear(input.someKey); return result; } ```

Comments (0)

No comments yet. Start the discussion.

Comment on this issue