Skip to content

Latest commit

 

History

History
366 lines (203 loc) · 16.3 KB

API.md

File metadata and controls

366 lines (203 loc) · 16.3 KB

API Reference

Classes

Name Description
AppSyncTransformer AppSyncTransformer Construct.

Structs

Name Description
AppSyncTransformerProps No description
CdkTransformerFunctionResolver No description
CdkTransformerGlobalSecondaryIndex No description
CdkTransformerHttpResolver No description
CdkTransformerLocalSecondaryIndex No description
CdkTransformerResolver No description
CdkTransformerTable No description
CdkTransformerTableKey No description
CdkTransformerTableTtl No description
DynamoDBStreamProps No description
OverrideResolverProps No description
SchemaTransformerOutputs No description

class AppSyncTransformer 🔹

AppSyncTransformer Construct.

Implements: IConstruct, IConstruct, IConstruct, IDependable Extends: Construct

Initializer

new AppSyncTransformer(scope: Construct, id: string, props: AppSyncTransformerProps)
  • scope (Construct) No description
  • id (string) No description
  • props (AppSyncTransformerProps) No description
    • schemaPath (string) Relative path where schema.graphql exists.
    • apiName (string) String value representing the api name. Default: ${id}-api
    • authorizationConfig (AuthorizationConfig) Optional. Default: API_KEY authorization config
    • customVtlTransformerRootDirectory (string) The root directory to use for finding custom resolvers. Default: process.cwd()
    • dynamoDbStreamConfig (Map<string, StreamViewType>) A map of @model type names to stream view type e.g { Blog: StreamViewType.NEW_IMAGE }. Optional
    • enableDynamoPointInTimeRecovery (boolean) Whether to enable dynamo Point In Time Recovery. Default: false
    • fieldLogLevel (FieldLogLevel) Optional. Default: FieldLogLevel.NONE
    • nestedStackName (string) Specify a custom nested stack name. Default: "appsync-nested-stack"
    • outputPath (string) Path where generated resolvers are output. Default: "./appsync"
    • postCdkTransformers (Array) Optional. Default: undefined
    • preCdkTransformers (Array) Optional. Default: undefined
    • syncEnabled (boolean) Whether to enable Amplify DataStore and Sync Tables. Default: false
    • tableNames (Map<string, string>) A map of names to specify the generated dynamo table names instead of auto generated names. Default: undefined
    • xrayEnabled (boolean) Determines whether xray should be enabled on the AppSync API. Default: false

Properties

Name Type Description
appsyncAPI🔹 GraphqlApi The cdk GraphqlApi construct.
functionResolvers🔹 Map<string, Array<CdkTransformerFunctionResolver>> The Lambda Function resolvers designated by the function directive https://github.com/kcwinner/cdk-appsync-transformer#functions.
httpResolvers🔹 Map<string, Array<CdkTransformerHttpResolver>>
nestedAppsyncStack🔹 NestedStack The NestedStack that contains the AppSync resources.
outputs🔹 SchemaTransformerOutputs The outputs from the SchemaTransformer.
resolvers🔹 Map<string, CdkTransformerResolver> The AppSync resolvers from the transformer minus any function resolvers.
tableMap🔹 Map<string, Table> Map of cdk table keys to L2 Table e.g. { 'TaskTable': Table }.
tableNameMap🔹 Map<string, string> Map of cdk table tokens to table names.

Methods

addDynamoDBStream(props)🔹

Adds a stream to the dynamodb table associated with the type.

addDynamoDBStream(props: DynamoDBStreamProps): string
  • props (DynamoDBStreamProps) No description
    • modelTypeName (string) The @model type name from the graph schema e.g. Blog.
    • streamViewType (StreamViewType) No description

Returns:

  • string

addLambdaDataSourceAndResolvers(functionName, id, lambdaFunction, options?)🔹

Adds the function as a lambdaDataSource to the AppSync api Adds all of the functions resolvers to the AppSync api.

addLambdaDataSourceAndResolvers(functionName: string, id: string, lambdaFunction: IFunction, options?: DataSourceOptions): LambdaDataSource
  • functionName (string) The function name specified in the.
  • id (string) The id to give.
  • lambdaFunction (IFunction) The lambda function to attach.
  • options (DataSourceOptions) No description
    • description (string) The description of the data source. Default: No description
    • name (string) The name of the data source, overrides the id given by cdk. Default: generated by cdk given the id

Returns:

grantPrivate(grantee)🔹

Adds an IAM policy statement granting access to the private fields of the AppSync API.

Policy is based off of the @auth transformer https://docs.amplify.aws/cli/graphql-transformer/auth

grantPrivate(grantee: IGrantable): Grant

Returns:

grantPublic(grantee)🔹

Adds an IAM policy statement granting access to the public fields of the AppSync API.

Policy is based off of the @auth transformer https://docs.amplify.aws/cli/graphql-transformer/auth

