Coder Social home page Coder Social logo

mandyjcho / serverless-graphql-apollo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverless/serverless-graphql

1.0 1.0 0.0 8.48 MB

Serverless GraphQL Boilerplate using Apollo – Ready to be deployed to production within minutes …

Home Page: https://www.serverless.com

JavaScript 91.68% HTML 4.14% CSS 4.18%

serverless-graphql-apollo's Introduction

Serverless GraphQL

This starter kit is an opinionated set of tools combined to help you get started building a Serverless application with an GraphQL endpoint and deploy them to production in minutes.

This example uses the following technologies:

  • Frontend

    • Apollo Client
    • React
  • Backend

    • Serverless
    • AWS Lambda & AWS API Gateway
    • Apollo Lambda Server
    • Serverless Webpack
    • Serverless Offline

System Architecture

serverless application architecture v2

Setup

You need to have Node 6 or higher installed.

npm install -g serverless
npm install -g yarn

Configure your AWS keys. Here you can find a 2min walkthrough how to do retrieve the keys.

sls config credentials --provider aws --key <your_aws_access_key> --secret <your_aws_secret_key>

Install Dependencies (FrontEnd and BackEnd)

cd app-backend
yarn install
cd ../app-client
yarn install

Test Locally - Use Apollo Lambda Server

# Start Server http://localhost:4000/graphql
cd app-backend
yarn run start-server-lambda:offline

Start Client

# Start Client http://localhost:3000
cd app-client
yarn start

OR

# Start Client http://localhost:3000
cd app-backend
yarn run start-client-local

Setup for Production

Use live data from the development environment. You need to make sure you have access to your deployed lambda functions. This works only after you deployed it to production.

cd app-backend
yarn run deploy-server-lambda-prod

deploy feedback

Directory Layout

.
├── /app-client/                     # React Client with Apollo Integration
│   ├── /public/                     # front End Utils
│   │   ├── /index.html              # main html file to render react app
│   │   ├── /...                     # front end metadata
│   ├── /src/                        # react app code logic
│   │   ├── /componenets/            # react componenets
│   │   ├── /App.js                  # react application logic
│   │   ├── /index.js                # react dom render
│   │   ├── /...                     # etc.
│   ├── /package.json                # react app dependencies
├── /app-backend/                    # Server Backend with Apollo Integration
│   ├── /handler.js                  # AWS Lambda - Apollo Lambda Server
│   ├── /package.js                  # server side dependencies
│   ├── /resolvers.js                # graphql resolvers
│   ├── /schema.js                   # graphql schema
│   ├── /serverless.yaml             # Serverless yaml for AWS deployment
│   ├── /webpack.config.js           # Webpack server side code with ES6
├── /config/                         # Configuration files
│   ├── /security.env.local          # local config
│   ├── /security.env.prod           # production config

Multiple package.json

In order to keep the total amount of code uploaded to AWS Lambda small the foundation/app-server directory containing the Serverless service has it's own package.json. This speeds up uploading and also should reduce the cold start time of Lambda functions. You don't have to run yarn install manually at any point. It will only happen during deploy, but you need make sure every library you are consuming in your GraphQL endpoint is added as a dependency there.

app-client/package.json

  • dependencies: dependencies used by the front-end
  • devDependencies: dependencies used to package the front-end application & running the local environment

app-backend/package.json

  • dependencies: dependencies used on AWS Lambda

serverless-graphql-apollo's People

Contributors

andreimc avatar austencollins avatar brettstack avatar brokenglass avatar chownation avatar daviskoh avatar denneulin avatar eahefnawy avatar helfer avatar jamesmcintyre avatar kevinold avatar laardee avatar marclar avatar minibikini avatar mpigsley avatar nikgraf avatar ozbillwang avatar pmuens avatar ryansb avatar sid88in avatar stan-devproject avatar timsvoice avatar

Stargazers

 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.