Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Jan 29, 2024 · 2 comments
Open

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

ghost opened this issue Jan 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jan 29, 2024

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
Copy link
Contributor

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

@gurjotkaur20
Copy link
Contributor

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.

  • Either we add this where filter in the workflow for each entity
  • Or we can keep the filter in some mappings to keep the workflow unchanges (in case of multiple clients using the same workflow) and mappings can be kept separately for different clients. This will keep the main workflow same for all the clients, the variable part would be there in mappings.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants