Skip to content

Wrapping execute #3117

Closed Answered by madsbuch
madsbuch asked this question in Q&A
Nov 28, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Alright, so this can be done making a custom plugin as the following:

const authZPlugin: Plugin = {
  onExecute(e) {
    const wrapped = wrapExecuteFn(e.executeFn, { rules }) as typeof e.executeFn;
    return wrapped(e.args);
  },
};

EDIT: This is how it is added:

const authZPlugin: Plugin = {
  onExecute({ executeFn, setExecuteFn }) {
    setExecuteFn(
      wrapExecuteFn(executeFn, {
        rules,
      })
    );
  },
};

And then adding it to the yoga plugins.

I moved away from this, as it does not at all play with the prisma realtions:

GraphQLError: undefined is not an object (evaluating 'state.fieldMap.relations')
 path: "..."
      at /.../node_modules/graphql/error/GraphQLError.js:…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ardatan
Comment options

ardatan Nov 28, 2023
Collaborator

@madsbuch
Comment options

@ardatan
Comment options

ardatan Dec 5, 2023
Collaborator

Answer selected by madsbuch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants