Skip to content

evaluate_code async

evaluate_code(
    runtime: AppSyncRuntime,
    code: Code,
    context: Context,
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
    function: Optional[String] = None,
) -> EvaluateCodeResponse

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.

Parameters:

  • runtime (AppSyncRuntime) –

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

  • code (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.

  • context (Context) –

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

  • function (Optional[String], default: None ) –

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

Raises:

  • AccessDeniedException –

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

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

  • InternalFailureException –

    An internal AppSync error occurred. Try your request again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_appsync/_services/async_app_sync.py
async def evaluate_code(
    self,
    runtime: "capo_appsync.types.app_sync_runtime.AppSyncRuntime",
    code: "capo_appsync.types.code.Code",
    context: "capo_appsync.types.context.Context",
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
    function: Optional["capo_appsync.types.string.String"] = None,
) -> "capo_appsync.types.evaluate_code_response.EvaluateCodeResponse":
    """<p>Evaluates the given code and returns the response. The code definition requirements depend on the specified runtime. For <code>APPSYNC_JS</code> 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. </p>

    Args:
        runtime: <p>The runtime to be used when evaluating the code. Currently, only the <code>APPSYNC_JS</code> runtime is supported.</p>
        code: <p>The code definition to be evaluated. Note that <code>code</code> and <code>runtime</code> are both required for this action. The <code>runtime</code> value must be <code>APPSYNC_JS</code>.</p>
        context: <p>The map that holds all of the contextual information for your resolver invocation. A <code>context</code> is required for this action.</p>
        function: <p>The function within the code to be evaluated. If provided, the valid values are <code>request</code> and <code>response</code>.</p>

    Raises:
        capo_appsync.errors.access_denied_exception.AccessDeniedException: <p>You don't have access to perform this operation on this resource.</p>
        capo_appsync.errors.bad_request_exception.BadRequestException: <p>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.</p>
        capo_appsync.errors.internal_failure_exception.InternalFailureException: <p>An internal AppSync error occurred. Try your request again.</p>
        capo_appsync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_appsync.types.evaluate_code_request.EvaluateCodeRequest]",
    ) -> AsyncOperationResponse[
        "capo_appsync.types.evaluate_code_response.EvaluateCodeResponse"
    ]:
        import capo_appsync._operations.aws_deepdish_control_plane_service.evaluate_code

        (
            output,
            http_response,
        ) = await capo_appsync._operations.aws_deepdish_control_plane_service.evaluate_code.async_evaluate_code(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("EvaluateCode")
    )
    input_: capo_appsync.types.evaluate_code_request.EvaluateCodeRequest = {
        "runtime": runtime,
        "code": code,
        "context": context,
    }
    if function is not None:
        input_["function"] = function

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output