Comments (3)
If you could provide the query you are trying to run, and the relevant serverless.yml, then it would be easier to help.
Also, running the emulator with NODE_DEBUG=*
will provide a verbose console.log output. Currently, I am not very familiar with VSCode or inspect-brk
.
Furthermore, it may be helpful to wrap the problem in a try/catch
so that you can inspect the error that's being thrown ( or ignored )
from aws-utils.
I should mention I have forked and made some changes to fit my use case. Got rid of DynamoDBEmulator and subscriptions and added an AWSTimestamp Scalar type.
serverless.yml
service: fake-serverless
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage,'dev'}
plugins:
- serverless-webpack #order matters
- serverless-appsync-offline
- serverless-offline
functions:
getChannel:
handler: functions/getChannel.handler
# startChannel:
# handler: functions/startChannel.handler
custom:
appsync-emulator:
buildPrefix: .webpack/service
webpack:
includeModules: true
appSync:
name: project-name
authenticationType: AWS_IAM
mappingTemplates:
- dataSource: getChannel
type: Query
field: getChannel
request: requests/complete-request.vtl
response: responses/common-response.vtl
dataSources:
- type: AWS_LAMBDA
name: getChannel
config:
functionName: getChannel
serviceRoleArn: { Fn::GetAtt: [backendAdmin, Arn] }
resources:
Resources:
backendAdmin:
Type: AWS::IAM::Role
Properties:
Path: /
RoleName: backendAdmin-${self:provider.stage} # required if you want to use 'serverless deploy --function' later on
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- appsync.amazonaws.com
- sns.amazonaws.com
- ses.amazonaws.com
- s3.amazonaws.com
- sqs.amazonaws.com
Action: sts:AssumeRole
I do have the GraphQL execute request wrapped in a try catch but no exception ever gets caught.
I have looked over the schema, documentAST, variables, and operationName variables and they seem to be the exact same when calling from the debugger or as regular.
One thing is the request that gets made as part of context has some additional fields in the object when not run as normal from the command line. Not sure if that matters?
The request in the context object has the following fields when called with the debugger.
{
...
host: localhost,
hostname: localhost,
xhr: false,
protocol: http
...
}
I can confirm that my web client is connecting to the GraphQL server. The only error I get is in my web client after about 2 minutes...
POST http://localhost:40000/graphql net::ERR_EMPTY_RESPONSE
So for some reason my request is not making it to the resolver when called from the debugger...
My VSCode launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Dev Offline",
"program": "/home/nathanh81/.nvm/versions/node/v8.12.0/lib/node_modules/serverless/bin/serverless",
"args": ["offline", "start"],
"protocol": "inspector",
"runtimeExecutable": "node",
"runtimeArgs": ["--lazy"],
"outFiles": ["${workspaceRoot}/.webpack/service/*"],
"sourceMaps": true,
"cwd": "/home/nathanh81/Projects/appsync-offline/fake-serverless",
"env": {
"NODE_ENV": "development",
"NODE_DEBUG": "*"
// Here we set some environment vars that should be set locally.
// They can and will overwrite the ones coming from your serverless.yml
}
}
]
}
The command line after debugger called
/home/nathanh81/.nvm/versions/node/v8.12.0/bin/node --lazy --inspect-brk=26732 ../../../.nvm/versions/node/v8.12.0/lib/node_modules/serverless/bin/serverless offline start
Debugger listening on ws://127.0.0.1:26732/bb23cc68-6e5c-4616-b3d6-36f4e821b5c6
Debugger attached.
Serverless: Bundling with Webpack...
CLI.js:337
Time: 1228ms
CLI.js:337
Built at: 2019-03-25 14:02:22
Asset Size Chunks Chunk Names
functions/getChannel.js 4.14 KiB functions/getChannel [emitted] functions/getChannel
Entrypoint functions/getChannel = functions/getChannel.js
[./functions/getChannel.js] 214 bytes {functions/getChannel} [built]
Serverless: Watching for changes...
CLI.js:337
this.serverless.schema undefined
index.js:82
Serverless: AppSync started: http://localhost:40000/graphql
CLI.js:337
Serverless: Starting Offline: dev/us-east-1.
CLI.js:337
Serverless: Routes for getChannel:
CLI.js:337
Serverless: (none)
Serverless: Offline listening on http://localhost:3000
from aws-utils.
schema.graphql
schema {
query: Query
}
type Channel {
serverTime: AWSTimestamp
}
type Query {
getChannel(channelName: String, fingerprint: ID): Channel
}
getChannel.js
exports.handler = async (event, context) => {
try {
return {
serverTime: Date.now()
};
} catch (error) {
throw new Error(error);
}
};
from aws-utils.
Related Issues (20)
- Cannot find function config for function : undefined HOT 1
- Failure trying to run tests HOT 3
- ValueMapper: JavaString HOT 2
- Feature request: Aurora (RDS) Serverless support HOT 1
- AppSync Emulator - Support Condition Expressions
- AppSync Emulator - Support $context.stash
- appsync emulator resultItems mapping template example does not work in AWS
- [appsync-emulator-serverless] Does not respect multiple appsSync API's in config HOT 2
- AppSync Emulator - Support RegEx in string split
- Cannot Install on Windows HOT 1
- [appsync-emulator-serverless] Conflicting peer dependencies
- Bug with getting PID by port HOT 9
- Lambda datasource docker HOT 12
- Emulator does not throw error when AppSync does
- AppSync Emulator - AWSEmail and AWSURL HOT 1
- Incorrect string equality in VTL templates HOT 1
- Unable to Invoke lambda function HOT 2
- Mismatch between AWSJSON and AppSync
- Assertions within createSchema method prevent DynamoDB from being null HOT 1
- Incorrect $util.isNullOrEmpty check in appsynce-emulator HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-utils.