Open dallinbjohnson opened 3 years ago
This totally makes sense. I would like to see the client side server hooks run as well. Perhaps a good solution is to export a modified version of the collectBatches
hook and allow the developer to use it explicitly.
You would then not use the batchClient
plugin and would use the collectBatches
hook directly. Something like this
// Pass the manger in explicitly and remove excludes
const collectBatches = manager => async context => {
const { method, path } = context;
const args = makeArguments(context);
const payload = [method, path, ...args];
const batchPromise = new Promise((resolve, reject) => manager.addBatchCall({
resolve,
reject,
payload
}));
context.result = await batchPromise;
return context;
};
// Use the hook manually
import { BatchManger, collectBatches } from 'feathers-batch';
const manager = new BatchManager()
const batchHook = collectBatches(manager);
// use batchHook wherever you want
Steps to reproduce
Because feathers-batch is a global hook it does not run individual service hooks that may add data or perform ETL functions.
I think that if we added global after hooks that could be added after all service hooks for front end and back end hooks would be wonderful and would solve this problem.
(First please check that this issue is not already solved as described here)
feathers client hooks do not run on batched calls. Because it is a global hook.
Expected behavior
Tell us what should happen
I think the batched hook should run after each service hook runs.
Actual behavior
Tell us what happens instead
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
NodeJS version:
Operating System:
Browser Version:
React Native Version:
Module Loader: