0.18.22 • Published 2 days ago

@ttoss/appsync-api v0.18.22

Weekly downloads
-
License
-
Repository
github
Last release
2 days 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.18.22

2 days ago

0.18.21

2 days ago

0.18.19

4 days ago

0.18.20

4 days ago

0.18.18

6 days ago

0.18.17

8 days ago

0.18.16

8 days ago

0.18.15

18 days ago

0.18.14

18 days ago

0.18.13

22 days ago

0.18.11

26 days ago

0.18.12

25 days ago

0.18.10

1 month ago

0.18.9

1 month ago

0.18.8

1 month ago

0.18.7

1 month ago

0.18.6

2 months ago

0.18.5

3 months ago

0.18.4

3 months ago

0.18.2

4 months ago

0.18.3

4 months ago

0.18.1

4 months ago

0.18.0

5 months ago

0.17.12

5 months ago

0.17.11

5 months ago

0.17.10

5 months ago

0.17.9

6 months ago

0.17.6

6 months ago

0.17.7

6 months ago

0.17.8

6 months ago

0.17.2

8 months ago

0.17.3

7 months ago

0.15.5

10 months ago

0.17.4

7 months ago

0.15.6

10 months ago

0.17.5

6 months ago

0.15.7

9 months ago

0.17.1

8 months ago

0.16.0

9 months ago

0.15.4

11 months ago

0.15.3

12 months ago

0.11.1

1 year ago

0.13.0

1 year ago

0.11.2

1 year ago

0.13.1

12 months ago

0.15.0

12 months ago

0.15.1

12 months ago

0.12.0

1 year ago

0.14.0

12 months ago

0.11.0

1 year ago

0.10.14

1 year ago

0.10.10

1 year ago

0.10.11

1 year ago

0.10.12

1 year ago

0.10.13

1 year ago

0.10.9

1 year ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.3

1 year ago

0.10.4

1 year ago

0.10.5

1 year ago

0.10.6

1 year ago

0.10.7

1 year ago

0.10.8

1 year ago

0.10.0

1 year ago

0.9.1

1 year ago

0.8.4

1 year ago

0.9.0

1 year ago

0.7.5

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.7.2

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago