evaluateCode method

Future<EvaluateCodeResponse> evaluateCode({
  1. required String code,
  2. required String context,
  3. required AppSyncRuntime runtime,
  4. String? function,
})

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.

May throw AccessDeniedException. May throw BadRequestException. May throw InternalFailureException.

Parameter 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.

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

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

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

Implementation

Future<EvaluateCodeResponse> evaluateCode({
  required String code,
  required String context,
  required AppSyncRuntime runtime,
  String? function,
}) async {
  final $payload = <String, dynamic>{
    'code': code,
    'context': context,
    'runtime': runtime,
    if (function != null) 'function': function,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/dataplane-evaluatecode',
    exceptionFnMap: _exceptionFns,
  );
  return EvaluateCodeResponse.fromJson(response);
}