System Information
- Strapi Version: 4.3.2
- Operating System:
- Database:
- Node Version:
- NPM Version:
- Yarn Version:
I want to extend the graphql resolver of removeFile
mutation (which comes from the upload
core plugin).
I have successfully replaced the resolver using the following code on my plugin’s register.js
file, but I haven’t yet find a way to call the original resolver of removeFile
inside my custom one
export default ({ strapi }) => {
const extensionService = strapi.plugin("graphql").service("extension");
extensionService.use(({ nexus }) => ({
resolvers: {
Mutation: {
removeFile: async (obj, args) => {
// my custom logic will goes here
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// I WANT TO CALL the original resolver of "removeFile" here
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// other logic will also goes here
},
},
},
}));
};
So my question is: How can I call a graphql registered resolver (the original resolver of removeFile
mutation) from another one (the new registered resolver)?
Additional Info: note that I have successfully replaced a controller handler by assign a new function to it and call the old one in some point of time. here is the code
export default ({ strapi }) => {
strapi.container
.get("controllers")
.extend("plugin::upload.admin-file", (controller) => {
const originalHandler = controller["destroy"].bind(controller);
controller["destroy"] = async function (ctx) {
// my custom logic will goes here
await originalHandler();
// other logic will also goes here
};
return controller;
});
};