{"id":13432292,"url":"https://github.com/serverless/serverless-graphql-blog","last_synced_at":"2025-04-04T10:05:02.152Z","repository":{"id":3789967,"uuid":"49918451","full_name":"serverless/serverless-graphql-blog","owner":"serverless","description":"A Serverless Blog leveraging GraphQL to offer a REST API with only 1 endpoint using Serverless v0.5","archived":false,"fork":false,"pushed_at":"2017-08-18T16:08:55.000Z","size":251,"stargazers_count":789,"open_issues_count":8,"forks_count":74,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-03-28T09:06:27.667Z","etag":null,"topics":[],"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/serverless.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":"2016-01-19T01:53:44.000Z","updated_at":"2025-03-24T17:13:07.000Z","dependencies_parsed_at":"2022-07-26T11:02:12.613Z","dependency_job_id":null,"html_url":"https://github.com/serverless/serverless-graphql-blog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql-blog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql-blog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql-blog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-graphql-blog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/serverless-graphql-blog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157108,"owners_count":20893215,"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-31T02:01:10.099Z","updated_at":"2025-04-04T10:05:02.126Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"![Serverless GraphQL Blog AWS Lambda API Gateway](serverless_graphql_blog.png)\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n\n\u003e Please note this project uses Serverless version 0.5\n\n#serverless-graphql-blog\n\nThis [Serverless Framework](http://www.serverless.com) Project creates a REST API for a basic blog structure, including Posts, Authors and Comments utilizing [GraphQL][1] and DynamoDB for persistent storage.  What's unique about this implementation is the entire REST API consists of only 1 endpoint.\n\nNote: This project automatically creates 3 DynamoDB tables upon `serverless project install`.  They are defined in `s-project.json`.\n\n* [Blog Post](http://kevinold.com/2016/02/01/serverless-graphql.html)\n* [Video Walkthrough](https://www.youtube.com/watch?v=lgE5-mm8gX4)\n* [Email Updates](http://eepurl.com/bvz5Nj)\n* [Gitter Chat Room](https://gitter.im/serverless/serverless)\n* [Serverless Documentation](http://docs.serverless.com)\n* [Twitter](https://www.twitter.com/goserverless)\n\nEnjoy,\u003cbr/\u003e\nKevin Old ([Twitter](https://twitter.com/kevinold))\n\n## Install \u0026 Deploy\n\nMake sure you have the most recent version of the [Serverless Framework](http://www.serverless.com) (0.5.x and higher) and you are using NodeV4 or greater.\n\n```\nnpm install serverless -g\n```\n\nInstall this Serverless Project:\n\n```\nserverless project install serverless-graphql-blog\n```\n\nInstall (top level) npm dependencies\n\n```\nnpm install\n```\n\nView project summary:\n\n```\nserverless dash summary\n```\nDeploy the project's Function and Endpoint:\n\n```\nserverless dash deploy\n```\n\n[![Serverless GraphQL Blog Video Walkthrough](video_serverless_blog_graphql.png)](https://www.youtube.com/watch?v=lgE5-mm8gX4)\n\n### Querying with GraphiQL\n\nThe [graphql-js][1] endpoint provided in this Serverless Project is compatible with [GraphiQL][2], a query visualization tool used with [graphql-js][1].\n\nUsage with [GraphiQL.app][3] (an Electron wrapper around [GraphiQL][2]) is recommended and is shown below:\n\n![GraphiQL.app demo](https://s3.amazonaws.com/various-image-files/graphiql-serverless-graphql-blog-screenshot.png)\n\n### Sample GraphQL queries\n\n#### List of author names\n```\ncurl -XPOST -d '{\"query\": \"{ authors { name } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"data\":{\n    \"authors\":[\n      {\"name\":\"Kevin\"}\n    ]\n  }\n}\n```\n\n### List of posts with id and title\n```\ncurl -XPOST -d '{\"query\": \"{ posts { id, title } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"data\": {\n    \"posts\": [\n      { \"id\":\"1\",\n        \"title\":\"First Post Title\"\n      }\n    ]\n  }\n}\n```\n\n#### List of posts with id, title and *nested* author name\n```\ncurl -XPOST -d '{\"query\": \"{ posts { id, title, author { name } } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"data\": {\n    \"posts\": [\n      { \"id\":\"1\",\n        \"title\":\"First Post Title\",\n        \"author\":{\n          \"name\":\"Kevin\"\n        }\n      }\n    ]\n  }\n}\n```\n\n#### List of posts with post, author and comments information (for a Post with no comments, i.e. comments:[])\n```\ncurl -XPOST -d '{\"query\": \"{ posts { id, title, author { id, name }, comments { id, content, author { name } } } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"data\":{\n    \"posts\":[\n    {\n      \"id\":\"1\",\n        \"title\":\"First Post Title\",\n        \"author\":{\n          \"id\":\"1\",\n          \"name\":\"Kevin\"\n        },\n        \"comments\":[]\n    }\n    ]\n  }\n}\n```\n\n\n### Sample GraphQL Mutations\n\n#### Create Post\n```\ncurl -XPOST -d '{\"query\": \"mutation createNewPost { post: createPost (id: \\\"5\\\", title: \\\"Fifth post!\\\", bodyContent: \\\"Test content\\\", author: \\\"1\\\") { id, title } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"data\":{\n    \"post\":{\n      \"id\":\"5\",\n      \"title\":\"Fifth post!\"\n    }\n  }\n}\n```\n\n\n#### Mutation Validation\n\nValidations defined using [graphql-custom-types][4] in [blog/lib/schema.js][5]\n```\ncurl -XPOST -d '{\"query\": \"mutation createNewPost { post: createPost (id: \\\"8\\\", title: \\\"123456789\\\", bodyContent: \\\"Test content 5\\\") { id, title } }\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\n#### Results\n```\n{\n  \"errors\":[\n  {\n    \"message\":\"Query error: String not long enough\"}\n  ]\n}\n```\n\n\n### Introspection Query\n```\ncurl -XPOST -d '{\"query\": \"{__schema { queryType { name, fields { name, description} }}}\"}' \u003cendpoint\u003e/dev/blog/graphql\n```\n\nReturns:\n```\n{\n  \"data\":{\n    \"__schema\":{\n      \"queryType\":{\n        \"name\":\"BlogSchema\",\n          \"fields\":[\n          {\n            \"name\":\"posts\",\n            \"description\":\"List of posts in the blog\"\n          },\n          {\n            \"name\":\"authors\",\n            \"description\":\"List of Authors\"\n          },\n          {\n            \"name\":\"author\",\n            \"description\":\"Get Author by id\"\n          }\n        ]\n      }\n    }\n  }\n}\n```\n\n[1]: https://github.com/graphql/graphql-js\n[2]: https://github.com/graphql/graphiql\n[3]: https://github.com/skevy/graphiql-app\n[4]: https://github.com/stylesuxx/graphql-custom-types\n[5]: https://github.com/serverless/serverless-graphql-blog/blob/master/blog/lib/schema.js#L100\n","funding_links":[],"categories":["JavaScript","Examples"],"sub_categories":["JavaScript Examples"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-graphql-blog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fserverless-graphql-blog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-graphql-blog/lists"}