Giter VIP home page Giter VIP logo

serverless-graphql-blog's Introduction

Serverless GraphQL Blog AWS Lambda API Gateway

serverless

Please note this project uses Serverless version 0.5

#serverless-graphql-blog

This Serverless Framework Project creates a REST API for a basic blog structure, including Posts, Authors and Comments utilizing GraphQL and DynamoDB for persistent storage. What's unique about this implementation is the entire REST API consists of only 1 endpoint.

Note: This project automatically creates 3 DynamoDB tables upon serverless project install. They are defined in s-project.json.

Enjoy,
Kevin Old (Twitter)

Install & Deploy

Make sure you have the most recent version of the Serverless Framework (0.5.x and higher) and you are using NodeV4 or greater.

npm install serverless -g

Install this Serverless Project:

serverless project install serverless-graphql-blog

Install (top level) npm dependencies

npm install

View project summary:

serverless dash summary

Deploy the project's Function and Endpoint:

serverless dash deploy

Serverless GraphQL Blog Video Walkthrough

Querying with GraphiQL

The graphql-js endpoint provided in this Serverless Project is compatible with GraphiQL, a query visualization tool used with graphql-js.

Usage with GraphiQL.app (an Electron wrapper around GraphiQL) is recommended and is shown below:

GraphiQL.app demo

Sample GraphQL queries

List of author names

curl -XPOST -d '{"query": "{ authors { name } }"}' <endpoint>/dev/blog/graphql

Results

{
  "data":{
    "authors":[
      {"name":"Kevin"}
    ]
  }
}

List of posts with id and title

curl -XPOST -d '{"query": "{ posts { id, title } }"}' <endpoint>/dev/blog/graphql

Results

{
  "data": {
    "posts": [
      { "id":"1",
        "title":"First Post Title"
      }
    ]
  }
}

List of posts with id, title and nested author name

curl -XPOST -d '{"query": "{ posts { id, title, author { name } } }"}' <endpoint>/dev/blog/graphql

Results

{
  "data": {
    "posts": [
      { "id":"1",
        "title":"First Post Title",
        "author":{
          "name":"Kevin"
        }
      }
    ]
  }
}

List of posts with post, author and comments information (for a Post with no comments, i.e. comments:[])

curl -XPOST -d '{"query": "{ posts { id, title, author { id, name }, comments { id, content, author { name } } } }"}' <endpoint>/dev/blog/graphql

Results

{
  "data":{
    "posts":[
    {
      "id":"1",
        "title":"First Post Title",
        "author":{
          "id":"1",
          "name":"Kevin"
        },
        "comments":[]
    }
    ]
  }
}

Sample GraphQL Mutations

Create Post

curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"5\", title: \"Fifth post!\", bodyContent: \"Test content\", author: \"1\") { id, title } }"}' <endpoint>/dev/blog/graphql

Results

{
  "data":{
    "post":{
      "id":"5",
      "title":"Fifth post!"
    }
  }
}

Mutation Validation

Validations defined using graphql-custom-types in blog/lib/schema.js

curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"8\", title: \"123456789\", bodyContent: \"Test content 5\") { id, title } }"}' <endpoint>/dev/blog/graphql

Results

{
  "errors":[
  {
    "message":"Query error: String not long enough"}
  ]
}

Introspection Query

curl -XPOST -d '{"query": "{__schema { queryType { name, fields { name, description} }}}"}' <endpoint>/dev/blog/graphql

Returns:

{
  "data":{
    "__schema":{
      "queryType":{
        "name":"BlogSchema",
          "fields":[
          {
            "name":"posts",
            "description":"List of posts in the blog"
          },
          {
            "name":"authors",
            "description":"List of Authors"
          },
          {
            "name":"author",
            "description":"Get Author by id"
          }
        ]
      }
    }
  }
}

serverless-graphql-blog's People

Contributors

austencollins avatar davidwells avatar kevinold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-graphql-blog's Issues

