{"id":23164127,"url":"https://github.com/lk321/sls-graphql","last_synced_at":"2026-05-01T09:31:24.144Z","repository":{"id":122249933,"uuid":"408617770","full_name":"lk321/sls-graphql","owner":"lk321","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-20T22:29:43.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T20:48:35.034Z","etag":null,"topics":["aws","dynamodb","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lk321.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-20T22:26:28.000Z","updated_at":"2023-03-08T16:26:48.000Z","dependencies_parsed_at":"2023-03-13T12:21:40.250Z","dependency_job_id":null,"html_url":"https://github.com/lk321/sls-graphql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lk321/sls-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lk321%2Fsls-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lk321%2Fsls-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lk321%2Fsls-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lk321%2Fsls-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lk321","download_url":"https://codeload.github.com/lk321/sls-graphql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lk321%2Fsls-graphql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32492095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aws","dynamodb","serverless"],"created_at":"2024-12-18T00:33:21.751Z","updated_at":"2026-05-01T09:31:24.129Z","avatar_url":"https://github.com/lk321.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![banner](https://user-images.githubusercontent.com/4102106/28962905-7e5aa6d0-7907-11e7-8b0e-022c0cd73a42.png)\n\n\n# Serverless GraphQL API using Lambda and DynamoDB\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![Build Status](https://travis-ci.org/boazdejong/serverless-graphql-api.svg?branch=master)](https://travis-ci.org/boazdejong/serverless-graphql-api)\n\nGraphQL Lambda Server using [graphql-server-lambda](https://github.com/apollographql/graphql-server/tree/master/packages/graphql-server-lambda) from [Apollo](http://dev.apollodata.com/).\n\n[graphql-tools](https://github.com/apollographql/graphql-tools) and [merge-graphql-schemas](https://github.com/okgrow/merge-graphql-schemas) are used to generate the schema.\n\n[serverless-webpack](https://github.com/elastic-coders/serverless-webpack) is used to transform ES6 with [Babel](https://babeljs.io/) and build the lambda.\n\n\n## Setup\nClone the repository and install the packages.\n\n```\ngit clone https://github.com/boazdejong/serverless-graphql-api\ncd serverless-graphql-api\nnpm install\n```\n\n## Deploy\nRun the `deploy` script to create the Lambda Function and API Gateway for GraphQL. This also creates two DynamoDB tables named `artists` and `songs`\n```\nnpm run deploy\n```\n\n## Queries and Mutations\nQuery the GraphQL server using the [GraphiQL.app](https://github.com/skevy/graphiql-app). If you have Homebrew installed on OSX run\n```\nbrew cask install graphiql\n```\n\n### Mutations\nThe following mutations are available in this example.\n\n#### createArtist()\nCreate an artist providing the first and last name as arguments. The id will be a generated uuid.\n```graphql\nmutation {\n  createArtist(first_name: \"Billy\", last_name: \"Crash\") {\n    id\n  }\n}\n```\n\n#### createSong()\nUsing the generated id from the artist you can create a song with the following mutation. Also provide a title and duration.\n```graphql\nmutation {\n  createSong(artist: \"99a746e0-0734-11e7-b2fd-45ae0a3b9074\", title: \"Whatever\", duration: 120) {\n    id\n  }\n}\n```\n\n#### updateArtist()\n```graphql\nmutation {\n  updateArtist(id: \"99a746e0-0734-11e7-b2fd-45ae0a3b9074\", first_name: \"John\", last_name: \"Ruth\") {\n    id\n    first_name\n    last_name\n  }\n}\n```\n\n#### updateSong()\n```graphql\nmutation {\n  updateSong(id: \"a8a0a060-071b-11e7-bd09-8562f101f7c2\", artist: \"99a746e0-0734-11e7-b2fd-45ae0a3b9074\", duration: 130, title: \"A new title\") {\n    id\n  }\n}\n```\n\n### Queries\n#### Example query\n```graphql\n{\n  songs {\n    id\n    title\n    duration\n    artist {\n      id\n      first_name\n      last_name\n    }\n  }\n}\n```\n\nThis query will return a result similar to this\n```json\n{\n  \"data\": {\n    \"songs\": [\n      {\n        \"id\": \"a8a0a060-071b-11e7-bd09-8562f101f7c2\",\n        \"title\": \"Whatever\",\n        \"duration\": 120,\n        \"artist\": {\n          \"id\": \"99a746e0-0734-11e7-b2fd-45ae0a3b9074\",\n          \"first_name\": \"Billy\",\n          \"last_name\": \"Crash\"\n        }\n      }\n    ]\n  }\n}\n```\n\n## DynamoDB Streams\nThis project also includes an example of capturing table activity with DynamoDB Streams.\nThe `record` lambda function is triggered by two stream events. One for each table.\n\nIn `serverless.yml`:\n```\nrecord:\n  handler: lib/handler.record\n  events:\n    - stream:\n        type: dynamodb\n        arn:\n          Fn::GetAtt:\n            - ArtistsDynamoDbTable\n            - StreamArn\n        batchSize: 1\n    - stream:\n        type: dynamodb\n        arn:\n          Fn::GetAtt:\n            - SongsDynamoDbTable\n            - StreamArn\n        batchSize: 1\n```\n\nThe stream is enabled when defining the DynamoDB table in the `serverless.yml` resources.\n```\nStreamSpecification:\n  StreamViewType: NEW_AND_OLD_IMAGES\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flk321%2Fsls-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flk321%2Fsls-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flk321%2Fsls-graphql/lists"}