godspeedsystems / gs-node-service

Godspeed microservice framework
https://godspeed.systems/
Other
624 stars 15 forks source link

Not able to use inputs and output in mappings as placeholders #939

Open ghost opened 9 months ago

ghost commented 9 months ago

Version Information

@godspeedsystems/core: 2.3.2

Current Behavior

We can't use inputs and outputs in mappings as placeholders. Currently, what is happening, inputs and outputs are getting evaluated loadtime, but at that time, inputs and outputs will be blank. So id is coming as blank. For example, sample mapping yaml:

get:
  where:
    id: <% inputs?.params?.id %>
  select:
    id: true
    name: true
    email: true
    enabled: true
    roles:
      select:
        name: true
  bName: <% config.bname %>
  cName: <% mappings.sample %>

Expected Behavior

inputs and outputs should go as it is like a placeholder and should get evaluated at the runtime whenever any event is triggered and any workflow is executing.

So what should happen as per the above example, in mappings.sample and config.bname should be evaluated during loadtime because these are the constants but inputs and outputs should go as they are. These should get evaluated during the workflow execution.

mastersilv3r commented 8 months ago

Shouldn't mappings always be loaded and evaluated at load time? Instead of at run time?

gurjotkaur20 commented 7 months ago

Let me give an example of my use case: In my prisma schema, I have two tables user and user_type where user has a relation with user_type.

Request body is fixed e.g.

"name": "abc",
"user_type": "admin"

If we want to get user then in the workflow we need to provide the filters like where, select, etc., But to provide related records information we need to give where clause something like this:

where:
  name: <% inputs.body.name %>
  user_type:
     select:
       name: <% inputs.body.user_type %>

We have two options here.

So, the option 2 is only feasible if mappings can take inputs and outputs.