little-bear-labs / aws-utils

Apache License 2.0
56 stars 35 forks source link

Cannot find function config for function : undefined #122

Open eerenwong opened 5 years ago

eerenwong commented 5 years ago

Did anyone know how to solve this issue?

My project DynamoDB is start separately serverless dynamodb start --stage dev

Appsync emulator command: yarn appsync-emulator --port 62222

Mutation:

mutation createData{
    createData(
        name:"John"
        gender: 0
        mobile: "123456789"
    ) {
        id
    }
}

Mapping Template VTL:

  #set( $data = $context )
  #set( $data.arguments.id = "$util.autoId()" )
  #set( $data.arguments.user_id = "\${context.identity.name}" )
  #set( $data.arguments.created_by = "\${context.identity.name}" )
  {
    "version" : "2017-02-28",
    "operation": "Invoke",
    "payload": {
      "resolve": "CREATE.DATA",
      "context": $util.toJson($data)
    }
  }

When I run test and came out this:

✖ error Mutation.createData failed
✖ error Error: Cannot find function config for function : undefined
    at lambdaSource (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/lambdaSource.js:22:11)
    at dispatchRequestToSource (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:173:14)
    at /home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:244:29
    at resolveFieldValueOrError (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:531:18)
    at resolveField (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:495:16)
    at /home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:339:18
    at /home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/jsutils/promiseReduce.js:25:10
    at Array.reduce (<anonymous>)
    at promiseReduce (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/jsutils/promiseReduce.js:22:17)
    at executeFieldsSerially (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:336:38)
    at executeOperation (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:289:55)
    at executeImpl (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:154:14)
    at execute (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/node_modules/graphql/execution/execute.js:131:229)
    at executeGQL (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:235:24)
    at /home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:286:17
    at app.post (/home/User/Projects/example/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:355:13)
    at Layer.handle [as handle_request] (/home/User/Projects/example/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/User/Projects/example/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/User/Projects/example/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/User/Projects/example/node_modules/express/lib/router/layer.js:95:5)
    at /home/User/Projects/example/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/User/Projects/example/node_modules/express/lib/router/index.js:335:12)
    at next (/home/User/Projects/example/node_modules/express/lib/router/index.js:275:10)
    at cors (/home/User/Projects/example/node_modules/cors/lib/index.js:188:7)
    at /home/User/Projects/example/node_modules/cors/lib/index.js:224:17
    at originCallback (/home/User/Projects/example/node_modules/cors/lib/index.js:214:15)
    at /home/User/Projects/example/node_modules/cors/lib/index.js:219:13
    at optionsCallback (/home/User/Projects/example/node_modules/cors/lib/index.js:199:9)
    at corsMiddleware (/home/User/Projects/example/node_modules/cors/lib/index.js:204:7)
    at Layer.handle [as handle_request] (/home/User/Projects/example/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/User/Projects/example/node_modules/express/lib/router/index.js:317:13)
    at /home/User/Projects/example/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/User/Projects/example/node_modules/express/lib/router/index.js:335:12)
    at next (/home/User/Projects/example/node_modules/express/lib/router/index.js:275:10)
    at /home/User/Projects/example/node_modules/body-parser/lib/read.js:130:5
    at invokeCallback (/home/User/Projects/example/node_modules/raw-body/index.js:224:16)
    at done (/home/User/Projects/example/node_modules/raw-body/index.js:213:7)
    at IncomingMessage.onEnd (/home/User/Projects/example/node_modules/raw-body/index.js:273:7)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickDomainCallback (internal/process/next_tick.js:219:9)
cbaron commented 5 years ago

@eerenwong -- looks like your serverless config thinks this mutation has a lambda data source.

Check out the example config which shows you how to create a mutation with a dynamo data source