System Information
- Strapi Version: 4.20.4
- Operating System: Linux
- Database: Postgres
- Node Version: v20.11.1
- NPM Version: 10.2.4
- Yarn Version: 1.22.19
I am trying to extend the users-permissions plugin using the register method in the index.ts.
extensionService.use(({ nexus }) => ({
types: [
nexus.extendInputType({
type: 'UsersPermissionsRegisterInput',
definition(t) {
// here define fields you need
// t.string('dob');
t.string('phone');
t.string('gender');
t.string('dob');
t.string("address");
},
}),
nexus.extendType({
type: 'UsersPermissionsMe',
definition(t) {
t.string('phone');
t.string('gender');
t.string('dob');
t.string("address");
},
}),
nexus.extendType({
type: 'Mutation',
definition(t) {
t.field('createCustomerByAdmin', {
type: CustomerOutputType,
args: {
data: CustomerInputType
},
resolve(parent, args, context) {
const { data } = args;
console.log(context.state)
return strapi.service('api::users-permissions.user').createCustomerByAdmin(data);
}
});
}
})
]
}));
Right now, this mutation works with any authenticated user of roles defined by the users-permissions plugin. I need to restrict it to work with only admin type only.
mutation CreateCustomerByAdmin($data: CustomerInputType) {
createCustomerByAdmin(data: $data) {
id
email
gender
dob
address
blocked
confirmed
}
}
I also want it the code to be moved to a plugin instead of modifications in the index.ts file. What is the ideal way of doing this?