Installation is broken on a fresh install of npm/serverless (mac osx)

serverless project install serverless-graphql-blog


| _ .-----.----.--.--.-----.----| .-----.-----.-----.
| || -| _| | | -| _| | -|_ --|__ --|
|____ ||| _/||| ||||_____|
| | | The Serverless Application Framework
| | serverless.com, v0.5.1
`-------'

Serverless: Installing Serverless Project "serverless-graphql-blog"...
Serverless: Downloading project and installing dependencies...
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
fn = function () { throw arg; };
^

ServerlessError: This plugin could not be found: serverless-optimizer-plugin
at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/Error.js:17:11)
at Serverless._loadPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:293:17)
at Serverless.loadProjectPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:240:10)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:77:41
From previous event:
at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:73:25)
at /usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:213:24
From previous event:
at ProjectInstall._initProject (/usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:208:27)
From previous event:
at ProjectInstall.installProject (/usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:110:12)
From previous event:
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:181:31
at Array.reduce (native)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:180:32
From previous event:
at Serverless._execute (/usr/local/lib/node_modules/serverless/lib/Serverless.js:178:12)
at Serverless.actions.(anonymous function) (/usr/local/lib/node_modules/serverless/lib/Serverless.js:424:20)
at Serverless.command (/usr/local/lib/node_modules/serverless/lib/Serverless.js:393:38)
at /usr/local/lib/node_modules/serverless/bin/serverless:19:16
at processImmediate as _immediateCallback
From previous event:
at Object. (/usr/local/lib/node_modules/serverless/bin/serverless:18:4)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3

Cannot deploy to AWS

Hi everyone,

Here is the error I got when "sls dash deploy":
Error 1:
Serverless: Failed to deploy the following functions in "dev" to the following regions:
Serverless: us-east-1 ------------------------
Serverless: blog/resource/graphql: Missing required key 'Role' in params
serverless:lib.node_modules.serverless.lib.actions.FunctionDeploy MissingRequiredParameter: Missing required key 'Role' in params
at ParamValidator.fail (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/param_validator.js:50:37)
at ParamValidator.validateStructure (/usr/local/lib/node_modules/serverless/node_modules/aws-sdk/lib/param_validator.js:61:14)

Error 2:
Serverless: Failed to deploy endpoints in "dev" to the following regions:
Serverless: us-east-1 ------------------------
Serverless: POST - resource/graphql: No Lambda IAM Role found
serverless:lib.node_modules.serverless.lib.actions.EndpointDeploy ServerlessError: No Lambda IAM Role found
at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/ServerlessError.js:17:11)
at Builder._validateAndPrepare (/usr/local/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js:132:15)

"serverless project install serverless-graphql-blog" does not work

Serverless Error ---------------------------------------

 Command "project" not found, Run "serverless help" for
 a list of all available commands.

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues

Your Environment Infomation -----------------------------
OS: linux
Node Version: 5.6.0
Serverless Version: 1.0.2

Updates needed for serverless 0.4?

Any updates you would make based on serverless .4? For example, the release notes say "If you have s-modules.json in your project, we will continue to support those, but we advise you to change them into s-resources-cf.json files."

Perhaps make a few issues and folks will submit PRs.

ES6 features not working

There is probably some custom setup on your machine, I can't get it working after this commands (node v5.4.1):

git clone [email protected]:serverless/serverless-graphql-blog.git .
sls project init -c
sls function run blog/resource/graphql

I get this error Serverless: SyntaxError: Unexpected token import. Obviously Babel transformation was not called.

What worked for me was:

npm install babel-register babel-preset-es2015 aws-sdk
echo '{"presets": ["es2015"]}' > .babelrc

and add require("babel-register"); into graphql/handler.js. Then I can see "Success":

$ sls function run blog/resource/graphql
Serverless: Running blog/resource/graphql...  
Serverless: -----------------  
Serverless: Success! - This Response Was Returned:  
Serverless: {"errors":[{"message":"Syntax Error GraphQL request (1:1) Unexpected EOF\n\n1: \n   ^\n"}]}  

Don't have AWS account yet, so I'm not sure if there is any trap in deploy. I'll be happy to send pull request, but maybe you have better solution since I'm no big expert in Serverless & NodeJS.

Installation is broken on a fresh install of npm/serverless (mac osx)

serverless project install serverless-graphql-blog
 _______                             __
|   _   .-----.----.--.--.-----.----|  .-----.-----.-----.
|   |___|  -__|   _|  |  |  -__|   _|  |  -__|__ --|__ --|
|____   |_____|__|  \___/|_____|__| |__|_____|_____|_____|
|   |   |             The Serverless Application Framework
|       |                           serverless.com, v0.5.1
`-------'

