You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need similar behavior of com.gs.return and com.gs.transform inbuilt workflows
Both com.gs.return and com.gs.transform should behave in the same way(as per below specifications) except that com.gs.return will do the transformation and exit the workflow however com.gs.transform will just do the transformation of result.
The GSStatus is a built-in class in Godspeed. All functions in the framework or written by developer, whether tasks in yaml or typescript funtions or workflows in yaml, have to return either GSStatus or data.
The GSStatus has five keys: code , success, message , data , headers
Now lets see how the framework will qualify your return as GSStatus or simple data. The framework will see that your returned data has one of code or success meta-keys. if present, it will look for the other GSStatus keys defined above and set them. If it doesn't find any of these keys, it will assume all that you have returned is intended to be GSStatus.data.
It will add code: 200 and success: true internally to your response and create a GSStatus out of it to pass on to next tasks or workflows.
Deprecated: If the developer uses a flag called defaults.returnV1Compatible in config/default.yaml then the code, success and message of args is not copied to the finally returned GSStatus. The data of returned GSSTatus contains entire args object, with code, message, data, success. Its own code is 200 and success is true always. The same two examples above would return
Setting in default.yaml
defaults:
returnV1Compatible: true # com.gs.return should behave in V1 compatible way
Example 1
tasks:
- id: first_task
fn: com.gs.return
args: <% "Hello World. This is " + inputs.query.name_one + " ."%>
this should return
code: 200
success:true
data: 'Hello world. This is name_from_query.
The Problem
Need similar behavior of
com.gs.return
andcom.gs.transform
inbuilt workflowsBoth
com.gs.return
andcom.gs.transform
should behave in the same way(as per below specifications) except thatcom.gs.return
will do the transformation and exit the workflow howevercom.gs.transform
will just do the transformation of result.The
GSStatus
is a built-in class in Godspeed. All functions in the framework or written by developer, whether tasks in yaml or typescript funtions or workflows in yaml, have to return eitherGSStatus
or data.The
GSStatus
has five keys:code
,success
,message
,data
,headers
GSStatus
or simple data.The framework will see that your returned data has one of
code
orsuccess
meta-keys. if present, it will look for the otherGSStatus
keys defined above and set them. If it doesn't find any of these keys, it will assume all that you have returned is intended to beGSStatus.data
.It will add
code: 200
andsuccess: true
internally to your response and create aGSStatus
out of it to pass on to next tasks or workflows.Example 1
this should return
Example 2
this should return
Example 3
This should return
defaults.returnV1Compatible
inconfig/default.yaml
then the code, success and message of args is not copied to the finally returned GSStatus. The data of returned GSSTatus contains entire args object, with code, message, data, success. Its own code is 200 and success is true always. The same two examples above would returnSetting in default.yaml
Example 1
this should return
Example 2
this should return
The Solution
Fix com.gs.return behavior in core/functions
How to test
With
config/default.yaml
hasdefaults.returnV1Compatible
to false or undefinedExample 1
this should return
Example 2
this should return
Example 3
This should return
Example 4
This should return
With
config/default.yaml
hasdefaults.returnV1Compatible
to trueExample 1
this should return
Example 2
this should return
The text was updated successfully, but these errors were encountered: