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

Allow returning arbitrary values

Open jacob-israel-turner opened this issue 5 years ago • 6 comments

We're looking at using this library to wrap a portion of our existing data loader implementation. A headache that has come up is that redis-dataloader does not allow returning primitives, only JSON. This makes consuming data loaders that return, for example, a simple count, somewhat more cumbersome. It is achievable by returning something like { count: 21 }, but then every consumer (generally GraphQL type resolvers) must pull that value out of the response from the data loader.

Is there a reason that redis-dataloader could not allow arbitrary primitives, such as numbers?

jacob-israel-turner avatar Aug 28 '20 17:08 jacob-israel-turner

yeah that makes sense

PatrickJS avatar Aug 28 '20 20:08 PatrickJS

Cool - how can I help?

jacob-israel-turner avatar Aug 28 '20 21:08 jacob-israel-turner

this is the issue right? https://github.com/PatrickJS/redis-dataloader/blob/master/index.js#L100

PatrickJS avatar Aug 29 '20 06:08 PatrickJS

Hmm, I don't think so. From reading that code, if a non-object is passed in, it should just pass it through directly. However, according to @mahcloud, if a non-object is passed in, an error is thrown. I can look at getting the specific error if that's helpful.

jacob-israel-turner avatar Aug 31 '20 16:08 jacob-israel-turner

yeah, we're thinking about rewriting the package in typescript too so any problems you run into let me know

PatrickJS avatar Sep 01 '20 01:09 PatrickJS

Hi @PatrickJS I was wondering if there was any progress on this topic, or anything we may track which is related to this issue?

paul-vd avatar Jul 20 '22 12:07 paul-vd