Skip to content

fix: apig vtl stringify#361

Merged
thantos merged 1 commit intomainfrom
fix_apig_stringify
Jul 26, 2022
Merged

fix: apig vtl stringify#361
thantos merged 1 commit intomainfrom
fix_apig_stringify

Conversation

@thantos
Copy link
Copy Markdown
Collaborator

@thantos thantos commented Jul 26, 2022

Do things that don't scale?

new AwsMethod(
  {
    httpMethod: "POST",
    resource: saga,
  },
  (
    $input: ApiGatewayInput<
      ApiRequest<
        {},
        Reservation & { [index: string]: ApiBody },
        { run_type?: RunType }
      >
    >
  ) => {
    return sagaFunction.func({
      input: {
        reservation: $input.data!,
        run_type: $input.params("run_type")!,
      },
    });
  },
  (result) => {
    return result.data;
  }
);
{
"stateMachineArn":"arn:aws:states:us-east-1:180727192481:stateMachine:sagasagaFunction54D97EEF-B6WfpKLDY3QV",
"input":"{\"reservation\":$util.escapeJavaScript($input.json('$')),\"run_type\":\"$input.params('run_type')\"}"
}

@netlify
Copy link
Copy Markdown

netlify bot commented Jul 26, 2022

Deploy Preview for effortless-malabi-1c3e77 ready!

Name Link
🔨 Latest commit 0d051b1
🔍 Latest deploy log https://app.netlify.com/sites/effortless-malabi-1c3e77/deploys/62e009fce55eac00080a7ca6
😎 Deploy Preview https://deploy-preview-361--effortless-malabi-1c3e77.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

}

/**
* Attempt to return the expression as a valid escaped json string.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it fail sometimes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Don't have exhaustive tests or runtime tests, but it works for the two cases I tried. I assume it will need to get more complex as more cases are found or we re-architect to support the various output cases (ex: late resolution with a sub-ast instead of in place transform that can account for the need to be a string instead of an object.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants