{"id":13493477,"url":"https://github.com/serverless/serverless-graphql","last_synced_at":"2025-04-06T11:07:08.153Z","repository":{"id":7056309,"uuid":"52542345","full_name":"serverless/serverless-graphql","owner":"serverless","description":"Serverless GraphQL Examples for AWS AppSync and Apollo","archived":false,"fork":false,"pushed_at":"2023-01-11T00:53:52.000Z","size":11846,"stargazers_count":2715,"open_issues_count":201,"forks_count":362,"subscribers_count":100,"default_branch":"master","last_synced_at":"2024-06-26T04:57:26.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.serverless.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-25T17:10:04.000Z","updated_at":"2024-06-25T17:16:11.000Z","dependencies_parsed_at":"2023-01-13T15:30:36.055Z","dependency_job_id":null,"html_url":"https://github.com/serverless/serverless-graphql","commit_stats":null,"previous_names":["serverless/serverless-app","serverless/boilerplate-graphql","serverless/serverless-boilerplate","serverless/serverless-graphql-apollo"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/serverless-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471517,"owners_count":20944158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:15.634Z","updated_at":"2025-04-06T11:07:08.132Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"**📦 Archived - This repository is archived and preserved for reference only. No updates, issues, or pull requests will be accepted. If you have questions, please reach out to our support team.**\n\n---\n\n# Introduction\n\n\u003e *Part 1:* [Running a scalable \u0026 reliable GraphQL endpoint with Serverless](https://serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless/)  \n\u003e *Part 2:* [AppSync Backend: AWS Managed GraphQL Service](https://medium.com/@sid88in/running-a-scalable-reliable-graphql-endpoint-with-serverless-24c3bb5acb43)  \n\u003e *Part 3:* [AppSync Frontend: AWS Managed GraphQL Service](https://hackernoon.com/running-a-scalable-reliable-graphql-endpoint-with-serverless-db16e42dc266)  \n\n# Serverless GraphQL\n\nThis starter kit is an opinionated set of tools combined to help you get started building a Serverless application with a GraphQL endpoint and deploy them to production in minutes.\n\nThis example uses the following technologies:\n\n- Frontend\n  - [AWSAppSyncClient](http://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-react.html)\n  - [Apollo Client 2.0](https://github.com/apollographql/apollo-client)\n  - [React App](https://github.com/facebookincubator/create-react-app)\n  - [GraphiQL](https://github.com/graphql/graphiql)\n  - [GraphQL Playground (GraphiQL replacement)](https://github.com/graphcool/graphql-playground)\n  - [Netlify Integration](https://www.netlify.com/)\n\n- Backend\n  - [Serverless](https://serverless.com/framework/docs/)\n  - [AWS AppSync](https://aws.amazon.com/appsync/) DynamoDB, Elasticsearch and Lambda Integrations\n  - [AWS Lambda](https://aws.amazon.com/lambda/) \u0026 [AWS API Gateway](https://aws.amazon.com/documentation/apigateway/)\n  - [Apollo Server Lambda 2.0](https://www.npmjs.com/package/apollo-server-lambda)\n  - [DynamoDB](https://aws.amazon.com/dynamodb/)\n  - [RDS (MySQL, PostGres and Aurora)](https://aws.amazon.com/rds/)\n  - [REST API](https://developer.twitter.com/en/docs)\n  - Plugins\n      - [Serverless Appsync Plugin](https://github.com/sid88in/serverless-appsync-plugin)\n      - [Serverless Webpack](https://github.com/serverless-heaven/serverless-webpack)\n      - [Serverless Offline](https://github.com/dherault/serverless-offline)\n      - [Serverless DynamoDB Local](https://github.com/99xt/serverless-dynamodb-local)\n      - [Serverless DynamoDB Client](https://www.npmjs.com/package/serverless-dynamodb-client)\n      - [Serverless Finch](https://www.npmjs.com/package/serverless-finch)\n\n- Other Utilities and Integrations\n    - [Faker](https://www.npmjs.com/package/faker)\n    - [Prettier](https://github.com/prettier/prettier)\n    - [Apollo Tracing](https://github.com/apollographql/apollo-tracing)\n\n## System Architecture\n\n![serverless application architecture v2](https://user-images.githubusercontent.com/1587005/36063546-21c3a540-0e33-11e8-9fa4-1a1e5e9a6537.png)\n\n## Quick Setup\n\nYou need to have Node 6 or higher installed.\n\n```\nnpm install -g serverless\nnpm install -g yarn\nnpm install -g netlify-cli\n```\n\nInstall Dependencies.\n```\nyarn install\n```\n\n## Feature Support in this repository\n\n![feature-support](/feature-support.png)\n\n## Quick Start (Serverless Offline)\nPlease note: [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) is required to be installed on your system\n\n1. **Select Backend** \n\n- *AWS Appsync* (Serverless Offline does not support Appsync at this point)\n\n    - AWS DynamoDB\n    - AWS ElasticSearch\n    - AWS Lambda\n\n- *Lambda Backend* (Serverless Offline Supported)\n    \n    - *Twitter Rest API*\n        ```\n        cd app-backend/rest-api\n        yarn start\n        ```\n\n    *Generate your Consumer Key and Secret Key for a [Twitter App](https://developer.twitter.com/en/docs/basics/developer-portal/guides/apps) and update [config](/config/security.env.local)*\n\n    - *DynamoDB*\n        ```\n        cd app-backend/dynamodb\n        yarn start\n        ```\n\n    - *RDS*\n        ```\n        cd app-backend/rds\n        yarn start\n        ```\n\n2. **Start FrontEnd** (Apollo Client or Appsync Client)\n\n- For Appsync Backend please select Appsync Client Integration:\n\n    ```\n    cd app-client/appsync-client/\n    yarn start\n    ```\n\n- For Lambda Backend please select Apollo Client Integration:\n\n    ```\n    cd app-client/apollo-client/\n    yarn start\n    ```\n\nAlso, please make sure GraphQL endpoint is configured correctly in config/security.env.local to run client on local.\n\n3. **Start GraphiQL**\n```\nhttp://localhost:4000/graphiql\n```\n\n4. **Start GraphQL Playground (GraphiQL replacement - coming soon)**\n```\nhttp://localhost:4000/playground\n```\n*`rest-api` and `dynamodb` backends route GET and POST to the same `/graphql` endpoint handler*\n```\nhttp://localhost:4000/graphql\n```\n\n5. **Sample Query for GraphiQL, Playground or GraphQL**\n```\n{\n  getUserInfo(handle: \"Madalyn61\") {\n    name\n    tweets {\n      items {\n        retweeted\n        retweet_count\n        favorited\n        tweet\n      }\n    }\n    topTweet {\n      retweeted\n      retweet_count\n      favorited\n    }\n  }\n}\n```\n\nIf you've followed me this far, DynamoDB will now be available and running on your local machine at `http://localhost:8000/shell`:\n\n![!Live Example](https://user-images.githubusercontent.com/1587005/36065162-b4ad3c14-0e4b-11e8-8776-e19596546ce1.gif)\n\n\n## Setup for Production (Deploy resources to AWS)\n\nConfigure your AWS keys. Here you can find a [2min walkthrough](https://www.youtube.com/watch?v=mRkUnA3mEt4) how to do retrieve the keys.\n\n```\nsls config credentials --provider aws --key \u003cyour_aws_access_key\u003e --secret \u003cyour_aws_secret_key\u003e\n```\n\n![!Live Example](https://user-images.githubusercontent.com/1587005/36068493-de82620e-0e8b-11e8-887b-e1593cd3c8cc.gif)\n\nYou need to make sure you have access to your deployed lambda functions.\n\n1. **Select Backend** \n\n- *AWS Appsync* (Supported by [Serverless-AppSync-Plugin](https://github.com/sid88in/serverless-appsync-plugin))\n\n**Note** Please make sure latest serverless package is installed `npm install -g serverless@latest`\n\nTo use aws appsync you will need to create cognito user pool to authenticate the API [Reference](https://serverless-stack.com/chapters/create-a-cognito-user-pool.html)\n\n    - AWS DynamoDB\n        cd app-backend/appsync/dynamodb\n        yarn deploy-prod\n        yarn deploy-appsync\n                \n    - AWS ElasticSearch\n        \n        cd app-backend/appsync/dynamo-elasticsearch-lambda\n        yarn deploy-prod\n        yarn deploy-appsync\n                \n    - AWS Lambda\n        \n        cd app-backend/appsync/lambda\n        yarn deploy-prod\n        yarn deploy-appsync\n        \n- *Lambda Backend* (Serverless Offline Supported)\n\n    - *Twitter Rest API*\n        ```\n        cd app-backend/rest-api\n        yarn deploy-prod\n        ```\n    \n    - *DynamoDB*\n        ```\n        cd app-backend/dynamodb\n        yarn deploy-prod\n        ```\n    \n    - *RDS*\n      - Create RDS Instance. For example - [PostGres Tutorial](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.PostgreSQL.html#CHAP_GettingStarted.Creating.PostgreSQL)\n     \n      - Please make sure connectivity to production RDS instance works (For example: test via razersql)\n      \n      - Edit the `config/security.env.prod` file and replace the `DATABASE_URL` variable with your amazon rds endpoint (eg: postgres://${username}:{password}@${endpoint):5432/${dbName}).\n    \n      - Run the deployment command\n          ```\n          cd app-backend/rds\n          yarn deploy-prod\n          ```\n\n2. **Config**: Get your /graphql POST endpoint as shown below and use it in config/security.env.prod  **NOTE** Please remove all quotes and \u003c\u003e and place only your POST endpoint url otherwise you will get 405 method not allowed error on POST to your endpoint\n\n![deploy feedback](https://user-images.githubusercontent.com/1587005/32410402-351ff868-c17c-11e7-9bfb-e39f7e8c14a3.png)\n\n\n3. **Select Frontend** (apollo-client or appsync-client)\n\n- Note: \n    - For lambda please use apollo-client\n    - For appsync backend please use appsync-client\n    - Please note that backend is deployed before deploying frontend.\n    - You can deploy the client on AWS S3 or Netlify.    \n\n- *AWS S3*\n\n  - First you will need to choose custom s3 bucket name for client. For ex: s3-firstname-serverless-graphql. Please note that bucket name must be unique across all aws buckets.\n\n  - Now, in `app-client/\u003cclient-name\u003e/serverless.yml` edit the `custom.client.bucketName` property and replace it the bucket name above.\n\n  - Now, in `app-client/\u003cclient-name\u003e/package.json` edit the `homepage` property with `https://${yourBucketName}.s3-website-us-east-1.amazonaws.com`. For ex: https://s3-bucketname-serverless-graphql.s3-website-us-east-1.amazonaws.com\n\n  - Run the deployment command\n      ```\n      cd app-client/\u003cclient-name\u003e/\n      yarn deploy-s3\n      # Your deployment url will be printed on the console\n      ```\n  - Your deployment url will be : https://s3.amazonaws.com/[bucket-name]/index.html   \n      \n- *Netlify*\n\n  - First you will need to create a new account. Please see https://www.netlify.com/docs/cli/ for details.\n\n  - Remove homepage property in `app-client/\u003cclient-name\u003e/package.json`. This property is not required while deploying to netlify but is required for aws s3 deployment.\n\n  - The first time you use the cli tool, you’ll be asked to authenticate through the browser. After you authenticate netlify will store an access token in a global ~/.netlify/config\n\n  - Run deployment command\n\n      ```\n      cd app-client/\u003cclient-name\u003e/\n      yarn deploy-netlify\n      ```\n\n      - ? No site id specified, create a new site (Y/n) Y\n      - ? Path to deploy? (current dir) build    \n\n  - Your deployment url will be printed on the console\n\n## Example: Appsync Backend Integration\n\n- GraphQL Schema:\n\n```graphql\ntype Mutation {\n\t# Create a tweet for a user\n\t# consumer keys and tokens are not required for dynamo integration\n\tcreateTweet(\n\t\ttweet: String!,\n\t\tconsumer_key: String,\n\t\tconsumer_secret: String,\n\t\taccess_token_key: String,\n\t\taccess_token_secret: String,\n\t\tcreated_at: String!\n\t): Tweet!\n\n\t# Delete User Tweet\n\tdeleteTweet(\n\t    tweet_id: String!,\n\t    consumer_key: String,\n        consumer_secret: String,\n        access_token_key: String,\n        access_token_secret: String\n    ): Tweet!\n\n\t# Retweet existing Tweet\n\treTweet(\n\t    tweet_id: String!,\n\t    consumer_key: String,\n        consumer_secret: String,\n        access_token_key: String,\n        access_token_secret: String\n    ): Tweet!\n\n\t# Update existing Tweet\n\tupdateTweet(tweet_id: String!, tweet: String!): Tweet!\n\n    # Create user info is available in dynamo integration\n\tupdateUserInfo(\n\t\tlocation: String!,\n\t\tdescription: String!,\n\t\tname: String!,\n\t\tfollowers_count: Int!,\n\t\tfriends_count: Int!,\n\t\tfavourites_count: Int!,\n\t\tfollowers: [String!]!\n\t): User!\n}\n\ntype Query {\n\tmeInfo(consumer_key: String, consumer_secret: String): User!\n\tgetUserInfo(handle: String!, consumer_key: String, consumer_secret: String): User!\n\n\t# search functionality is available in elasticsearch integration\n\tsearchAllTweetsByKeyword(keyword: String!): TweetConnection\n}\n\ntype Subscription {\n\taddTweet: Tweet\n\t\t@aws_subscribe(mutations: [\"createTweet\"])\n}\n\ntype Tweet {\n\ttweet_id: String!\n\ttweet: String!\n\tretweeted: Boolean\n\tretweet_count: Int\n\tfavorited: Boolean\n\tcreated_at: String!\n}\n\ntype TweetConnection {\n\titems: [Tweet!]!\n\tnextToken: String\n}\n\ntype User {\n\tname: String!\n\thandle: String!\n\tlocation: String!\n\tdescription: String!\n\tfollowers_count: Int!\n\tfriends_count: Int!\n\tfavourites_count: Int!\n\tfollowers: [String!]!\n\ttopTweet: Tweet\n\ttweets(limit: Int!, nextToken: String): TweetConnection\n\n\t# search functionality is available in elasticsearch integration\n    searchTweetsByKeyword(keyword: String!): TweetConnection\n}\n\nschema {\n\tquery: Query\n\tmutation: Mutation\n\tsubscription: Subscription\n}\n```\n\n- GraphQL Query:\n\n![query](https://user-images.githubusercontent.com/1587005/35409243-786b52d6-01c6-11e8-85c1-5f9572e3db04.gif)\n\n\n## Directory Layout\n\n```bash\n.\n├── /app-client/                             # React JS Client Integrations\n│   ├── /appsync-client                         # Appsync Client Itegrations\n│   │   ├── /public/                            # front End Utils\n│   │   │   ├── /index.html                     # main html file to render react app\n│   │   │   ├── /...                            # front end metadata\n│   │   ├── /src/                               # react app code logic\n│   │   │   ├── /components/                    # react components\n│   │   │   ├── /App.js                         # react application logic\n│   │   │   ├── /index.js                       # react dom render\n│   │   │   ├── /aws-exports.js                 # AWS Authentication\n│   │   │   ├── /...                            # etc.\n│   │   ├── /package.json                       # react app dependencies\n│   │   ├── /serverless.yml                     # Serverless yaml for AWS deployment\n│   ├── /apollo-client                       # Apollo Client Itegrations\n│   │   ├── /public/                            # front End Utils\n│   │   │   ├── /index.html                     # main html file to render react app\n│   │   │   ├── /...                            # front end metadata\n│   │   ├── /src/                               # react app code logic\n│   │   │   ├── /components/                    # react components\n│   │   │   ├── /App.js                         # react application logic\n│   │   │   ├── /index.js                       # react dom render\n│   │   │   ├── /...                            # etc.\n│   │   ├── /package.json                       # react app dependencies\n│   │   ├── /serverless.yml                     # Serverless yaml for AWS deployment\n├── /app-backend/                            # Server Backend Integrations\n├   ├── /appsync/                               # AWS Appsync Integrations\n├   ├   ├── /dynamodb/*                         # AWS Appsync Dynamodb \n├   ├   ├── /elasticsearch/*                    # AWS Appsync Elasticsearch\n├   ├   ├── /lambda/                            # AWS Appsync Lambda\n│   ├── /dynamodb                            # Integration with DynamodDB Backend\n│   │   ├── /seed-data/                         # seed test data\n│   │   │   ├── /create_seed_data.js            # Create Seed data to be inserted in dynamodb local and remote\n│   │   │   ├── /insert_seed_data_prod.js       # Insert seed data in aws dynamodb (serverless)\n│   │   │   ├── /sample-query.txt               # Test Query on DynamoDB Local Client http://localhost:8000\n│   │   ├── /handler.js                         # AWS Lambda - Apollo Lambda Server\n│   │   ├── /package.js                         # server side dependencies\n│   │   ├── /resolvers.js                       # graphql resolvers\n│   │   ├── /schema.js                          # graphql schema\n│   │   ├── /serverless.yml                     # Serverless yaml for AWS deployment\n│   │   ├── /webpack.config.js                  # Webpack server side code with ES6\n│   ├── /rest-api                           # Integration with REST API Backend\n│   │   ├── /handler.js                         # AWS Lambda - Apollo Lambda Server\n│   │   ├── /package.js                         # server side dependencies\n│   │   ├── /resolvers.js                       # graphql resolvers\n│   │   ├── /schema.js                          # graphql schema\n│   │   ├── /serverless.yml                     # Serverless yaml for AWS deployment\n│   │   ├── /webpack.config.js                  # Webpack server side code with ES6\n│   ├── /rds                                # Integrations for PostGres, MySQL and Aurora Backend\n│   │   ├── /seed-data/                         # seed test data\n│   │   │   ├── /create_seed_data.js            # Create Seed data to be inserted in dynamodb local and remote\n│   │   │   ├── /seed_local.js                  # Insert seed data in aws dynamodb (serverless)\n│   │   │   ├── /seed_prod.js                   # Test Query on DynamoDB Local Client http://localhost:8000\n│   │   ├── /migrations/                        # Create DDL statements\n│   │   ├── /knexfile.js                        # Database Configurations \n│   │   ├── /handler.js                         # AWS Lambda - Apollo Lambda Server\n│   │   ├── /package.js                         # server side dependencies\n│   │   ├── /resolvers.js                       # graphql resolvers\n│   │   ├── /schema.js                          # graphql schema\n│   │   ├── /serverless.yml                     # Serverless yaml for AWS deployment\n│   │   ├── /webpack.config.js                  # Webpack server side code with ES6\n├── /config/                                # Configuration files\n│   ├── /security.env.local                     # local config\n│   ├── /security.env.prod                      # production config\n```\n\n## Coming Soon\n\n1. Schema Stitching\n2. Lambda Backend: GraphCool, Druid\n3. Aggregations at Scale - Druid\n4. Lambda Backend: Authentication and Authorization\n5. Lambda Backend: Pagination\n6. Swagger Integration\n7. Integration with Azure, IBM and Google Coud\n\n## Who uses Serverless GraphQL Apollo?\n\nAs the Serverless GraphQL Apollo community grows, we'd like to keep track of who is using the platform. Please send a PR with your company name and @githubhandle if you may.\n\nCurrently **officially** using Serverless GraphQL Apollo :\n\n1. Serverless [@nikgraf](https://github.com/nikgraf)\n2. Glassdoor [@sid88in](https://github.com/sid88in)\n3. [@pradel](https://github.com/pradel)\n4. EMC School [@JstnEdr](https://github.com/JstnEdr)\n\n## Feedback\n\n![](http://www.reactiongifs.com/wp-content/uploads/2013/11/I-have-no-idea-what-I-am-doing.gif)\n\nSend your questions or feedback at: [@nikgraf](https://twitter.com/nikgraf), [@sidg_sid](https://twitter.com/sidg_sid)\n","funding_links":[],"categories":["JavaScript","Example Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fserverless-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-graphql/lists"}