Git Product home page Git Product logo

aws-utils's People

Contributors

adamclerk avatar aheissenberger avatar asodeur avatar barendb avatar bboure avatar cbaron avatar danifbento avatar devmetal avatar dingosky avatar dirk39 avatar jimmyhurrah avatar lightsofapollo avatar malz avatar marklawlor avatar mattgibson avatar mystogab avatar pianomansam avatar praisegeek avatar set001 avatar zkrige 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-utils's Issues

Version 1.0 Discussion

As mentioned in #91, in order to make the emulator less serverless dependent and more open to other platforms (e.g: amplify), could we discuss a refactoring of this plugin (version 1.0?).

Maybe an approach would be to have this plugin receive a normalized json object containing all the info needed to execute an offline graphQl API. From the top of my head:

  • dynamodb config
  • lambda functions config
  • ... other data source types (pipeline, etc)
  • schema
  • data sources
  • mapping templates
  • general configuration (like ports, etc)

Any external platform using the emulator would be responsible for generating the normalized input json and inject it into the emulator's entry script.
For example, this serverless plugin would need to extract all the info from the Serverless instance/serverless.yml and inject it into createServer().

The advantage is that we don't need to support all different platform that are susceptible of using the emulator.

Drawback is that this forces the use of a wrapper for those platform (emulator would not work "out of the box"). We could imagine though, supporting basic wrappers for popular plugins in a different package.

Any thoughts?

varibales in tables names in serverless.yml

It seems like currenlty emulator does not revognize variables in table names in serverless.yml file.

having such a declaration in yml:
TableName: ens-webhooks-${self:provider.stage}
I'm getting error this error when starting emulator:

{ ValidationException: Invalid table/index name. Table/index names must be between 3 and 255 characters long, and may contain only the characters a-z, A-Z, 0-9, '_', '-', and '.'
it's sad that the error message does not contain actual table name which occures error.

After digging a bit I found that error comes from asw-sdk and the params passed there contain, among all others, such thing:

params: { TableName: 'ens-webhooks-${self:provider.stage}',

am I doing something wrong or emulator indeed does not support variables in yml?

dynamoDB / direct access

How can I use the same dynamodb which is created/used by AppSync Emulator to write/read from a normal lambda function called by serverless-offline?

On which local port can I directly access the dynamodb?

Thanks
Andreas
ps. Thanks for creating the AppSync emulator - great work!

Handle lambda function invocation with webpack

Hi There!

I'm currently working on a project using Appsync with Lambda Resolvers written in Typescript (therefore webpack) I've noticed that the Lambda Runner invokes a child process which doesn't work with '.ts' files. I've managed to fix it on my end by manually prepending "./webpack/service" to handlerPath but this is far from the best way to do it. I think the webpack path could be extracted from the serverless configuration (somewhere) but I'm not sure of the best way to integrate it with the rest of the LambdaSource/LambdaRunner.

Another way to fix this would be to exec serverless invoke local -f ${fn} -d ${payload} however that's significantly different to the way that child processes are currently being handled.

AppSync Emulator - emulator does not enforce strict JSON in VTL templates

{
  "version" : "2017-02-28",
  "operation" : "PutItem",
  "key": {
      "type" : { "S": "Ingredient" },
      "position" : { "N": "$ctx.args.input.position" },
  },
  "attributeValues": {
    "name" : { "S": "$ctx.args.input.name" },
    composition: $util.dynamodb.toMapJson($ctx.args.input.composition),
  }
}

Works in the emulator, but not when deployed to AWS -- composition must be wrapped in double quotes:

{
  "version" : "2017-02-28",
  "operation" : "PutItem",
  "key": {
      "type" : { "S": "Ingredient" },
      "position" : { "N": "$ctx.args.input.position" },
  },
  "attributeValues": {
    "name" : { "S": "$ctx.args.input.name" },
    "composition": $util.dynamodb.toMapJson($ctx.args.input.composition),
  }
}

Not possible to run two instances of appsync-emulator at once on different ports

I'm running the serverless appsync emulator library via serverless appsync offline. I want to be able to have two instances running - one for development and one for locally running browser specs. These need to be on different ports, but when I do this, two instances of mosca are started for the graphql subscriptions and they both use port 3000 on loclahost so they conflict.

I'm not sure if the right solution is to have the serverless emulator choose a random port or to have mosca do it.

serverless appsync-offline start --port 37000
serverless appsync-offline start --port 47000

{"pid":43621,"hostname":"Matts MacBook Pro","name":"mosca","level":50,"time":1556740318814,"msg":"Error starting Mosca Server","v":1}
Serverless: ERROR: Error: listen EADDRINUSE: address already in use :::1883

Can't get specs running on Mac

I'm trying to get the project set up to start some work on adding a new feature, but the README's instructions of just using yarn jest after docker-compose up leads to quite a few failures.

travis.yml seems to show a more complicated setup, but I've as yet not been able to get the specs to all pass even after running the commands in that file. Errors seem to be around python and go lambda code mostly.

Could a section be added to the README showing how to get all the specs to run locally after a clean checkout please? I'm on MacOS 10.14.3.

Merge appsync-emulator-serverless with serverless-appsync-offline

I was wondering if we should merge this repo and https://github.com/aheissenberger/serverless-appsync-offline

Does this repo make sense as a standalone?
I see a couple of refactoring that would simplify everything.
As a Serverless plugin, you receive in the constructor the Serverless instance which I think would remove all the responsibility from the emulator form parsing the yml and instantiating its own (incomplete and wrongly configured) Serverless instance which by the way adds overhead.

If I am not mistaken, The serverless instance would already come with the service object containing everything the emulator needs.

Right now, things like sls offline start ---stage local --profile foo does not work because the dummy Serverless instance (ServerlessConfig) uses dev for stage by default and I assume the default profile.

Or Did I miss something?

Thanks

JavaArray incorrectly extends native Array constructor - causes native functions to not work

I found this issue a couple of days ago but thought it must be a non-issue, but since #70 it has appeared more often.

The JavaArray class extends Array but uses a different constructor signature. Because of this difference, native Array functions cannot work on JavaArrays (especially functions that return new instances of an array such as map).

Internally the native Array.Map function may initialise an Array with new Array(arrayLength) and then populate the indexes. As JavaArray assumes the first parameter will be an array and not a number, it fails on the forEach call.

For example

class NewArray extends Array { constructor(...elements) { super(...elements); console.log('i was called with:', ...elements); } }
const test1 = new NewArray()
// logs: I was called with:
test1.map(() => 1)
// logs: I was called with: 0
const test2 = new NewArray("a", "b", "c")
// logs: I was called with: "a", "b", "c"
test2.map(() => 1)
// logs: I was called with: 3

An alternative way to resolve this issue would be to re-implement the native functions in the JavaArray class

Eslint error on graphql-phone-type dependency

I'm getting this error when trying to install anything that uses the appsync-emulator-serverless package as a dependency. It looks like it is pointing to a forked package of the graphql-phone-type repo which may not have been updated or is broken.

$ npm run clean && npm run lint && npm run build
[###############################################################----------------------------------------------] 534/928

[email protected] clean C:\Users\up175\AppData\Local\Yarn\Cache\v2.tmp\ba08b149d9e36e6bca89db26836f5f97.daaa07a9705b8a4669acd5f98a599ab443cb31d6.prepare
rimraf lib dist es coverage

[email protected] lint C:\Users\up175\AppData\Local\Yarn\Cache\v2.tmp\ba08b149d9e36e6bca89db26836f5f97.daaa07a9705b8a4669acd5f98a599ab443cb31d6.prepare
eslint src demo

C:\Users\up175\AppData\Local\Yarn\Cache\v2.tmp\ba08b149d9e36e6bca89db26836f5f97.daaa07a9705b8a4669acd5f98a599ab443cb31d6.prepare\src\index.js
1:65 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
2:66 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
3:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
4:60 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
5:31 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
6:30 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
7:91 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
8:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
9:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
10:47 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
11:25 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
12:54 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
13:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
14:18 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
15:78 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
16:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
17:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
18:16 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
19:3 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
20:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
21:58 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
22:30 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
23:43 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
24:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
25:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
26:19 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
27:28 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
28:22 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
29:29 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
30:16 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
31:11 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
32:40 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
33:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
34:29 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
35:22 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
36:29 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
37:16 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
38:11 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
39:40 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
40:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
41:51 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
42:8 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
43:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
44:2 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
45:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
46:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

C:\Users\up175\AppData\Local\Yarn\Cache\v2.tmp\ba08b149d9e36e6bca89db26836f5f97.daaa07a9705b8a4669acd5f98a599ab443cb31d6.prepare\demo\index.js
1:31 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
2:39 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
3:31 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
4:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
5:23 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
6:40 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
7:98 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
8:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
9:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
10:30 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
11:10 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
12:18 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
13:5 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

C:\Users\up175\AppData\Local\Yarn\Cache\v2.tmp\ba08b149d9e36e6bca89db26836f5f97.daaa07a9705b8a4669acd5f98a599ab443cb31d6.prepare\demo\schema.js
1:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
2:21 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
3:17 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
4:18 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
5:35 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
6:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
7:35 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
8:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
9:19 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
10:21 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
11:20 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
12:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
13:30 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
14:24 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
15:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
16:44 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
17:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
18:22 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
19:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
20:32 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
21:24 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
22:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
23:37 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
24:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
25:26 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
26:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
27:36 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
28:25 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
29:25 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
30:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
31:44 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
32:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
33:28 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
34:33 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
35:38 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
36:25 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
37:25 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
38:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
39:38 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
40:8 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
41:8 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
42:6 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
43:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

102 problems (102 errors, 0 warnings)
102 errors, 0 warnings potentially fixable with the --fix option.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: eslint src demo
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

yml file inclusion

does emulator currently understand following syntax in serverless.yml?

environment: ${file(config/${self:provider.stage}.yml)}

I use it to sepparate configuration for different stages and it work on AWS but does not in emulator

Appsync emulator - setting defaultAction: DENY has no effect

I want to build an API which is not public and which requires a cognito user pool token for access. I have set defaultAction: DENY in serverless.yml, but there is nothing blocking access when I make a request, provided the JWT I supply in the auth header is actually a JWT. It doesn't fail if the JWT has got nothing to do with the user pool I specified, whereas the actual deployed API refuses access.

Issue with VTL request template

Hi there,

I'm getting the following error when making a GraphQL Query to the appsync emulator.

{ SyntaxError: JSON5: invalid character '$' at 6:17

I narrowed it down to the following request template:

{
    "version" : "2017-02-28",
    "operation": "Invoke",
    "payload": {
    	"body": $util.toJson($context.arguments),
        "tenant": $util.toJson($context.identity.claims['http://tenant'])
    }
}

Specifically, this line "tenant": $util.toJson($context.identity.claims['http://tenant']). This code currently works in production. I can't immediately see anything that might be causing this issue. Although the claims in production are from an OPENID integration with Auth0, could this be the cause?

My request looks like this:

curl -POST --header 'x-api-key: <valid jwt token>'  --url http://localhost:62222/graphql --data '{"operationName":"FetchFiles","variables":{},"query":"query FetchFiles {\n  fetchFiles {\n    name\n    path\n    savedAt\n    createdAt\n    __typename\n  }\n}\n"}' --header 'Content-Type: application/json' -v

Thanks in advance!

appsync-emulator-serverless TypeError: Path must be a string. Received undefined

Hi, i faced an issue and it seem to me an implementation error. I use the serverless-appsync-plugin 1.0.9 version, and the latest from appsync-emulator-serverless. The problem is, the latest appsync plugin implemented a feature that i want to use. The feature is the nested mappingTables support.

So i can make a config like this:

mappingTemplates:
      - ${file(./src/schema/board/board.mapping.yml)}
      - ${file(./src/schema/ticket/ticket.mapping.yml)}
      - ${file(./src/schema/comment/comment.mapping.yml)}
      - ${file(./src/schema/user/user.mapping.yml)}

But when i start this emulator, i got this error instant:

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.join (path.js:1236:7)
    at config.mappingTemplates.reduce (/home/adam/works/serverless/aws/graphql-trello-clone-server/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:307:27)
    at Array.reduce (<anonymous>)
    at generateResolvers (/home/adam/works/serverless/aws/graphql-trello-clone-server/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:299:34)
    at createSchema (/home/adam/works/serverless/aws/graphql-trello-clone-server/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:371:27)
    at createSchema (/home/adam/works/serverless/aws/graphql-trello-clone-server/node_modules/@conduitvc/appsync-emulator-serverless/server.js:70:10)
    at <anonymous>

So i did a little debug, and the issue is came from the reducer. I loged out the config.mappingTemplates variable, and i found the reduce is not able to work properly because its content:

[ [ { dataSource: 'boards',
      type: 'Query',
      field: 'boards',
      request: 'board/mapping/boards-request-mapping-template.txt',
      response: 'board/mapping/boards-response-mapping-template.txt' },
    { dataSource: 'boards',
      type: 'Board',
      field: 'tickets',
      request: 'board/mapping/boards-tickets-request-mapping-template.txt',
      response: 'board/mapping/boards-tickets-response-mapping-template.txt' },
    { dataSource: 'boards',
      type: 'Mutation',
      field: 'createBoard',
      request: 'board/mapping/createBoard-request-mapping-template.txt',
      response: 'board/mapping/createBoard-response-mapping-template.txt' },
    { dataSource: 'boards',
      type: 'Mutation',
      field: 'updateBoard',
      request: 'board/mapping/updateBoard-request-mapping-template.txt',
      response: 'board/mapping/updateBoard-response-mapping-template.txt' },
    { dataSource: 'boards',
      type: 'Mutation',
      field: 'removeBoard',
      request: 'board/mapping/removeBoard-request-mapping-template.txt',
      response: 'board/mapping/removeBoard-response-mapping-template.txt' } ],
  [ { dataSource: 'tickets',
      type: 'Query',
      field: 'ticket',
      request: 'ticket/mapping/ticket-request-mapping-template.txt',
      response: 'ticket/mapping/ticket-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Ticket',
      field: 'board',
      request: 'ticket/mapping/ticket-board-request-mapping-template.txt',
      response: 'ticket/mapping/ticket-board-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Ticket',
      field: 'comments',
      request: 'ticket/mapping/ticket-comments-request-mapping-template.txt',
      response: 'ticket/mapping/ticket-comments-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Mutation',
      field: 'createTicket',
      request: 'ticket/mapping/createTicket-request-mapping-template.txt',
      response: 'ticket/mapping/createTicket-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Mutation',
      field: 'moveTicket',
      request: 'ticket/mapping/moveTicket-request-mapping-template.txt',
      response: 'ticket/mapping/moveTicket-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Mutation',
      field: 'updateTicket',
      request: 'ticket/mapping/updateTicket-request-mapping-template.txt',
      response: 'ticket/mapping/updateTicket-response-mapping-template.txt' },
    { dataSource: 'tickets',
      type: 'Mutation',
      field: 'removeTicket',
      request: 'ticket/mapping/removeTicket-request-mapping-template.txt',
      response: 'ticket/mapping/removeTicket-response-mapping-template.txt' } ],
  [ { dataSource: 'comments',
      type: 'Comment',
      field: 'ticket',
      request: 'comment/mapping/comments-ticket-request-mapping-template.txt',
      response: 'comment/mapping/comments-ticket-response-mapping-template.txt' },
    { dataSource: 'comments',
      type: 'Mutation',
      field: 'commentTicket',
      request: 'comment/mapping/commentTicket-request-mapping-template.txt',
      response: 'comment/mapping/commentTicket-response-mapping-template.txt' },
    { dataSource: 'comments',
      type: 'Mutation',
      field: 'updateComment',
      request: 'comment/mapping/updateComment-request-mapping-template.txt',
      response: 'comment/mapping/updateComment-response-mapping-template.txt' },
    { dataSource: 'comments',
      type: 'Mutation',
      field: 'removeComment',
      request: 'comment/mapping/removeComment-request-mapping-template.txt',
      response: 'comment/mapping/removeComment-response-mapping-template.txt' } ],
  [ { dataSource: 'users',
      type: 'Query',
      field: 'users',
      request: 'user/mapping/users-request-mapping-template.txt',
      response: 'user/mapping/users-response-mapping-template.txt' },
    { dataSource: 'users',
      type: 'Mutation',
      field: 'createUser',
      request: 'user/mapping/createUser-request-mapping-template.txt',
      response: 'user/mapping/createUser-response-mapping-template.txt' },
    { dataSource: 'users',
      type: 'Mutation',
      field: 'login',
      request: 'user/mapping/login-request-mapping-template.txt',
      response: 'user/mapping/login-response-mapping-template.txt' },
    { dataSource: 'users',
      type: 'Mutation',
      field: 'validate',
      request: 'user/mapping/validate-request-mapping-template.txt',
      response: 'user/mapping/validate-response-mapping-template.txt' } ] ]

It not flatten, and i think it may have to be flattened.
And the configuration is 100% working, because i'm able to deploy to aws.

Thank you for this module and great work!

Failure trying to run tests

I have some suspicions about a bug in the VTL portion of the project. Specifically the custom value mapper. I'd like to write a few tests to validate my suspicions. But I cannot get the project working according to the readme.

I'm getting the following:

asciicast

Note: I'm also running npm install before running yarn test. That step is not explicitly called out in the readme. But I assumed it was needed since I'm getting an error from node about missing packages (jest).

Call lambda code using python runtime

Hello,

I'm trying to configure appsync-serverless-emulator to run AppSync and to call some local lambdas.

At this moment the serverless is configured to use python3.6 runtime for the function that I'm trying to call. But, for instance, when I call my Query on GraphQL which should call the respective Lambda, debugging the appsync-emulator-serverless shows that is trying to call a NodeJS version of it. How can I configure the emulator to run also Python code? Or this implementation doesn't work in that way?

And it is possible to call deployed lambdas with the appsync-serverless-emulator offline?

Thanks,

dynamodb-emulator fails to init after failed bounding

When trying to init sls offline start inside a Docker container I receive this message, but the 8000 port is not bounded with anything...

SLS_DEBUG=* NODE_DEBUG=dynamodb* sls offline start

Serverless: Invoke offline:start
ℹ️  dynamodb-emulator launching { retry: 0,
  givenOptions:
   { port: 8000,
     dbPath: '/py-tests/.dynamodb',
     inMemory: false,
     seed: true,
     sharedDb: true,
     delayTransientStatuses: undefined,
     optimizeDbBeforeStartup: undefined } }
ℹ️  dynamodb-emulator Spawning Emulator: { args:
   [ '-Djava.library.path=./DynamoDBLocal_lib',
     '-jar',
     'DynamoDBLocal.jar',
     '-port',
     8000,
     '-dbPath',
     '/py-tests/.dynamodb',
     '-sharedDb' ],
  cwd:
   '/root/.npm_packages/lib/node_modules/serverless-appsync-offline/node_modules/@conduitvc/dynamodb-emulator/emulator' }
ℹ️  dynamodb-emulator Emulator has started but need to verify socket
❌  dynamodb-emulator Port bound but by another process ... time to retry
Serverless: ERROR: Error: 8000 is bound and unavailable

JSON5: invalid character '$'

Attempting to #set a variable that is used in a request template.

This request template works when pushed to AppSync, just not when invoked from serverless-appsync-offline

#set( $limit = $util.defaultIfNull($context.args.limit, 10) )
{
  "version": "2017-02-28",
  "operation": "Scan",
  "limit": $limit
}

I'm getting this error when the $context.args.limit is null

{
  "errors": [
    {
      "message": "JSON5: invalid character '$' at 4:12",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "listOrganizations"
      ]
    }
  ],
  "data": {
    "listOrganizations": null
  }
}

Looks like $limit is not being interpolated correctly?
I've tried this with other $context.args fields and get similar errors.

If I call $util.toJson($context.args) I can see the args, but when I assign them to a variable it throws.

Debugging appsync-emulator-serverless

Wasn't sure if you anyone would be able to help me but worth a shot. I'm trying to run this the appsync-emulator in VSCode by debugging. I can confirm that my application works correctly when running from the command line and serverless offline start but when I run the appsync-server via the node --inspect-brk command with serverless offline start, the query just hangs when it gets to this bit of code in the executeGQL function of serverCore.js

await execute(
      schema,
      documentAST,
      null, // root value
      context,
      variables,
      operationName
    );

Any idea why that might be? I'm not all that familiar with Node.JS so sorry if my question isn't all that clear.

Unable to find logical ref resource for

@lightsofapollo

Since #65 was merged I get this kind of error all over the place.

Error: Unable to find logical ref resource for : AWS::Cognito::UserPool (custom.appSync.userPoolConfig.userPoolId.Ref)

The reason is that the implementation only supports DynamoDb resolution for now and throws an exception on any other resource.

This is a breaking change. Before this, userPoolId being a reference did not cause any problem since the emulator simply ignores/mocks authentication.

This error also occurs in any other resource referencing another, even if not even related to AppSync at all.

I suggest we change this line to fallback to the previous behaviour and simply return value untouched/unresolved, instead of throwing an exception.

AppSync Emulator -- DynamoDB DeleteItem should return deleted item

Found in the docs

After a successful delete, the logs render:

1|server   | [14:18:41] Resolve: Mutation.deleteIngredient [deleteIngredient]
1|server   | [14:18:41] Rendered Request:
1|server   | { version: '2017-02-28',
1|server   |   operation: 'DeleteItem',
1|server   |   key: { type: { S: 'Ingredient' }, position: { N: '1' } } }
1|server   | [14:18:41] Dispatch to source
1|server   | { name: 'TableName', type: 'AMAZON_DYNAMODB' }
1|server   | [14:18:41] Rendered Response:
1|server   | null

Response mapping template:

$utils.toJson($context.result)

dataSources / tableName as Ref not processed / InvalidParameterType: Expected params.TableName to be a string

Using a "Ref: " for tableName is not supported

dataSources:
      - type: AMAZON_DYNAMODB
        name: UsersTableDS
        description: 'Users table'
        config:
          #tableName: conda-test-appsync-ah-users
          tableName: { Ref: UsersTable }
          serviceRoleArn: { Fn::GetAtt: [ DynamoDBRole, Arn ] }

Error:

start Resolve: Query.allUsers [allUsers]
ℹ info Rendered Request:

  { version: '2017-02-28',
    operation: 'Scan',
    limit: 2,
    nextToken: null }
ℹ info Dispatch to source
  { name: 'UsersTableDS', type: 'AMAZON_DYNAMODB' }
✖ error Query.allUsers failed
✖ error InvalidParameterType: Expected params.TableName to be a string
  at ParamValidator.fail (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:50:37)
  at ParamValidator.validateType (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:222:10)
  at ParamValidator.validateString (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:154:32)
  at ParamValidator.validateScalar (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:130:21)
  at ParamValidator.validateMember (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:94:21)
  at ParamValidator.validateStructure (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:75:14)
  at ParamValidator.validateMember (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:88:21)
  at ParamValidator.validate (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/param_validator.js:34:10)
  at Request.VALIDATE_PARAMETERS (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/event_listeners.js:125:42)
  at Request.callListeners (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/sequential_executor.js:109:20)
  at callNextListener (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/sequential_executor.js:99:12)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/event_listeners.js:85:9
  at finish (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/config.js:322:7)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/config.js:340:9
  at Credentials.get (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/credentials.js:126:7)
  at getAsyncCredentials (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/config.js:334:24)
  at Config.getCredentials (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/config.js:354:9)
  at Request.VALIDATE_CREDENTIALS (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/event_listeners.js:80:26)
  at Request.callListeners (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/sequential_executor.js:105:18)
  at Request.emit (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/sequential_executor.js:81:10)
  at Request.emit (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/request.js:683:14)
  at Request.transition (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/request.js:22:10)
  at AcceptorStateMachine.runTo (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/state_machine.js:14:12)
  at Request.runTo (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/request.js:403:15)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/request.js:792:12
  at new Promise (<anonymous>)
  at Request.promise (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/aws-sdk/lib/request.js:778:12)
  at scan (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/dynamodbSource.js:213:29)
  at resolve (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/dynamodbSource.js:387:14)
  at dispatchRequestToSource (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:156:14)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/schema.js:202:33
  at resolveFieldValueOrError (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:531:18)
  at resolveField (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:495:16)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:364:18
  at Array.reduce (<anonymous>)
  at executeFields (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:361:42)
  at executeOperation (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:289:122)
  at executeImpl (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:154:14)
  at execute (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/graphql/execution/execute.js:131:229)
  at executeGQL (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:235:24)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:282:15
  at app.post (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/@conduitvc/appsync-emulator-serverless/serverCore.js:328:13)
  at Layer.handle [as handle_request] (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/layer.js:95:5)
  at next (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/route.js:137:13)
  at Route.dispatch (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/route.js:112:3)
  at Layer.handle [as handle_request] (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/layer.js:95:5)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:281:22
  at Function.process_params (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:335:12)
  at next (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:275:10)
  at cors (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:188:7)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:224:17
  at originCallback (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:214:15)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:219:13
  at optionsCallback (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:199:9)
  at corsMiddleware (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/cors/lib/index.js:204:7)
  at Layer.handle [as handle_request] (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/layer.js:95:5)
  at trim_prefix (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:317:13)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:284:7
  at Function.process_params (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:335:12)
  at next (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/express/lib/router/index.js:275:10)
  at /Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/body-parser/lib/read.js:130:5
  at invokeCallback (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/raw-body/index.js:224:16)
  at done (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/raw-body/index.js:213:7)
  at IncomingMessage.onEnd (/Users/ah/SVN-Checkouts/CONDA/conda-registration-login/server/node_modules/raw-body/index.js:273:7)
  at IncomingMessage.emit (events.js:180:13)
  at IncomingMessage.emit (domain.js:422:20)
  at endReadableNT (_stream_readable.js:1106:12)
  at process._tickCallback (internal/process/next_tick.js:178:19)

There is no problem if { Ref: UsersTable } is replaced with a string - e.g. "appnam-users-table"

ValueMapper: JavaString

I'd like to take a crack at creating a value mapper for Strings in the javaify function.

Any pointers, pitfalls or dragons I need to look out for?

verbose errors: handler file missing

If serverless.yml points to handler file which does not exist, all you will get is error like this:

✖ error Query.getReservations failed
✖ error undefined

There is no way to understand what is going wrong here. Can it be more verbose?

emulator installation error

I would like to play with this emilator but I cant even install it. When trying I get his error:

set@set-home ~/www/foo/bar $ npm install @conduitvc/appsync-emulator-serverless --save-dev
npm WARN deprecated [email protected]: Please upgrade to 2.2.19 or higher
npm WARN deprecated [email protected]: Use uuid module instead

> @conduitvc/[email protected] preinstall /home/set/www/foo/bar/node_modules/@conduitvc/dynamodb-emulator
> ./download.sh

+ download --extract -o emulator https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip
./download.sh: line 3: download: command not found
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@^4.19.1 but none is installed. You must install peer dependencies yourself.
npm WARN @conduitvc/[email protected] requires a peer of aws-appsync@>= 1 but none is installed. You must install peer dependencies yourself.

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @conduitvc/[email protected] preinstall: `./download.sh`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @conduitvc/[email protected] preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/set/.npm/_logs/2018-08-29T15_34_07_622Z-debug.log

Also there are packages like dynamodb-local and serverless-dynamodb-local. Can they be used? is it so necessary do download something from AWS?

Leverage serverless local to run our lambda functions.

We're already bundling serverless (which I am annoyed by but let's make the most if it) so leveraging it with some plugins to run the actual lambdas should be possible and would reduce the amount of surface area we have (particularly for node).

Feature request: Aurora (RDS) Serverless support

First - thank you for this amazing library, I am shocked there are only 39 stars on it!

We are using it serverless-appsync-offline currently. On a new project, we are planning on using Aurora Serverless in appsync (https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-rds-resolvers.html) - while this is technically still only in beta and may explain why support is limited, I'd really like to start using it for our app as its better suited for an RDS then noSQL. But.... I'm incredibly hesitant to start working on anything that I can't do offline/testing on.

So my request is for Aurora emulation that serverless-appsync-offline can use OR a recipe for how to properly emulate this using MySQL locally (if someone has already come across doing this).

Is BatchInvoke supported?

I am trying to use this template for my lambda resolver.

{
    "version": "2017-02-28",
    "operation": "BatchInvoke",
    "payload": $utils.toJson($context)
}

My lambda fails for several reasons:

  1. the lambda is called once for each previously resolved source.
  2. the event params does not come as an array.

I believe that BatchInvoke is not supported?

Mutation triggers subscription resolver

When running a mutation that has a subscription it seems to trigger the subscription resolver, I'm under the impression that the subscription resolver should only be triggered on the initial subscription registration and that the data published to the subscription should be the return payload of the mutation.

From the appsync devguide
"Subscriptions are triggered from mutations and the mutation selection set is sent to subscribers."
...
"Although the subscription query is needed for client connections and tooling, the selection set that is received by subscribers is specified by the client triggering the mutation."

I use a resolver to authorize subscriptions as described in the security section of the devguide
response mapping returns null to continue or $utils.unauthorized() to fail.

It seems the emulator is using the resolver mapping for the subscription on the data, which in my case results in the published data to be null

My code works fine in appsync but not in the emulator, Any thoughts on this?

make Dynamodb optional?

Hi all,

For what I can understand from doc and code, dynamodb seems to be required, whether it's dynamodb local or a custom dynamodb server.
I am not using dynamodb at all in my project (neither with resolvers, nor from lambda). I just use Lambda and a neo4j DB.
I was looking for a way to skip any dynamodb from starting with the emulator but I don't think it's possible.
Did I miss something?

I am using this package in association with https://github.com/aheissenberger/serverless-appsync-offline

Did I miss something? is this something possible?
And should we consider making it optional?
I would be open to make a PR for that.

Cannot find function config for function : undefined

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)

Handle no appsync resources config

The serverless appsync framework does not require a resources section in the config file.

I have a project that is Lambda only and does not access any DynamoDB tables, meaning I do not need (or have) a resources section in my serverless.yml file. The project deploys to AWS AppSync with no issues. I cannot, however, use the appsync emulator since the missing resources config faults.

appsync-serverless-emulator: how to work with subscriptions

I'm testing this with GraphQl Playground (connected to http://localhost:62222/graphql) - mutations and queries working fine but it I'm trying to run subscription I'm getting this error:

{
  "error": "Could not connect to websocket endpoint ws://localhost:62222/graphql. Please check if the endpoint url is correct."
}

should I connect playground elsewhere or how do I make this work?

when I start emulator I got this:

started at url: http://localhost:62222/graphql

so - no mentions that it is listening websockets

Appsync emulator with Docker container

Good day everyone! I try to build my project which uses appsync-emulator-serverless with Docker with node:8.12 image. But I get errors with npm install.

Does somebody successfully started the project with docker (if I run the project directly on host machine with ArchLinux, all are working fine)? Thank you!

My Dockerfile:

FROM node:8.12

RUN mkdir -p /appsync
WORKDIR /appsync

RUN apt-get update && \
    apt-get install -y build-essential bzip2 default-jre g++ \
    libkrb5-dev libzmq3-dev make python2.7 zip unzip

COPY . .
RUN npm install

EXPOSE 62222
CMD ["npm", "start"]

Errors:

Unable to install appsync-emulator-serverless

I'm getting error when installing appsync-emulator-serverless
by running command npm i @conduitvc/appsync-emulator-serverless
Here is the logs:

84 verbose stack Error: Non-registry package missing package.json: graphql-phone-type@git+https://github.com/pianomansam/graphql-phone-type.git.
84 verbose stack     at BB.join (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/pacote/lib/finalize-manifest.js:162:23)
84 verbose stack     at tryCatcher (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
84 verbose stack     at Holder$5._callFunction (eval at generateHolderClass (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:92:16), <anonymous>:14:44)
84 verbose stack     at Holder$5.checkFulfillment (eval at generateHolderClass (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:92:16), <anonymous>:29:30)
84 verbose stack     at Promise.eval (eval at thenCallback (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/join.js:14:16), <anonymous>:6:20)
84 verbose stack     at Promise._settlePromise (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:566:21)
84 verbose stack     at Promise._settlePromise0 (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
84 verbose stack     at Promise._settlePromises (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
84 verbose stack     at Promise._fulfill (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
84 verbose stack     at Object.<anonymous> (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/bluebird/js/release/nodeback.js:42:21)
84 verbose stack     at emitNone (events.js:111:20)
84 verbose stack     at Object.emit (events.js:208:7)
84 verbose stack     at Object.Parser.on._ (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/tar/lib/parse.js:75:14)
84 verbose stack     at emitTwo (events.js:126:13)
84 verbose stack     at Object.emit (events.js:214:7)
84 verbose stack     at Object.[emit] (/home/eeren/.nvm/versions/node/v8.16.0/lib/node_modules/npm/node_modules/tar/lib/parse.js:229:12)
85 verbose cwd /home/eeren/Projects/src/consumers
86 verbose Linux 4.18.0-18-generic
87 verbose argv "/home/eeren/.nvm/versions/node/v8.16.0/bin/node" "/home/eeren/.nvm/versions/node/v8.16.0/bin/npm" "i" "@conduitvc/appsync-emulator-serverless"
88 verbose node v8.16.0
89 verbose npm  v6.4.1
90 error code ENOPACKAGEJSON
91 error package.json Non-registry package missing package.json: graphql-phone-type@git+https://github.com/pianomansam/graphql-phone-type.git.
92 error package.json npm can't find a package.json file in your current directory.
93 verbose exit [ 1, true ]

Anyone know how to solve it ? Thanks

Merge graphql-phone-type into aws-utils

appsync-emulator-serverless depends on https://github.com/pianomansam/graphql-phone-type which is to minor fork of https://github.com/enniel/graphql-phone-type

Instead of relying on the fork, it may be useful to roll that package into this monorepo and publish it under the @conduitvc scope. Either that or push the changes back upstream to the original package

@pianomansam

There are some minor updates I'd like to perform on the package, such as renaming its prepare script to something else as it is causing intermittent issues within my CI environment. But I'd prefer for this repo formalise which package it is using before I do the PR.

appsync-emulator-serverless: AWSDate/Time won't work with introspection query and input fields

I think I bumped into two issues with the current implementation of AWSDate/Time.

In introspection queries AWSDate/Time fields show-up as Date/Time because graphql-iso-date.GraphQLDate/Time have a name attribute w/o the AWS prefix.

For AWSDate/Time inputs (both literals and values) the current implementation is doing too much. The string dates get parsed into DateTime. However, AppSync seems to expect string representations of date/time.

The fix below seems to work but is not very elegant ...

const AWSDate = new GraphQLScalarType({
    name: "AWSDate",
    description: GraphQLDate.description,
    serialize(value) {
      return GraphQLDate._scalarConfig.serialize
    },
    parseValue(value) {
      return GraphQLDate._scalarConfig.parseValue(value) ? value : null
    },
    parseLiteral(value) {
      return GraphQLDate._scalarConfig.parseLiteral(value) ? value.value : null
    }
});

const AWSTime = new GraphQLScalarType({
    name: "AWSTime",
    description: GraphQLTime.description,
    serialize(value) {
      return GraphQLTime._scalarConfig.serialize
    },
    parseValue(value) {
      return GraphQLTime._scalarConfig.parseValue(value) ? value : null
    },
    parseLiteral(value) {
      return GraphQLTime._scalarConfig.parseLiteral(value) ? value.value : null
    }
});

const AWSDateTime = new GraphQLScalarType({
    name: "AWSDateTime",
    description: GraphQLDateTime.description,
    serialize(value) {
      return GraphQLDateTime._scalarConfig.serialize
    },
    parseValue(value) {
      return GraphQLDateTime._scalarConfig.parseValue(value) ? value : null
    },
    parseLiteral(value) {
      return GraphQLDateTime._scalarConfig.parseLiteral(value) ? value.value : null
    }
});

Serverless Appsync Offline quits on Serverless 1.33

This is a cross post from the main issue I submitted on Serverless Appsync Offline.

When running serverless appsync-offline start, ever since upgrading to Serverless 1.33, the command quits as soon as the GraphQL server comes up. From my logs, when using nodemon:

ℹ️  appsync-emulator:serverCore server bound { address: '::', family: 'IPv6', port: 62222 }
Serverless: AppSync started: http://localhost:62222/graphql
[nodemon] clean exit - waiting for changes before restart

You'll notice that while it exits cleanly, it doesn't do any of the cleanup. Otherwise we would see a line like AppSync offline - stopping graphql and dynamoDB.

I'm not sure if the bug is in this library or Serverless Appsync Offline.

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.