Giter Club home page Giter Club logo

wali-api's Introduction

banner

Serverless GraphQL API using Lambda and DynamoDB

serverless workflow

GraphQL Lambda Server using apollo-server-lambda from Apollo.

graphql-tools and merge-graphql-schemas are used to generate the schema.

serverless-webpack is used to transform ES6 with Babel and build the lambda.

Setup

  1. Run npm install -g serverless to install serverless globally if you haven't already and follow the instructions here to configure the CLI.

  2. Initialize a new project from this template:

serverless install --url https://github.com/hustlelikeaboss/serverless-graphql-api
cd serverless-graphql-api
npm ci

Deploy

Run serverless package to preview the stacks to be created.

  1. First time deployment:
# deploy to dev by default
npm run deploy
# deploy to production
npm run deploy --stage production

This will create the Lambda Function and API Gateway for GraphQL, together with two DynamoDB tables named artists and songs.Note the API endpoint down for use with the GrapiQL app below, which should be something like this: https://[YOUR_LAMBDA_ID].execute-api.us-east-1.amazonaws.com/dev/graphql. You can always find

  1. Run the same command above after infrastructure changes made to serverless.yml.
  2. Run the script below to quickly upload code changes:
serverless deploy function -f graphql

Other useful scripts:

# invoke lambda function locally
serverless invoke local --function graphql --path lib/event.json

# invoke deployed lambda function directly
serverless invoke --function graphql --path lib/event.json

# remove deployed stack
serverless remove

Queries and Mutations

Query the GraphQL server using the GraphiQL.app. If you have Homebrew installed on OSX run

brew cask install graphiql

wali-api's People

Contributors

hustlelikeaboss avatar

Watchers

 avatar

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.