
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@intellihr/serverless-appsync-plugin
Advanced tools
Tired of 🚀 deploying, ✏️ updating, and ❌ deleting your AppSync API's using the AWS AppSync dashboard? You can now develop all of your AppSync API's locally using Serverless + Serverless-AppSync-Plugin! With support for AWS DynamoDB, AWS Lambda, and AWS Elastic Search; you have everything you need to get started developing your AppSync API's locally.
Part 1: Running a scalable & reliable GraphQL endpoint with Serverless
AWS Mobile Blog How to deploy a GraphQL API on AWS using the Serverless Framework

Be sure to check out all that AWS AppSync has to offer. Here are a few resources to help you understand everything needed to get started!
Install the plugin via Yarn (recommended)
yarn add serverless-appsync-plugin
or via NPM
npm install serverless-appsync-plugin
Add serverless-appsync-plugin to the plugins section of serverless.yml
plugins:
- serverless-appsync-plugin
Add the following example config to the custom section of serverless.yml
custom:
appSync:
name: # defaults to api
# apiKey # only required for update-appsync/delete-appsync
authenticationType: API_KEY or AWS_IAM or AMAZON_COGNITO_USER_POOLS or OPENID_CONNECT
# if AMAZON_COGNITO_USER_POOLS
userPoolConfig:
awsRegion: # required # region
defaultAction: # ALLOW
userPoolId: # required # user pool ID
appIdClientRegex: # optional
region: # defaults to provider region
# if OPENID_CONNECT
openIdConnectConfig:
issuer:
clientId:
iatTTL:
authTTL:
logConfig:
loggingRoleArn: { Fn::GetAtt: [AppSyncLoggingServiceRole, Arn] } # Where AppSyncLoggingServiceRole is a role with CloudWatch Logs write access
level: ERROR # Logging Level: NONE | ERROR | ALL
mappingTemplatesLocation: # defaults to mapping-templates
mappingTemplates:
- dataSource: # data source name
type: # type name in schema (e.g. Query, Mutation, Subscription)
field: getUserInfo
request: # request mapping template name
response: # response mapping template name
schema: # defaults schema.graphql
dataSources:
- type: AMAZON_DYNAMODB
name: # data source name
description: # DynamoDB Table Description
config:
tableName: { Ref: MyTable } # Where MyTable is a dynamodb table defined in Resources
serviceRoleArn: { Fn::GetAtt: [AppSyncDynamoDBServiceRole, Arn] } # Where AppSyncDynamoDBServiceRole is an IAM role defined in Resources
iamRoleStatements: # custom IAM Role statements for this DataSource. Ignored if `serviceRoleArn` is present. Auto-generated if both `serviceRoleArn` and `iamRoleStatements` are omitted
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
Resource:
- "arn:aws:dynamodb:{REGION}:{ACCOUNT_ID}:myTable"
- "arn:aws:dynamodb:{REGION}:{ACCOUNT_ID}:myTable/*"
region: # Overwrite default region for this data source
- type: AMAZON_ELASTICSEARCH
name: # data source name
description: 'ElasticSearch'
config:
endpoint: # required # "https://{DOMAIN}.{REGION}.es.amazonaws.com"
serviceRoleArn: { Fn::GetAtt: [AppSyncESServiceRole, Arn] } # Where AppSyncESServiceRole is an IAM role defined in Resources
iamRoleStatements: # custom IAM Role statements for this DataSource. Ignored if `serviceRoleArn` is present. Auto-generated if both `serviceRoleArn` and `iamRoleStatements` are omitted
- Effect: "Allow"
Action:
- "es:ESHttpGet"
Resource:
- "arn:aws:es:{REGION}:{ACCOUNT_ID}:{DOMAIN}"
- type: AWS_LAMBDA
name: # data source name
description: 'Lambda DataSource'
config:
lambdaFunctionArn: { Fn::GetAtt: [GraphqlLambdaFunction, Arn] } # Where GraphqlLambdaFunction is the lambda function cloudformation resource created by serverless for the serverless function named graphql
serviceRoleArn: { Fn::GetAtt: [AppSyncLambdaServiceRole, Arn] } # Where AppSyncLambdaServiceRole is an IAM role defined in Resources
iamRoleStatements: # custom IAM Role statements for this DataSource. Ignored if `serviceRoleArn` is present. Auto-generated if both `serviceRoleArn` and `iamRoleStatements` are omitted
- Effect: "Allow"
Action:
- "lambda:invokeFunction"
Resource:
- "arn:aws:lambda:{REGION}:{ACCOUNT_ID}:myFunction"
- "arn:aws:lambda:{REGION}:{ACCOUNT_ID}:myFunction:*"
- type: HTTP
name: # data source name
description: 'Http endpoint'
config:
endpoint: # required # "https://{DOMAIN}/{PATH}"
substitutions: # allows to pass variables from here to velocity templates
# ${exampleVar1} will be replaced with given value in all mapping templates
exampleVar1: "${self:service.name}"
exampleVar2: {'Fn::ImportValue': 'Some-external-stuff'}
Be sure to replace all variables that have been commented out, or have an empty value.
serverless deployThis command will deploy all AppSync resources in the same CloudFormation template used by the other serverless resources.
serverless graphql-playgroundThis command will start a local graphql-playground server which is connected to your AppSync endpoint. The required options for the command are different depending on your AppSync authenticationType.
For API_KEY, either the GraphQLApiKeyDefault output or the --apiKey option is required
For AMAZON_COGNITO_USER_POOLS, the -u/--username and -p/--password arguments are required. The cognito user pool client id can be provided with the --clientId option or directly in the yaml file (custom.appSync.userPoolConfig.playgroundClientId)
For OPENID_CONNECT, the --jwtToken option is required.
The AWS_IAM authenticationType is not currently supported.
endpoint option in serverless.yml before deploying.You can use serverless-appsync-offline to autostart an AppSync Emulator which depends on Serverless-AppSync-Plugin with DynamoDB and Lambda resolver support:
npm install --save serverless-appsync-offline
custom:
appsync-offline:
port: 62222
dynamodb:
server:
port: 8000
If you use serverless-offline:
sls offline start
otherwise:
sls appsync-offline start
the result is:
Serverless: dynamoDB started: http://localhost:8000/
Serverless: AppSync started: http://localhost:62222/graphql
Go to serverless-appsync-offline to get further configuration options.
If you have any questions, please feel free to reach out to me directly on Twitter Sid Gupta.
If you have previously used versions of this plugin prior to 1.0, you will need
to perform some additional manual steps in order to continue use of this
plugin (it will be worth it). This change removes the sls *-appsync
commands in favor of adding AppSync resources directly to the serverless
cloudformation stack. What this means for your existing APIs is that
they can no longer be updated. The good news is that you will
no longer need to use separate commands to deploy vs update and update
your serverless config with the created apiId.
The rough steps for migration are as follows:
sls deploy to create the new AppSync api and make note
of the endpoint returned as part of the stack outputs. If you were
using an API_KEY auth type, you will also need the new api key which
is also included in the stack outputs.sls delete-appsync
to cleanup the old resourcesapiId line from custom.appSync in serverless.ymlBig Thanks to Nik Graf, Philipp Müns, Jon Patel and my favourite coolest kat ever for helping to build this plugin!
We are always looking for open source contributions. So, feel free to create issues/contribute to this repo.
FAQs
AWS AppSync support for the Serverless Framework
The npm package @intellihr/serverless-appsync-plugin receives a total of 22 weekly downloads. As such, @intellihr/serverless-appsync-plugin popularity was classified as not popular.
We found that @intellihr/serverless-appsync-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.