Skip to main content

functions

Creates, updates, deletes, gets or lists a functions resource.

Overview

Namefunctions
TypeResource
Idaws.appsync.functions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe name of the Function object. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>)
codestringThe function code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS.
data_source_namestringThe name of the DataSource. (pattern: <code>[_A-Za-z][_0-9A-Za-z]*</code>)
descriptionstringThe Function description.
function_arnstringThe Amazon Resource Name (ARN) of the Function object.
function_idstringA unique ID representing the Function object.
function_versionstringThe version of the request mapping template. Currently, only the 2018-05-29 version of the template is supported.
max_batch_sizeintegerThe maximum batching size for a resolver.
request_mapping_templatestringThe Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template. (pattern: <code>^.*$</code>)
response_mapping_templatestringThe Function response mapping template. (pattern: <code>^.*$</code>)
runtimeobjectDescribes a runtime used by an Amazon Web Services AppSync pipeline resolver or Amazon Web Services AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified.
sync_configobjectDescribes a Sync configuration for a resolver. Specifies which Conflict Detection strategy and Resolution strategy to use when the resolver is invoked.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_functionselectapi_id, function_id, regionGet a Function.
list_functionsselectapi_id, regionnextToken, maxResultsList multiple functions.
create_functioninsertapi_id, region, name, dataSourceNameCreates a Function object. A function is a reusable entity. You can use multiple functions to compose the resolver logic.
update_functionupdateapi_id, function_id, region, name, dataSourceNameUpdates a Function object.
delete_functiondeleteapi_id, function_id, regionDeletes a Function.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_idstringThe GraphQL API ID.
function_idstringThe Function ID.
regionstringAWS region (default: us-east-1)
maxResultsintegerThe maximum number of results that you want the request to return.
nextTokenstringAn identifier that was returned from the previous call to this operation, which you can use to return the next set of items in the list.

SELECT examples

Get a Function.

SELECT
name,
code,
data_source_name,
description,
function_arn,
function_id,
function_version,
max_batch_size,
request_mapping_template,
response_mapping_template,
runtime,
sync_config
FROM aws.appsync.functions
WHERE api_id = '{{ api_id }}' -- required
AND function_id = '{{ function_id }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Creates a Function object. A function is a reusable entity. You can use multiple functions to compose the resolver logic.

INSERT INTO aws.appsync.functions (
name,
description,
dataSourceName,
requestMappingTemplate,
responseMappingTemplate,
functionVersion,
syncConfig,
maxBatchSize,
runtime,
code,
api_id,
region
)
SELECT
'{{ name }}' /* required */,
'{{ description }}',
'{{ dataSourceName }}' /* required */,
'{{ requestMappingTemplate }}',
'{{ responseMappingTemplate }}',
'{{ functionVersion }}',
'{{ syncConfig }}',
{{ maxBatchSize }},
'{{ runtime }}',
'{{ code }}',
'{{ api_id }}',
'{{ region }}'
RETURNING
function_configuration
;

UPDATE examples

Updates a Function object.

UPDATE aws.appsync.functions
SET
name = '{{ name }}',
description = '{{ description }}',
dataSourceName = '{{ dataSourceName }}',
requestMappingTemplate = '{{ requestMappingTemplate }}',
responseMappingTemplate = '{{ responseMappingTemplate }}',
functionVersion = '{{ functionVersion }}',
syncConfig = '{{ syncConfig }}',
maxBatchSize = {{ maxBatchSize }},
runtime = '{{ runtime }}',
code = '{{ code }}'
WHERE
api_id = '{{ api_id }}' --required
AND function_id = '{{ function_id }}' --required
AND region = '{{ region }}' --required
AND name = '{{ name }}' --required
AND dataSourceName = '{{ dataSourceName }}' --required
RETURNING
function_configuration;

DELETE examples

Deletes a Function.

DELETE FROM aws.appsync.functions
WHERE api_id = '{{ api_id }}' --required
AND function_id = '{{ function_id }}' --required
AND region = '{{ region }}' --required
;