Git Product home page Git Product logo

serverless-appsync-lambda-httpresource-example's Introduction

serverless-appsync-lambda-httpresource-example CircleCI

This sample repository shows how to setup AWS AppSync that exposes two GraphQL queries:

  • getWeatherWithHTTPResource which gets weather information from https://wttr.in using a HTTP Resource
  • getWeatherWithLambda which gets weather information from https://wtter.in using a Lambda which then executes the request

This repository also shows different ways of testing a AWS AppSync:

  • At unit level for the lambda handler defined
  • At the mapping template level, by testing directly the VTL defined maps with @conduitvc/appsync-emulator-serverless/vtl
  • At AppSync level using the helper createAppSync available in @conduitvc/appsync-emulator-serverless/jest

Notes:

  • Created dynamodb-local.js to start DynamoDB locally before we run the tests so the tests don't timeout since DynamoDB takes a while to start for the first time
  • Created jest-utils to provide utils for testing the VTL files, loadVTL which will load the VTL file and renderVTL which will try to render the VTL provided with the function vtl available ij @conduitvc/appsync-emulator-serverless/vtl

Tech stack

Serverless

https://serverless.com/

The Serverless Framework is an open-source CLI for building and deploying serverless applications. With over 6 million deployments handled, the Serverless Framework is the tool developers trust to build cloud applications.

Build Setup

Using Docker

# Build Dockerfile
$ yarn docker:build

# graphql will run on http://localhost:62222/graphql
$ yarn docker:dev

# Running tests
$ yarn docker:test

# Running tests with watch
$ yarn docker:test:dev

Running locally

# install dependencies
$ yarn

# graphql will run on http://localhost:62222/graphql
$ yarn run dev

Testing

curl 'http://localhost:62222/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://localhost:3001' -H 'x-api-key: ABC123' --data-binary '{"query":"{ getWeatherWithHTTPResource }"}' --compressed
curl 'http://localhost:62222/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://localhost:3001' -H 'x-api-key: ABC123' --data-binary '{"query":"{ getWeatherWithLambda }"}' --compressed

serverless-appsync-lambda-httpresource-example's People

Contributors

davidpicarra avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

diegofleitas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.