-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow queries without batch keys #170
base: main
Are you sure you want to change the base?
Allow queries without batch keys #170
Conversation
Hi @arnodirlam can you elaborate what this accomplishes beyond calling |
Hi @benwilson512 thanks for your quick reply! For context, I'm using dataloader outside of GraphQL as a dependency for my library dx. The idea here is a
I'll try to make arguments in the context of running in a GraphQL resolver, though: For example, say you have a resolver that needs to load a database table with a global set of data. Could be some kind of app-wide config. In the app I'm working on, for example, we have tables for user roles that are global. That could be exposed via GraphQL. In that case, there is no batch key, because the data is global, but writing Does that make sense? |
It does. My only thought from an API design standpoint is that maybe we should require that users pass in a specific special value like |
I see. I might be biased here, but to me To me, it's a list of filters, where I see a point in helping prevent user mistakes by using
On another note, I'm considering crafting a PR to enable multiple filters in that list, internally detecting the most efficient key to batch on and executing the queries accordingly. For example, |
I had not really conceptualized the batch key as filter, rather that's the job of the middle arg. The params in the middle argument are filters that apply to the entire batch to be loaded. The right most arg is what uniquely identifiers this particular item within the batch. In general you want a single value there so that the SQL is ultimately some form of EDIT: Put another way, the argument you're calling the "batch key" is the "key of this item in the batch" rather than the key of the batch as a whole. The key of the batch as a whole within dataloader is the middle arg. |
0c9a5df
to
2dfe3c5
Compare
Hi there, sorry for letting this linger. I'd still be interested in getting it merged. Just rebased my branch on
I'd prefer either Thanks! ❤️ |
I have a use case where a query should run in dataloader without batching, together with all other (possibly batched) queries.
A few examples (see tests added in this PR):
The changes needed are minimal.
I'm happy to make another PR for the v1 branch, if and when this gets merged.
Thanks a lot for your consideration! 🙏