-
I am trying to enable AuthZ for a yoga/pothos graphQL server running on Bun. For that I need to wrap the graphql execute function, but I don't find any exposed functionality to do that in yoga. Is there a way to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
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:
Which is something I can't seem to fix within the resource bounds I have. I hope this is useful to other people! |
Beta Was this translation helpful? Give feedback.
Alright, so this can be done making a custom plugin as the following:
EDIT: This is how it is added:
And then adding it to the yoga plugins.
I moved away from this, as it does not at all play with the prisma realtions: