Open volbrene opened 4 years ago
I don't believe that would fit with the design of dataloader. The intention is that you already have an ID that ties to a specific value in some data store. Without knowing your data model, it's hard to suggest how to go about a solution. If you are just looking to cache some response, a simple memory cache may be a better solution. Otherwise, maybe you can do some filtering logic once you get the response back.
On Fri, Jan 24, 2020, 11:00 AM René Volbach notifications@github.com wrote:
Hello, is it possible to append in the loadMany and load method a "optional" parameter? I need this for add a language code to the dataloader function, because there I need it.
Or what i the best way to do this?
Thanks
volbrene
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/krislefeber/nestjs-dataloader/issues/10?email_source=notifications&email_token=ABTWSLF2MUI57MMWOAM6ZE3Q7MNENA5CNFSM4KLJFT62YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IISKY5A, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTWSLD4VTFCZC2XVS5QZA3Q7MNENANCNFSM4KLJFT6Q .
or you can pass your region as part of the key to the DataLoader and implement a custom cacheKeyFn.
I am also interested in this, my use case is that I'm trying to prevent overfetching fields from my db, and in regular resolvers I can extract the needed fields from the request.
I can achieve this with regular resolvers but since the db call is in the dataloader I need to find a way to pass those required fields.
Any advice? I might just fork if I have no other choice
I resolved this by using an object for data loader key like {'id': 1, 'param1': 'val1', 'param2': 'val2'} instead of just id's. When you do this make sure you overwrite your "cacheKeyFn"
/**
key => key
. Produces cache key for a given load key. UsefulGood luck.
On Thu, Feb 18, 2021 at 3:39 PM guy-baron1 notifications@github.com wrote:
I am also interested in this, my use case is that I'm trying to prevent overfetching fields from my db, and in regular resolvers I can extract the needed fields from the request.
I can achieve this with regular resolvers but since the db call is in the dataloader I need to find a way to pass those required fields.
Any advice? I might just fork if I have no other choice
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/krislefeber/nestjs-dataloader/issues/10#issuecomment-781620453, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWUCQOSHOKCMY7XKKNQRQLS7V3IDANCNFSM4KLJFT6Q .
Hello, is it possible to append in the loadMany and load method a "optional" parameter? I need this for add a language code to the dataloader function, because there I need it.
Or what i the best way to do this?
Thanks
volbrene