From eb272e996ca3a7445dba6e4eba00b01374c9c952 Mon Sep 17 00:00:00 2001 From: gp27 Date: Thu, 16 Jul 2020 08:45:44 +0200 Subject: [PATCH] - fix in graphql type builder (#6075) a required attribute that has a default value it's now not required in the input schema used for entities creation Signed-off-by: Gadi Piperno Corcos Co-authored-by: Gadi Piperno Corcos --- packages/strapi-plugin-graphql/services/type-builder.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/strapi-plugin-graphql/services/type-builder.js b/packages/strapi-plugin-graphql/services/type-builder.js index 45943e8d69..5fcdd53e81 100644 --- a/packages/strapi-plugin-graphql/services/type-builder.js +++ b/packages/strapi-plugin-graphql/services/type-builder.js @@ -71,8 +71,10 @@ module.exports = { break; } - if (attribute.required && action !== 'update') { - type += '!'; + if (attribute.required) { + if (rootType !== 'mutation' || (action !== 'update' && attribute.default === undefined)) { + type += '!'; + } } return type;