Serverless: Installing Serverless Project "serverless-graphql-blog"...
Serverless: Downloading project and installing dependencies...
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
        fn = function () { throw arg; };
                           ^

ServerlessError: This plugin could not be found: serverless-optimizer-plugin
    at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/Error.js:17:11)
    at Serverless._loadPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:293:17)
    at Serverless.loadProjectPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:240:10)
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:77:41
From previous event:
    at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:73:25)
    at /usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:213:24
From previous event:
    at ProjectInstall._initProject (/usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:208:27)
From previous event:
    at ProjectInstall.installProject (/usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js:110:12)
From previous event:
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:181:31
    at Array.reduce (native)
    at /usr/local/lib/node_modules/serverless/lib/Serverless.js:180:32
From previous event:
    at Serverless._execute (/usr/local/lib/node_modules/serverless/lib/Serverless.js:178:12)
    at Serverless.actions.(anonymous function) (/usr/local/lib/node_modules/serverless/lib/Serverless.js:424:20)
    at Serverless.command (/usr/local/lib/node_modules/serverless/lib/Serverless.js:393:38)
    at /usr/local/lib/node_modules/serverless/bin/serverless:19:16
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:18:4)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:141:18)
    at node.js:933:3

Error occurs when it is deployed

$ serverless deploy

  Serverless Error ---------------------------------------

     This command can only be run inside a service directory

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues

  Your Environment Infomation -----------------------------
     OS:                 linux
     Node Version:       5.6.0
     Serverless Version: 1.0.2

Error loading request plugin

I did:

npm install request --save

Then added it to s-project.json:
"plugins": ["request"]

When I do server less dash deploy, I get the following error:
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^

Error: options.uri is a required argument
at Request.init (/Users/Meenals/workspace/lambdas/RegistrationLogin/node_modules/request/request.js:246:31)
at new Request (/Users/Meenals/workspace/lambdas/RegistrationLogin/node_modules/request/request.js:142:8)
at request (/Users/Meenals/workspace/lambdas/RegistrationLogin/node_modules/request/index.js:55:10)
at Serverless._loadPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:291:25)
at Serverless.loadProjectPlugins (/usr/local/lib/node_modules/serverless/lib/Serverless.js:245:10)
at /usr/local/lib/node_modules/serverless/lib/Serverless.js:76:41
From previous event:
at Serverless.init (/usr/local/lib/node_modules/serverless/lib/Serverless.js:72:25)
at Object. (/usr/local/lib/node_modules/serverless/bin/serverless:17:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

When loading the plugin itself, it is trying to create a new Request object, which in turn is erroring out, since the required variables are niot present

Command "project" not found

$ serverless project install serverless-graphql-blog

  Serverless Error ---------------------------------------

     Command "project" not found, Run "serverless help" for
     a list of all available commands.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                 darwin
     Node Version:       6.10.2
     Serverless Version: 1.11.0

I also tried...

  1. $ serverless install project serverless-graphql-blog
  2. $ serverless install serverless-graphql-blog

graphql endpoint returning error after deploying project

I'm getting some issues after deploying the project and hitting the endpoint.

sdm:serverless41xx9q standayweb$ serverless dash deploy --debug
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/ProjectCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectCreate plugin loaded +6ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/ProjectInstall.js +3ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ProjectInstall plugin loaded +23ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/ComponentCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ComponentCreate plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/ModuleCreate.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ModuleCreate plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/FunctionRun.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRun plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/FunctionCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionCreate plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/FunctionRunLambdaNodeJs.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRunLambdaNodeJs plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/FunctionRunLambdaPython2.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionRunLambdaPython2 plugin loaded +0ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/FunctionDeploy.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.FunctionDeploy plugin loaded +2ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/CodePackageLambda.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodePackageLambda plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/CodeDeployLambda.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeDeployLambda plugin loaded +22ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/CodeEventDeployLambda.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.CodeEventDeployLambda plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EndpointDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeploy plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EndpointBuildApiGateway.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointBuildApiGateway plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/DashDeploy.js +3ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.DashDeploy plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/DashSummary.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.DashSummary plugin loaded +0ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EndpointDeployApiGateway.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EndpointDeployApiGateway plugin loaded +4ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/StageCreate.js +2ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.StageCreate plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/RegionCreate.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.RegionCreate plugin loaded +3ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EnvList.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvList plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EnvGet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvGet plugin loaded +0ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EnvSet.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvSet plugin loaded +0ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/EnvUnset.js +1ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.EnvUnset plugin loaded +1ms
  serverless:lib.node_modules.serverless.lib.Serverless Attempting to load plugin from /usr/local/lib/node_modules/serverless/lib/actions/ResourcesDeploy.js +0ms
  serverless:lib.node_modules.serverless.lib.Serverless serverless.core.ResourcesDeploy plugin loaded +1ms
WARNING: This plugin was requested by this project but could not be found: serverless-optimizer-plugin
  serverless:lib.node_modules.serverless.lib.Serverless CLI raw input:  +1ms { _: [ 'dash', 'deploy' ], debug: true }
  serverless:lib.node_modules.serverless.lib.Serverless CLI processed input:  +12ms { context: 'dash',
  action: 'deploy',
  options: 
   { stage: null,
     region: null,
     aliasFunction: null,
     aliasEndpoint: null,
     aliasRestApi: null },
  params: {},
  raw: { _: [ 'dash', 'deploy' ], debug: true } }
 _______                             __
|   _   .-----.----.--.--.-----.----|  .-----.-----.-----.
|   |___|  -__|   _|  |  |  -__|   _|  |  -__|__ --|__ --|
|____   |_____|__|  \___/|_____|__| |__|_____|_____|_____|
|   |   |             The Serverless Application Framework
|       |                           serverless.com, v0.2.0
`-------'

Serverless: Select the assets you wish to deploy:
    blog - resource - graphql
      function - blog/resource/graphql
      endpoint - blog/resource/graphql@resource/graphql~POST
    - - - - -
  > Deploy
  serverless:lib.node_modules.serverless.lib.utils.cli Closing select listener +6s

Serverless: Deploying functions in "development" to the following regions: eu-west-1  
  serverless:lib.node_modules.serverless.lib.actions.CodePackageLambda "development - eu-west-1 - graphql": Copying in dist dir /var/folders/4s/q2mkp7p96v919tp8nhh_vx2h0000gn/T/graphql@1454871343530 +37ms
  serverless:lib.node_modules.serverless.lib.utils.aws.S3 Getting ENV Vars: serverless.eu-west-1.serverless41xx9q.com - serverless/serverless41xx9q/development/eu-west-1/envVars/.env +360ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.CodeDeployLambda "development - eu-west-1 - graphql": Compressed file created - /var/folders/4s/q2mkp7p96v919tp8nhh_vx2h0000gn/T/graphql@1454871343530/package.zip +893ms
  serverless:lib.node_modules.serverless.lib.actions.CodeDeployLambda "development - eu-west-1 - graphql": Uploading to project bucket... +0ms
  serverless:lib.node_modules.serverless.lib.utils.aws.S3 Uploading Lambda Zip File: serverless/serverless41xx9q/development/lambdas/[email protected] +18ms
Serverless: |   serverless:lib.node_modules.serverless.lib.actions.CodeDeployLambda "development - eu-west-1 - graphql": Updating Lambda configuration... +567ms
Serverless: /   serverless:lib.node_modules.serverless.lib.actions.CodeDeployLambda "development - eu-west-1 - graphql": Updating Lambda function... +278ms
Serverless: -   serverless:lib.node_modules.serverless.lib.actions.CodeDeployLambda "development - eu-west-1 - graphql": Updating Lambda Alias for version - 2 +2s
Serverless: ------------------------  
Serverless: Successfully deployed functions in "development" to the following regions:   
Serverless: eu-west-1 ------------------------  
Serverless:   blog/resource/graphql: arn:aws:lambda:eu-west-1:051458180940:function:serverless41xx9q-blog-resource-graphql:development  

Serverless: Deploying endpoints in "development" to the following regions: eu-west-1  
Serverless: |   serverless:lib.node_modules.serverless.lib.utils.aws.ApiGateway "development - eu-west-1": found existing REST API on AWS API Gateway with name: serverless41xx9q +590ms
Serverless: \   serverless:lib.node_modules.serverless.lib.utils.aws.ApiGateway "development - eu-west-1": found existing REST API on AWS API Gateway with name: serverless41xx9q +186ms
Serverless: /   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": found the target lambda with function name: serverless41xx9q-blog-resource-graphql +120ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": found 3 existing Resources on API Gateway +151ms
  serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": ": no resources need to be created for this endpoint +1ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created method: POST +498ms
Serverless: -   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created integration with the type: AWS +185ms
Serverless: /   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created method response +182ms
Serverless: |   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created method response +199ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created method integration response +192ms
Serverless: -   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": created method integration response +186ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": removed existing lambda access policy statement +305ms
Serverless: \   serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development - eu-west-1 - /resource/graphql": added permission to Lambda +234ms
  serverless:lib.node_modules.serverless.lib.actions.EndpointBuildApiGateway "development" successfully built endpoint on API Gateway in the region "eu-west-1". Access it via POST @ https://2jo5n3frud.execute-api.eu-west-1.amazonaws.com/development/resource/graphql +0ms
Serverless: |   serverless:lib.node_modules.serverless.lib.actions.EndpointDeployApiGateway "development - eu-west-1 - REST API: created API Gateway deployment: tuycei +2s
Serverless: Successfully deployed endpoints in "development" to the following regions:  
Serverless: eu-west-1 ------------------------  
Serverless:   POST - resource/graphql - https://2jo5n3frud.execute-api.eu-west-1.amazonaws.com/development/resource/graphql  

When hitting the endpoint I get this error:

{
  "errorMessage": "Unexpected reserved word",
  "errorType": "SyntaxError",
  "stackTrace": [
    "Module._compile (module.js:439:25)",
    "Object.Module._extensions..js (module.js:474:10)",
    "Module.load (module.js:356:32)",
    "Function.Module._load (module.js:312:12)",
    "Module.require (module.js:364:17)",
    "require (module.js:380:17)",
    "Object.<anonymous> (/var/task/resource/graphql/handler.js:14:11)",
    "Module._compile (module.js:456:26)",
    "Object.Module._extensions..js (module.js:474:10)",
    "Module.load (module.js:356:32)"
  ]
}

Suggest adding troubleshooting section

I recently ran into the same problem as described by #4. I was about to file a duplicate open issue, but since the project is so small, I decided to look at the closed issues first, and found my answer. I wasn't going by the directions in the README, but rather the YouTube video, which doesn't show the npm install step. May I suggest adding a troubleshooting section to this project for others who may have the same issue?

How to make it scale?

I've been extremely intrigued by the ideal of using Lambda + Dynamo for a GraphQL-powered backend. However, Dynamo's "scan" operation won't scale. What kind of steps could be taken to take this same model and make it more scalable at the DB layer?

Deployment problem with role for function

I get this when trying to deploy this,

Failed to deploy the following functions in "dev" to the following regions:
Serverless: us-east-1 ------------------------
Serverless: graphql: The role defined for the function cannot be assumed by Lambda.
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };

Issues installing

Running into several issues trying to get this example running. Following along with the instructions I get:

$ serverless project install serverless-graphql-blog
 _______                             __
|   _   .-----.----.--.--.-----.----|  .-----.-----.-----.
|   |___|  -__|   _|  |  |  -__|   _|  |  -__|__ --|__ --|
|____   |_____|__|  \___/|_____|__| |__|_____|_____|_____|
|   |   |             The Serverless Application Framework
|       |                           serverless.com, v0.5.0
`-------'

Serverless: Installing Serverless Project "serverless-graphql-blog"...
Serverless: Downloading project and installing dependencies...
/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
        fn = function () { throw arg; };
                           ^

ServerlessError: This plugin could not be found: serverless-optimizer-plugin
    at new ServerlessError (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Error.js:17:11)
    at Serverless._loadPlugins (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:293:17)
    at Serverless.loadProjectPlugins (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:240:10)
    at /Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:77:41
From previous event:
    at Serverless.init (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:73:25)
    at /Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/actions/ProjectInstall.js:213:24
From previous event:
    at ProjectInstall._initProject (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/actions/ProjectInstall.js:208:27)
From previous event:
    at ProjectInstall.installProject (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/actions/ProjectInstall.js:110:12)
From previous event:
    at /Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:181:31
    at Array.reduce (native)
    at /Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:180:32
From previous event:
    at Serverless._execute (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:178:12)
    at Serverless.actions.(anonymous function) (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:424:20)
    at Serverless.command (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/lib/Serverless.js:393:38)
    at /Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/bin/serverless:19:16
    at tryOnImmediate (timers.js:534:15)
    at processImmediate [as _immediateCallback] (timers.js:514:5)
From previous event:
    at Object.<anonymous> (/Users/mhahn/.nvm/versions/node/v5.9.1/lib/node_modules/serverless/bin/serverless:18:4)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:142:18)
    at node.js:939:3

trying to run npm install within the cloned repo results in:

$ npm install
[email protected] /Users/mhahn/labs/serverless-graphql-blog
└── (empty)

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/mhahn/.nvm/versions/node/v5.9.1/bin/node" "/Users/mhahn/.nvm/versions/node/v5.9.1/bin/npm" "install"
npm ERR! node v5.9.1
npm ERR! npm  v3.8.3
npm ERR! path /Users/mhahn/labs/serverless-graphql-blog/node_modules/.staging/serverless-graphql-blog-1c4b69c2
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/Users/mhahn/labs/serverless-graphql-blog/node_modules/.staging/serverless-graphql-blog-1c4b69c2' -> '/Users/mhahn/labs/serverless-graphql-blog'
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/mhahn/labs/serverless-graphql-blog/node_modules/.staging/serverless-graphql-blog-1c4b69c2' -> '/Users/mhahn/labs/serverless-graphql-blog'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/mhahn/.nvm/versions/node/v5.9.1/bin/node" "/Users/mhahn/.nvm/versions/node/v5.9.1/bin/npm" "install"
npm ERR! node v5.9.1
npm ERR! npm  v3.8.3
npm ERR! path npm-debug.log.3086759565
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.3086759565'
npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.3086759565'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mhahn/labs/serverless-graphql-blog/npm-debug.log
npm ERR! code 1

relevant versions:

node: v5.9.1
npm: 3.8.3
serverless: 0.5.0

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.