aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 77 forks source link

Feature Request: a way to evaluate only VTL templates locally in a Unit Test #382

Open erezrokah opened 5 years ago

erezrokah commented 5 years ago

As suggested here, I'm opening this feature request here to get more feedback.

From the original issue:

Ideally I would like to be able to do something like this in a Unit Test:

expect(evaulateVTL(context, template)).toEqual(expectedTemplate);

I found this unofficial tool for API Gateway mapping (it is outdated but works).

The AppSync console already has this functionally and even provides useful context sample objects.

Correct me if I'm wrong but this will only check the template for errors.

I'm also aware of this new feature, but would like to be able to iterate just on the VTL templates before messing around with the GraphQL schema.

attilah commented 5 years ago

@erezrokah thanks for this feature request! Regarding the mock features, that's not just a validation over your VTL templates, you can actually run a local AppSync Simulator with a local GraphQL console and edit, debug, your VTL templates as the documentation page you linked describes it.

If you think that we could make the documentation around the mocking features better please suggest some changes.

erezrokah commented 5 years ago

Hey @attilah and thank you for the quick response.

I appreciate the clarification. I tried the local mock, but the main issue I'm trying to achieve is running the VTL transformation without going through GraphQL, and also being able to write unit tests for my VTL templates (similar to here).

For me, working with GraphQL is more familiar and less challenging (and there are already many tools to simulate a server/schema locally).

Another thing is that I'm creating my own back-end resources and just using Amplify for the client libraries (mostly because I want to use one DynamoDB table), so that makes it difficult for me to use the CLI commands.

I'm not sure this issue is relevant to the CLI itself, but I was redirected here after opening this issue.