Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@dttvinh/serverless-appsync-offline
Advanced tools
Serverless AWS AppSync Offline Plugin - Allow to run AppSync locally for serverless framework
This is a wrapper for the excellent AppSync Emulator.
This plugin is updated by its users, I just do maintenance and ensure that PRs are relevant to the community. In other words, if you find a bug or want a new feature, please help us by becoming one of the contributors.
npm install --save serverless-appsync-offline
Then in serverless.yml
add following entry to the plugins array: serverless-appsync-offline
plugins:
- serverless-appsync-offline
sls appsync-offline start
All CLI options are optional:
--port -p Port to provide the graphgl api. Default: dynamic
--dynamoDbPort -d Port to access the dynamoDB. Default: dynamic
--inMemory -i DynamoDB; will run in memory, instead of using a database file. When you stop DynamoDB;, none of the data will be saved. Note that you cannot specify both -dbPath and -inMemory at once.
--dbPath -b The directory where DynamoDB will write its database file. If you do not specify this option, the file will be written to the current directory. Note that you cannot specify both -dbPath and -inMemory at once. For the path, current working directory is <projectroot>/node_modules/serverless-appsync-offline/dynamob. For example to create <projectroot>/node_modules/serverless-appsync-offline/dynamob/<mypath> you should specify -d <mypath>/ or --dbPath <mypath>/ with a forwardslash at the end.
--sharedDb -h DynamoDB will use a single database file, instead of using separate files for each credential and region. If you specify -sharedDb, all DynamoDB clients will interact with the same set of tables regardless of their region and credential configuration.
--delayTransientStatuses -t Causes DynamoDB to introduce delays for certain operations. DynamoDB can perform some tasks almost instantaneously, such as create/update/delete operations on tables and indexes; however, the actual DynamoDB service requires more time for these tasks. Setting this parameter helps DynamoDB simulate the behavior of the Amazon DynamoDB web service more closely. (Currently, this parameter introduces delays only for global secondary indexes that are in either CREATING or DELETING status.)
--optimizeDbBeforeStartup -o Optimizes the underlying database tables before starting up DynamoDB on your computer. You must also specify -dbPath when you use this parameter.
All the above options can be added to serverless.yml to set default configuration: e.g.
Minimum Options:
custom:
appsync-offline:
port: 62222
dynamodb:
server:
port: 8000
All Options:
custom:
appsync-offline:
port: 62222
dynamodb:
client:
# if endpoint is provided, no local database server is started and and appsync connects to the endpoint - e.g. serverless-dynamodb-local
endpoint: "http://localhost:8000"
region: localhost
accessKeyId: a
secretAccessKey: a
server:
port: 8000
dbPath: "./.dynamodb"
inMemory: false,
sharedDb: false,
delayTransientStatuses: false,
optimizeDbBeforeStartup: false,
How to Query:
curl -X POST \
http://localhost:62222/graphql \
-H 'Content-Type: application/json' \
-H 'x-api-key: APIKEY' \
-d '{
"query": "{ hello { world } }"
}'
Note: If you're using API_KEY
as your authenticationType, then a x-api-key
header has to be present in the request. The value of the key doesn't really matter.
You need to add the following parameters to the AWS NODE SDK dynamodb constructor
e.g. for dynamodb document client sdk
var AWS = require('aws-sdk');
new AWS.DynamoDB.DocumentClient({
region: 'localhost',
endpoint: 'http://localhost:8000'
})
e.g. for dynamodb document client sdk
new AWS.DynamoDB({
region: 'localhost',
endpoint: 'http://localhost:8000'
})
When using this plugin with serverless-offline, it is difficult to use above syntax since the code should use DynamoDB Local for development, and use DynamoDB Online after provisioning in AWS. Therefore we suggest you to use serverless-dynamodb-client plugin in your code.
The serverless appsync-offline start
command can be triggered automatically when using serverless-offline
plugin.
Add both plugins to your serverless.yml
file:
plugins:
- serverless-appsync-offline
- serverless-offline
Make sure that serverless-appsync-offline
is above serverless-offline
so it will be loaded earlier.
Now your local Appsync and the DynamoDB database will be automatically started before running serverless offline
.
SLS_DEBUG=* NODE_DEBUG=appsync-* yarn offline
or
SLS_DEBUG=* NODE_DEBUG=appsync-* yarn sls appsync-offline start
Run serverless offline start
. In comparison with serverless offline
, the start
command will fire an init
and a end
lifecycle hook which is needed for serverless-offline and serverless-appsync-offline to switch off both resources.
Add plugins to your serverless.yml
file:
plugins:
- serverless-webpack
- serverless-appsync-offline
- serverless-offline #serverless-offline needs to be last in the list
custom:
appsync-emulator:
# when using serverless-webpack it (by default) outputs all the build assets to `<projectRoot>/.webpack/service`
# this will let appsync-offline know where to find those compiled files
buildPrefix: .webpack/service
The AppSync Emulator does not support CloudFormation syntax (e.g. tableName: { Ref: UsersTable }
) in dataSources
.
FAQs
Serverless AWS AppSync Offline Plugin - Allow to run AppSync locally for serverless framework
We found that @dttvinh/serverless-appsync-offline demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.