Skip to main content

Module evaluate

Module evaluate 

Source
Expand description

Honest, documented evaluation for EvaluateCode / EvaluateMappingTemplate.

AppSync’s real evaluation endpoints run a full VTL interpreter (mapping templates) or an APPSYNC_JS runtime (code) against a request context and return the rendered result. fakecloud does not ship a VTL/JS interpreter.

Instead this module performs a faithful, bounded evaluation:

  • It validates that context is well-formed JSON (AppSync’s Context is a JSON string) and that the template/code is present and non-empty – returning the model’s error output member (not a top-level exception) when the context is malformed, exactly as AppSync surfaces evaluation errors.
  • It returns a deterministic evaluationResult: the JSON-encoded value of the context’s arguments field when present, else the whole parsed context. This mirrors the overwhelmingly common request-mapping-template shape ($util.toJson($ctx.arguments)), so simple templates evaluate to a sensible, reproducible value without a full interpreter.
  • stash echoes the context’s stash (AppSync threads the stash through), and logs is empty (no interpreter log output is produced).

This is a documented evaluation subset, surfaced honestly rather than faking arbitrary interpreter output.

Structs§

Evaluation
The outcome of an evaluation: either a rendered result or an error detail.

Functions§

evaluate
Evaluate a request against its context. body is the template (mapping) or code string; it must be non-empty. context is the raw Context JSON string from the request.