0.20.4 • Published 4 months ago

@ttoss/appsync-api v0.20.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@ttoss/appsync-api

This package provides a opinionated way to create an AppSync API using @ttoss/graphql-api API.

Installation

pnpm add @ttoss/appsync-api @ttoss/graphql-api graphql

Getting Started

You can create and deploy an AppSync API in four steps:

  1. Create a schemaComposer object using graphql-compose, that the next steps will use to create the API.

  2. Create a cloudformation.ts file that exports a CloudFormation template using createApiTemplate:

import { createApiTemplate } from '@ttoss/appsync-api';
import { schemaComposer } from './schemaComposer';

const template = createApiTemplate({
  schemaComposer,
  dataSource: {
    roleArn: {
      'Fn::ImportValue': 'AppSyncLambdaDataSourceIAMRoleArn',
    },
  },
  lambdaFunction: {
    roleArn: {
      'Fn::ImportValue': 'AppSyncLambdaFunctionIAMRoleArn',
    },
  },
});

export default template;
  1. Create a lambda.ts file that exports a Lambda handler function using createAppSyncResolverHandler:
import { createAppSyncResolverHandler } from '@ttoss/appsync-api';
import { schemaComposer } from './schemaComposer';

export const handler = createAppSyncResolverHandler({ schemaComposer });
  1. Add graphql to the lambdaExternals array on carlin.yml:
lambdaExternals:
  - graphql

Now you can deploy your API using carlin deploy:

carlin deploy

API

Resolvers Context

The createAppSyncResolverHandler function adds the context object to the resolvers. This object contains the following properties:

Custom domain name

You can add a custom domain name to your API using the customDomain option.

import { createApiTemplate } from '@ttoss/appsync-api';

export const handler = createApiTemplate({
  schemaComposer,
  customDomain: {
    domainName: 'api.example.com', // required
    certificateArn: {
      'Fn::ImportValue': 'AppSyncDomainCertificateArn',
    }, // required
  },
});

If your domain is on Route53, you can use the option customDomain.hostedZoneName to create the required DNS records.

import { createApiTemplate } from '@ttoss/appsync-api';

export const template = createApiTemplate({
  schemaComposer,
  customDomain: {
    domainName: 'api.example.com', // required
    certificateArn: {
      'Fn::ImportValue': 'AppSyncDomainCertificateArn',
    }, // required
    hostedZoneName: 'example.com.', // optional
  },
});
0.20.4

4 months ago

0.20.3

6 months ago

0.20.1

6 months ago

0.20.0

6 months ago

0.19.2

6 months ago

0.20.2

6 months ago

0.19.1

7 months ago

0.19.0

7 months ago

0.18.36

8 months ago

0.18.33

10 months ago

0.18.35

9 months ago

0.18.34

10 months ago

0.18.32

10 months ago

0.18.31

11 months ago

0.18.30

11 months ago

0.18.28

11 months ago

0.18.29

11 months ago

0.18.27

11 months ago

0.18.24

1 year ago

0.18.23

1 year ago

0.18.26

1 year ago

0.18.25

1 year ago

0.18.22

1 year ago

0.18.21

1 year ago

0.18.19

1 year ago

0.18.20

1 year ago

0.18.18

1 year ago

0.18.17

1 year ago

0.18.16

1 year ago

0.18.15

1 year ago

0.18.14

1 year ago

0.18.13

1 year ago

0.18.11

1 year ago

0.18.12

1 year ago

0.18.10

1 year ago

0.18.9

1 year ago

0.18.8

1 year ago

0.18.7

1 year ago

0.18.6

1 year ago

0.18.5

1 year ago

0.18.4

1 year ago

0.18.2

1 year ago

0.18.3

1 year ago

0.18.1

1 year ago

0.18.0

2 years ago

0.17.12

2 years ago

0.17.11

2 years ago

0.17.10

2 years ago

0.17.9

2 years ago

0.17.6

2 years ago

0.17.7

2 years ago

0.17.8

2 years ago

0.17.2

2 years ago

0.17.3

2 years ago

0.15.5

2 years ago

0.17.4

2 years ago

0.15.6

2 years ago

0.17.5

2 years ago

0.15.7

2 years ago

0.17.1

2 years ago

0.16.0

2 years ago

0.15.4

2 years ago

0.15.3

2 years ago

0.11.1

2 years ago

0.13.0

2 years ago

0.11.2

2 years ago

0.13.1

2 years ago

0.15.0

2 years ago

0.15.1

2 years ago

0.12.0

2 years ago

0.14.0

2 years ago

0.11.0

2 years ago

0.10.14

2 years ago

0.10.10

2 years ago

0.10.11

2 years ago

0.10.12

2 years ago

0.10.13

2 years ago

0.10.9

2 years ago

0.10.1

2 years ago

0.10.2

2 years ago

0.10.3

2 years ago

0.10.4

2 years ago

0.10.5

2 years ago

0.10.6

2 years ago

0.10.7

2 years ago

0.10.8

2 years ago

0.10.0

2 years ago

0.9.1

2 years ago

0.8.4

2 years ago

0.9.0

2 years ago

0.7.5

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.7.2

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago