From 157ff605f14e3eb63aa77b379798c6d9bf4486b6 Mon Sep 17 00:00:00 2001 From: Rishichandra Wawhal Date: Thu, 23 Apr 2020 17:00:09 +0530 Subject: [PATCH 1/3] preserve the selection set in derived action --- console/src/shared/utils/deriveAction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/console/src/shared/utils/deriveAction.js b/console/src/shared/utils/deriveAction.js index 5df6b7ad9308d..8cec45fad3a2f 100644 --- a/console/src/shared/utils/deriveAction.js +++ b/console/src/shared/utils/deriveAction.js @@ -97,6 +97,10 @@ const deriveAction = ( const operationDefinition = rootFields[0]; const operationName = operationDefinition.name.value; + const selectedFields = operationDefinition.selectionSet.selections.map(s => { + return s.name.value; + }); + // get action name if not provided if (!actionName) { actionName = operationAst.definitions[0].name @@ -212,7 +216,10 @@ const deriveAction = ( Object.values(getTypeFields(refOperationOutputType)).forEach( outputTypeField => { const fieldTypeMetadata = getUnderlyingType(outputTypeField.type); - if (isScalarType(fieldTypeMetadata.type)) { + if ( + isScalarType(fieldTypeMetadata.type) && + selectedFields.includes(outputTypeField.name) + ) { outputTypeFields[outputTypeField.name] = wrapTypename( fieldTypeMetadata.type.name, fieldTypeMetadata.wraps From 98b4bfcf84c5f6deb5735d48f871f317d31ce4aa Mon Sep 17 00:00:00 2001 From: Rishichandra Wawhal Date: Thu, 23 Apr 2020 17:22:20 +0530 Subject: [PATCH 2/3] throw error if no scalar fields are selected --- console/src/shared/utils/deriveAction.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/console/src/shared/utils/deriveAction.js b/console/src/shared/utils/deriveAction.js index 8cec45fad3a2f..722e8de8aa51b 100644 --- a/console/src/shared/utils/deriveAction.js +++ b/console/src/shared/utils/deriveAction.js @@ -228,6 +228,11 @@ const deriveAction = ( } ); }); + if (!Object.keys(outputTypeFields).length) { + throw new Error( + `no scalar found in the selection set of your operation; only scalar fields of the operation get mapped onto the output type of the derived action` + ); + } Object.keys(outputTypeFields).forEach(fieldName => { actionOutputType.fields.push({ From a586b5c72b0858de1aa1c8852df9416e23f66233 Mon Sep 17 00:00:00 2001 From: Rishichandra Wawhal Date: Thu, 23 Apr 2020 17:57:06 +0530 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a9b9e25f6464..57ca9f76ef365 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Along with the check for filtering rows that can be updated, you can now set a p - server: support special characters in JSON path query argument with bracket `[]` notation, e.g `obj['Hello World!']` (#3890) (#4482) - server: add graphql-engine support for timestamps without timezones (fix #1217) - server: support inserting unquoted bigint, and throw an error if value overflows the bounds of the integer type (fix #576) (fix #4368) +- console: while deriving action, map selection set of parent mutation to action's returning type (#4530) - console: change react ace editor theme to eclipse (close #4437) - console: fix columns reordering for relationship tables in data browser (#4483) - console: format row count in data browser for readablity (#4433)