mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Change mutaion definition for single types
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
0285c7bd96
commit
900cec28f4
@ -498,10 +498,17 @@ const buildMutation = ({ model, action }, { _schema }) => {
|
||||
};
|
||||
}
|
||||
|
||||
const { kind } = model;
|
||||
|
||||
let mutationDef = `${mutationName}(input: ${mutationName}Input)`;
|
||||
if (kind === 'singleType' && action === 'delete') {
|
||||
mutationDef = mutationName;
|
||||
}
|
||||
|
||||
return {
|
||||
definition,
|
||||
mutation: {
|
||||
[`${mutationName}(input: ${mutationName}Input)`]: `${mutationName}Payload`,
|
||||
[mutationDef]: `${mutationName}Payload`,
|
||||
},
|
||||
resolvers: {
|
||||
Mutation: {
|
||||
|
||||
@ -291,6 +291,8 @@ module.exports = {
|
||||
const singularName = toSingular(name);
|
||||
const inputName = toInputName(name);
|
||||
|
||||
const { kind } = model;
|
||||
|
||||
switch (action) {
|
||||
case 'create':
|
||||
return `
|
||||
@ -298,11 +300,24 @@ module.exports = {
|
||||
type ${mutationName}Payload { ${singularName}: ${model.globalId} }
|
||||
`;
|
||||
case 'update':
|
||||
if (kind === 'singleType') {
|
||||
return `
|
||||
input ${mutationName}Input { data: edit${inputName} }
|
||||
type ${mutationName}Payload { ${singularName}: ${model.globalId} }
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
input ${mutationName}Input { where: InputID, data: edit${inputName} }
|
||||
type ${mutationName}Payload { ${singularName}: ${model.globalId} }
|
||||
`;
|
||||
case 'delete':
|
||||
if (kind === 'singleType') {
|
||||
return `
|
||||
type ${mutationName}Payload { ${singularName}: ${model.globalId} }
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
input ${mutationName}Input { where: InputID }
|
||||
type ${mutationName}Payload { ${singularName}: ${model.globalId} }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user