Skip to content
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

feathers client service hooks get skipped. #106

Open
2 tasks
dallinbjohnson opened this issue Jul 6, 2021 · 1 comment
Open
2 tasks

feathers client service hooks get skipped. #106

dallinbjohnson opened this issue Jul 6, 2021 · 1 comment

Comments

@dallinbjohnson
Copy link

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
)

  • Tell us what broke. The more detailed the better.

feathers client hooks do not run on batched calls. Because it is a global hook.

  • If you can, please create a simple example that reproduces the issue and link to a gist, jsbin, repo, etc.

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:

@DaddyWarbucks
Copy link

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.

const collectBatches = async context => {

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants