Skip to content

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

@Eldow

Description

@Eldow

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions