Skip to content

evaluate_mapping_template async

evaluate_mapping_template(
    template: Template,
    context: Context,
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
) -> EvaluateMappingTemplateResponse

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

Parameters:

  • template (Template) –

    The mapping template; this can be a request or response template. A template is required for this action.

  • context (Context) –

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

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_mapping_template(
    self,
    template: "capo_appsync.types.template.Template",
    context: "capo_appsync.types.context.Context",
    *,
    config_overrides: Optional[AsyncAppSyncClientConfig] = None,
) -> "capo_appsync.types.evaluate_mapping_template_response.EvaluateMappingTemplateResponse":
    """<p>Evaluates a given template and returns the response. The mapping template can be a request or response template.</p> <p>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.</p> <p>Mapping templates are written in the Apache Velocity Template Language (VTL).</p>

    Args:
        template: <p>The mapping template; this can be a request or response template. A <code>template</code> is required for this action.</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>

    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_mapping_template_request.EvaluateMappingTemplateRequest]",
    ) -> AsyncOperationResponse[
        "capo_appsync.types.evaluate_mapping_template_response.EvaluateMappingTemplateResponse"
    ]:
        import capo_appsync._operations.aws_deepdish_control_plane_service.evaluate_mapping_template

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("EvaluateMappingTemplate")
    )
    input_: capo_appsync.types.evaluate_mapping_template_request.EvaluateMappingTemplateRequest = {
        "template": template,
        "context": context,
    }

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