2025/01/28 - AWS AppSync - 2 updated api methods
Changes Add stash and outErrors to EvaluateCode/EvaluateMappingTemplate response
{'outErrors': 'string', 'stash': 'string'}
Evaluates the given code and returns the response. The code definition requirements depend on the specified runtime. For APPSYNC_JS runtimes, the code defines the request and response functions. The request function takes the incoming request after a GraphQL operation is parsed and converts it into a request configuration for the selected data source operation. The response function interprets responses from the data source and maps it to the shape of the GraphQL field output type.
See also: AWS API Documentation
Request Syntax
client.evaluate_code( runtime={ 'name': 'APPSYNC_JS', 'runtimeVersion': 'string' }, code='string', context='string', function='string' )
dict
[REQUIRED]
The runtime to be used when evaluating the code. Currently, only the APPSYNC_JS runtime is supported.
name (string) -- [REQUIRED]
The name of the runtime to use. Currently, the only allowed value is APPSYNC_JS.
runtimeVersion (string) -- [REQUIRED]
The version of the runtime to use. Currently, the only allowed version is 1.0.0.
string
[REQUIRED]
The code definition to be evaluated. Note that code and runtime are both required for this action. The runtime value must be APPSYNC_JS.
string
[REQUIRED]
The map that holds all of the contextual information for your resolver invocation. A context is required for this action.
string
The function within the code to be evaluated. If provided, the valid values are request and response.
dict
Response Syntax
{ 'evaluationResult': 'string', 'error': { 'message': 'string', 'codeErrors': [ { 'errorType': 'string', 'value': 'string', 'location': { 'line': 123, 'column': 123, 'span': 123 } }, ] }, 'logs': [ 'string', ], 'stash': 'string', 'outErrors': 'string' }
Response Structure
(dict) --
evaluationResult (string) --
The result of the evaluation operation.
error (dict) --
Contains the payload of the response error.
message (string) --
The error payload.
codeErrors (list) --
Contains the list of CodeError objects.
(dict) --
Describes an AppSync error.
errorType (string) --
The type of code error.
Examples include, but aren't limited to: LINT_ERROR, PARSER_ERROR.
value (string) --
A user presentable error.
Examples include, but aren't limited to: Parsing error: Unterminated string literal.
location (dict) --
The line, column, and span location of the error in the code.
line (integer) --
The line number in the code. Defaults to 0 if unknown.
column (integer) --
The column number in the code. Defaults to 0 if unknown.
span (integer) --
The span/length of the error. Defaults to -1 if unknown.
logs (list) --
A list of logs that were generated by calls to util.log.info and util.log.error in the evaluated code.
(string) --
stash (string) --
An object available inside each resolver and function handler. A single stash object lives through a single resolver run. Therefore, you can use the stash to pass arbitrary data across request and response handlers and across functions in a pipeline resolver.
outErrors (string) --
The list of runtime errors that are added to the GraphQL operation response.
{'outErrors': 'string', 'stash': 'string'}
Evaluates a given template and returns the response. The mapping template can be a request or response template.
Request templates take the incoming request after a GraphQL operation is parsed and convert it into a request configuration for the selected data source operation. Response templates interpret responses from the data source and map it to the shape of the GraphQL field output type.
Mapping templates are written in the Apache Velocity Template Language (VTL).
See also: AWS API Documentation
Request Syntax
client.evaluate_mapping_template( template='string', context='string' )
string
[REQUIRED]
The mapping template; this can be a request or response template. A template is required for this action.
string
[REQUIRED]
The map that holds all of the contextual information for your resolver invocation. A context is required for this action.
dict
Response Syntax
{ 'evaluationResult': 'string', 'error': { 'message': 'string' }, 'logs': [ 'string', ], 'stash': 'string', 'outErrors': 'string' }
Response Structure
(dict) --
evaluationResult (string) --
The mapping template; this can be a request or response template.
error (dict) --
The ErrorDetail object.
message (string) --
The error payload.
logs (list) --
A list of logs that were generated by calls to util.log.info and util.log.error in the evaluated code.
(string) --
stash (string) --
An object available inside each resolver and function handler. A single stash object lives through a single resolver run. Therefore, you can use the stash to pass arbitrary data across request and response handlers and across functions in a pipeline resolver.
outErrors (string) --
The list of runtime errors that are added to the GraphQL operation response.