{"id":18510251,"url":"https://github.com/cubonetwork/serverless-graphql-rest-api","last_synced_at":"2026-05-07T09:32:19.158Z","repository":{"id":42361749,"uuid":"130111645","full_name":"cubonetwork/serverless-graphql-rest-api","owner":"cubonetwork","description":"The porpuse of this repo is to create a REST API using GraphQL (Apollo Server) and Serverless framework.","archived":false,"fork":false,"pushed_at":"2022-12-22T09:23:45.000Z","size":3617,"stargazers_count":3,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-14T11:17:59.664Z","etag":null,"topics":["apollo-server","graphql","lambda","neo4j","neptune","serverless","serverless-framework"],"latest_commit_sha":null,"homepage":null,"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/cubonetwork.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}},"created_at":"2018-04-18T19:24:56.000Z","updated_at":"2019-02-07T18:48:25.000Z","dependencies_parsed_at":"2023-01-30T06:46:21.189Z","dependency_job_id":null,"html_url":"https://github.com/cubonetwork/serverless-graphql-rest-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cubonetwork/serverless-graphql-rest-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cubonetwork%2Fserverless-graphql-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cubonetwork%2Fserverless-graphql-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cubonetwork%2Fserverless-graphql-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cubonetwork%2Fserverless-graphql-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cubonetwork","download_url":"https://codeload.github.com/cubonetwork/serverless-graphql-rest-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cubonetwork%2Fserverless-graphql-rest-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261193093,"owners_count":23122905,"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":["apollo-server","graphql","lambda","neo4j","neptune","serverless","serverless-framework"],"created_at":"2024-11-06T15:22:17.324Z","updated_at":"2026-05-07T09:32:14.135Z","avatar_url":"https://github.com/cubonetwork.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"serverless-graphql-rest-api\n===========================\n\nThe main porpuse of this repo is be a sample of how to integrate Apollo Server + GraphQL + Serverless Architecture. For this we have created a search API thought a schema like following:\n\n![Model](./docs/images/model.png)\n\nTo summarize we have 3 entities: User, Company and Contacts. So, if I wish retrieve all the contacts of a specific company, how could I do it? This question will be answered by this code.\n\n# Dependencies\n\n* [Serverless framework](https://serverless.com)\n  * [serverless-offline](https://github.com/dherault/serverless-offline) \n  * [serverless-dynamodb-local](https://github.com/99xt/serverless-dynamodb-local) \n* [Apollo Server - Lambda](https://www.apollographql.com/docs/apollo-server/servers/lambda.html)\n\nTo understand the concepts and code implemented in this repo it's necessary a basic knowledge of GraphQL, Serverless Architecture and Node.js programming language.\n\n# Running\n\nAfter clone this repo in your computer, go to project folder and install dependencies using the following command:\n\n```bash\nnpm i\n```\n\nAfter all dependencies have installed you can run the project throught the command:\n\n```bash\nnpm run offline\n```\n\nIf everything was fine you could see a screen like this:\n\n![Running Offline](./docs/images/running_offline.png)\n\n# Implementation\n\nThis implementation was based on the post [Running a scalable \u0026 reliable GraphQL endpoint with Serverless](https://serverless.com/blog/running-scalable-reliable-graphql-endpoint-with-serverless/).\n\nBasically, the project contains two handlers, as you can see at [serverless.yml](./serverless.yml) file:\n\n* `graphql`: whose implementation is in [src/handler.js](./src/handler.js) file, more specifically at line 11. This handler is responsible to process requests throught GraphQL using apollo-server-lambda implementation. In other words is the Backend API of our project.\n* `graphiql`: whose implementation is in [src/handler.js](./src/handler.js) file, more specifically at line 25. This handler returns a GraphQL Client implementation called graphiql. Where you can write your queries and see the results.\n\nOther important files are:\n\n* [graphql](./src/graphql/): The graphql folder contains the graphql schema used for this project. In this folder you will find all schema's types, resolvers and queries. \n  * [schema.js](./src/graphql/schema.js): Where we define the GraphQL types, queries, mutations and subscriptions, which makes up the GraphQL Schema.\n  * [resolvers.js](./src/graphql/resolvers.js): The implementation of GraphQL resolvers based on types and queries defined at `schema.js`.\n  * [types.js](./src/graphql/types.js): Just an array of types which will by used at `schema.js`.\n* [src/core](./src/core/): The core folder contains the code to integrate with data layer. We have used DynamoDB to persist data.\n* [dynamodb/seed-data](./dynamodb/seed-data/): The seed-data folder contains sample data used on offline mode. See `serverless-dynamodb-local` for more information.\n\n# See it in action\n\nJust open the link `http://localhost:3000/graphiql` in your browser.\n\n![In action](./docs/images/in_action.gif)\n\n# Next steps\n\n* Compares [Apollo Engine](https://www.apollographql.com/docs/engine/setup-lambda.html) and [AppSync](https://hackernoon.com/running-a-scalable-reliable-graphql-endpoint-with-serverless-24c3bb5acb43) to manage cache and metrics about the GraphQL API\n* Reimplement this project using some GraphDB\n  * Amazon Neptune: until now (04/19/2018) neptune is only available for whitelisted users and there is no integration from Lambda functions. To request a preview for Neptune [click here](https://pages.awscloud.com/NeptunePreview.html).\n  * Neo4j: It's a good option, but, AWS there is no a managed service for neo4j. So you have to install and mantain it in a EC2 instance.\n\n## Neo4j\n\nTo run neo4j using docker run the following command:\n\n```bash\nnpm run neo4j:start\n```\n\n### Not implemented yet\n\n* [neo4j/seed-data.js](./neo4j/seed-data.js): the porpuse of this file is to create data on neo4j docker instance.\n\n# Test\n\nWe are using [jest](https://facebook.github.io/jest/docs/en/getting-started.html) for testing.\n\n## Running tests\n\n```bash\nnpm run test\n```\n\n## Coverage\n\n```bash\nnpm run coverage\n```\n\n# Documentation\n\n```bash\nnpm run generate-docs\n```\n\nAfter see generated site in [./docs/index.html](./docs/index.html).\n\n# Deploy\n\nFirst of all you need to configure your AWS credentials:\n\n```bash\nsls config credentials --provider aws --key \u003cyour_aws_access_key\u003e --secret \u003cyour_aws_secret_key\u003e\n```\n\nAfter that:\n\n```bash\nnpm run deploy\n```\n\n# About\n\n* devs@cubo.network","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcubonetwork%2Fserverless-graphql-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcubonetwork%2Fserverless-graphql-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcubonetwork%2Fserverless-graphql-rest-api/lists"}