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

How to use nested mutations with makeWrapResolversPlugin in filter matching mode #58

Open
Eldow opened this issue Nov 16, 2021 · 0 comments

Comments

@Eldow
Copy link
Contributor

Eldow commented Nov 16, 2021

Hello everyone, this issue is more of a call for help.

I am trying to use this core plugin https://www.graphile.org/postgraphile/make-wrap-resolvers-plugin/ in conjunction with postgraphile nested mutations.

// Example: log before and after each mutation runs
module.exports = makeWrapResolversPlugin(
  context => {
    if (context.scope.isRootMutation) {
      return { scope: context.scope };
    }
    return null;
  },
  ({ scope }) => async (resolver, user, args, context, _resolveInfo) => {
    console.log(`Mutation '${scope.fieldName}' starting with arguments:`, args);
    const result = await resolver();
    console.log(`Mutation '${scope.fieldName}' result:`, result);
    return result;
  }
);

In this example, the plugin adds custom logic (console logs) to every root mutation resolvers. I was wondering if there was a way to add custom logic to, let's say, every mutation creating a user, regardless of whether it's a root mutation or a nested one created through this plugin.

Has anyone tried to achieve the same behavior - or has more knowledge than me about what to look for in the resolver context to filter out the right ones ?

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

1 participant