EvaluateCode - AWS AppSync

EvaluateCode

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.

Request Syntax

POST /v1/dataplane-evaluatecode HTTP/1.1 Content-type: application/json { "code": "string", "context": "string", "function": "string", "runtime": { "name": "string", "runtimeVersion": "string" } }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

code

The code definition to be evaluated. Note that code and runtime are both required for this action. The runtime value must be APPSYNC_JS.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32768.

Required: Yes

context

The map that holds all of the contextual information for your resolver invocation. A context is required for this action.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 28000.

Pattern: ^[\s\S]*$

Required: Yes

function

The function within the code to be evaluated. If provided, the valid values are request and response.

Type: String

Required: No

runtime

The runtime to be used when evaluating the code. Currently, only the APPSYNC_JS runtime is supported.

Type: AppSyncRuntime object

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "error": { "codeErrors": [ { "errorType": "string", "location": { "column": number, "line": number, "span": number }, "value": "string" } ], "message": "string" }, "evaluationResult": "string", "logs": [ "string" ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

error

Contains the payload of the response error.

Type: EvaluateCodeErrorDetail object

evaluationResult

The result of the evaluation operation.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 65536.

Pattern: ^[\s\S]*$

logs

A list of logs that were generated by calls to util.log.info and util.log.error in the evaluated code.

Type: Array of strings

Errors

For information about the errors that are common to all actions, see Common Errors.

AccessDeniedException

You don't have access to perform this operation on this resource.

HTTP Status Code: 403

BadRequestException

The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and then try again.

HTTP Status Code: 400

InternalFailureException

An internal AWS AppSync error occurred. Try your request again.

HTTP Status Code: 500

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: