little-bear-labs / aws-utils Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
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:
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?
Since this commit: acad449
I am getting this error when doing
$utils.toJson($context)
.
This happens I believe because there must have some circular reference in the request object https://github.com/ConduitVC/aws-utils/blob/master/packages/appsync-emulator-serverless/serverCore.js#L280
There are a lot of things that may go wrong while executing create
in emulators jest beforeEach block.
I propose to wrap it in try/catch
block
something like this:
beforeEach(async () => {
try{
state.server = await create();
}catch(e){
console.error("ERROR:", e)
}
it helps to understand what is going wrong
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?
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!
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.
{
"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),
}
}
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
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.
do you have any plans to split what is in packages into stand-alone repositories? Seems like it would be easier to maintain them
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
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
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.
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
I see that AWSJSON support was added recently
It would be great if this supported all custom AWS scalars just like serverless-appsync-plugin.
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.
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!
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!
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:
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).
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,
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
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.
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.
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.
DynamoDB query/scan resolvers always return nextToken: null
. The issue seems to be that the cursor is not named NextToken
but LastEvaluatedKey
in the DynamoDB result.
Additionally AppSync obfuscates the cursor in some way (details are not documented AFAIK).
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)
Honor the serverless.yml optional mappingTemplatesLocation config value to override the default location of 'mapping-templates'.
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 ] }
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"
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?
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?
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?
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).
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).
AppSync now supports multistep resolvers called Pipeline Resolvers. And serverless-appsync-plugin provides support for them on AWS. It would be great to support this locally well!
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:
event
params does not come as an array.I believe that BatchInvoke
is not supported?
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?
AppSync offers quite some functionality to respond to failing condition checks, see.
I'll provide a PR that covers the simple cases for PutItem
resolvers soon.
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.
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)
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.
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
Hello
I have seen some pretty critical PR's be approved recently yet the npm package hasn't been published for 2months: https://www.npmjs.com/package/@conduitvc/aws-utils
Is there any update on why this is the case and when it will be republished next?
Thankyou!
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:
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
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
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.
I am waiting for new features already merged.
The latest version of appsync-emulator-serverless published in NPM is still 0.7.3.
I want to know when the new version will be published.
Thank you :)
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
}
});
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.