nestjs-dataloader icon indicating copy to clipboard operation
nestjs-dataloader copied to clipboard

add context in generateDataLoader to configure the query based on req

Open gouroujo opened this issue 5 years ago • 4 comments

This PR will allow to configure how we resolve data based not only on a list of ids but also with the current graphql context.

gouroujo avatar Feb 07 '20 19:02 gouroujo

@gouroujo I was about to make the same PR! :smiley: I was looking for a way to pass an access token from the request to a gRPC dataloader, and I settled for this solution. I think typing the context passed to generateDataLoader as GraphQLExecutionContext would be safer.

@krislefeber this shouldn't be breaking, existing data loaders can ignore the parameter and keep working as expected, even without overloading the generateDataLoader method.

asmeikal avatar Feb 20 '20 17:02 asmeikal

@gouroujo, if we can get typing added to the passed in context variable I will go ahead and make the merge. I see my mistake about the optional parameter

krislefeber avatar Feb 21 '20 00:02 krislefeber

Is there any plan to merge this? It would be a great addition to this lib.

The alternative for me is to fork this repo and do it in my project but I would love to keep using this package 😄

ghost avatar Sep 03 '20 11:09 ghost

Is there any update regarding this ?

AmrAnwar avatar Nov 28 '22 16:11 AmrAnwar