grantPublic(grantee: IGrantable): Grant
  • grantee (IGrantable) The principal to grant access to.

Returns:

overrideResolver(props)🔹

Allows for overriding the generated request and response mapping templates.

overrideResolver(props: OverrideResolverProps): void
  • props (OverrideResolverProps) No description
    • fieldName (string) The fieldname to override e.g. listThings, createStuff.
    • typeName (string) Example: Query, Mutation, Subscription For a GSI this might be Post, Comment, etc.
    • requestMappingTemplateFile (string) The full path to the request mapping template file. Optional
    • responseMappingTemplateFile (string) The full path to the resposne mapping template file. Optional

struct AppSyncTransformerProps 🔹

Name Type Description
schemaPath🔹 string Relative path where schema.graphql exists.
apiName?🔹 string String value representing the api name.
Default: ${id}-api
authorizationConfig?🔹 AuthorizationConfig Optional.
Default: API_KEY authorization config
customVtlTransformerRootDirectory?🔹 string The root directory to use for finding custom resolvers.
Default: process.cwd()
dynamoDbStreamConfig?🔹 Map<string, StreamViewType> A map of @model type names to stream view type e.g { Blog: StreamViewType.NEW_IMAGE }.
Optional
enableDynamoPointInTimeRecovery?🔹 boolean Whether to enable dynamo Point In Time Recovery.
Default: false
fieldLogLevel?🔹 FieldLogLevel Optional.
Default: FieldLogLevel.NONE
nestedStackName?🔹 string Specify a custom nested stack name.
Default: "appsync-nested-stack"
outputPath?🔹 string Path where generated resolvers are output.
Default: "./appsync"
postCdkTransformers?🔹 Array Optional.
Default: undefined
preCdkTransformers?🔹 Array Optional.
Default: undefined
syncEnabled?🔹 boolean Whether to enable Amplify DataStore and Sync Tables.
Default: false
tableNames?🔹 Map<string, string> A map of names to specify the generated dynamo table names instead of auto generated names.
Default: undefined
xrayEnabled?🔹 boolean Determines whether xray should be enabled on the AppSync API.
Default: false

struct CdkTransformerFunctionResolver 🔹

Name Type Description
defaultRequestMappingTemplate🔹 string
defaultResponseMappingTemplate🔹 string
fieldName🔹 string
typeName🔹 string

struct CdkTransformerGlobalSecondaryIndex 🔹

Name Type Description
indexName🔹 string
partitionKey🔹 CdkTransformerTableKey
projection🔹 any
sortKey🔹 CdkTransformerTableKey

struct CdkTransformerHttpResolver 🔹

Name Type Description
defaultRequestMappingTemplate🔹 string
defaultResponseMappingTemplate🔹 string
fieldName🔹 string
httpConfig🔹 any
typeName🔹 string

struct CdkTransformerLocalSecondaryIndex 🔹

Name Type Description
indexName🔹 string
projection🔹 any
sortKey🔹 CdkTransformerTableKey

struct CdkTransformerResolver 🔹

Name Type Description
fieldName🔹 string
typeName🔹 string

struct CdkTransformerTable 🔹

Name Type Description
globalSecondaryIndexes🔹 Array<CdkTransformerGlobalSecondaryIndex>
gsiResolvers🔹 Array
localSecondaryIndexes🔹 Array<CdkTransformerLocalSecondaryIndex>
partitionKey🔹 CdkTransformerTableKey
resolvers🔹 Array
tableName🔹 string
sortKey?🔹 CdkTransformerTableKey Optional
ttl?🔹 CdkTransformerTableTtl Optional

struct CdkTransformerTableKey 🔹

Name Type Description
name🔹 string
type🔹 string

struct CdkTransformerTableTtl 🔹

Name Type Description
attributeName🔹 string
enabled🔹 boolean

struct DynamoDBStreamProps 🔹

Name Type Description
modelTypeName🔹 string The @model type name from the graph schema e.g. Blog.
streamViewType🔹 StreamViewType

struct OverrideResolverProps 🔹

Name Type Description
fieldName🔹 string The fieldname to override e.g. listThings, createStuff.
typeName🔹 string Example: Query, Mutation, Subscription For a GSI this might be Post, Comment, etc.
requestMappingTemplateFile?🔹 string The full path to the request mapping template file.
Optional
responseMappingTemplateFile?🔹 string The full path to the resposne mapping template file.
Optional

struct SchemaTransformerOutputs 🔹

Name Type Description
cdkTables?🔹 Map<string, CdkTransformerTable> Optional
functionResolvers?🔹 Map<string, Array<CdkTransformerFunctionResolver>> Optional
httpResolvers?🔹 Map<string, Array<CdkTransformerHttpResolver>> Optional
mutations?🔹 Map<string, CdkTransformerResolver> Optional
noneResolvers?🔹 Map<string, CdkTransformerResolver> Optional
queries?🔹 Map<string, string> Optional
subscriptions?🔹 Map<string, CdkTransformerResolver> Optional