-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
feat(batch-delegate): added mapping function to createBatchDelegateFn #1825
feat(batch-delegate): added mapping function to createBatchDelegateFn #1825
Conversation
Thanks for your work on this! You can modify the result prior to it's conversion to a proxied result (in which the data is extracted and annotated with errors) by passing an additional transform with a transformResult property, but I agree that it makes sense to provide a direct option. See additional comments in the review. Thanks again! |
What do you mean by: what if the we want to group entities together by key for a one-to-many relation Sounds interesting! |
We could definitely change arguments to named properties within option object, preserving backwards compatibility to original order.... |
That's a use case that I've encountered before. Let's say you have an authors and a books schema. To stitch them, you can add an |
I'll leave it up to you how you handle the arguments. If we're not expecting the list of arguments to grow often then it's probably ok as it is. Either way we can always change it in a future PR/new release version. |
I have been thinking this over and wondering whether overall the workflow should be changed to eliminate the need for the createBatchDelegateFn step and just do everything in one go as.a batchDelegate function that uses whatever arguments are passed to it similar to delegateToSchema with addition of key, argsFn, resultsFn, and adjustment of returnType. I think that is the direction I am heading in, but I think absolutely no harm in merging this PR in the meantime anyway. |
The latest changes of this PR are available as alpha in npm: Quickly update your package.json by running:
|
TODO:
I love the recent addition of the batch-delegate package! The only thing that prevents me from using it is the inability to edit the server's response before returning the results to the dataloader. I believe there is a general need for this feature (e.g. what if the array of entities is not in order, or what if the we want to group entities together by key for a one-to-many relation?), so I wrote a quick PR to make this available. Let me know what you think!