Longyang Zhang
09/17/2021, 4:08 AMsst start
command not watching the code changes anymore if the code located under src/notes
folder.
Initially followed the graphql-appsync example which was working fine. Just wondering whether SST supports that? Or maybe something wrong with my setup? ThanksLongyang Zhang
09/17/2021, 4:08 AM```
import * as sst from "@serverless-stack/resources";
import * as appsync from '@aws-cdk/aws-appsync';
import * as lambda from '@aws-cdk/aws-lambda';
import * as db from '@aws-cdk/aws-dynamodb';
export class AppsyncSstStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
super(scope, id, props);
const api = new appsync.GraphqlApi(this, `${scope.stage}-AppSyncApi`, {
name: `${scope.stage}-AppSyncApi`,
schema: appsync.Schema.fromAsset('graphql/schema.graphql'),
})
const noteTable = new db.Table(this, 'Notes', {
partitionKey: { name: 'id', type: db.AttributeType.STRING },
})
const notesQueryHandler = new lambda.Function(this, 'QueryDataHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromAsset('src/notes'),
handler: 'index.handler',
environment: {
NOTES_TABLE: noteTable.tableName,
},
})
noteTable.grantFullAccess(notesQueryHandler)
const notesDataSource = api.addLambdaDataSource("notesDataSrouce", notesQueryHandler);
notesDataSource.createResolver({
typeName: 'Query',
fieldName: 'getNoteById'
})
}
}
```
Longyang Zhang
09/17/2021, 10:52 AMsst-debug.log
, with above code, the code under src/notes
doesn’t seem to be watched.
Well for the graphql-appsync example code, can see lambda-watcher-state
in the log with "entryPointsData":{"./src/notes/main.handler"
Longyang Zhang
09/17/2021, 10:53 AMLongyang Zhang
09/17/2021, 8:53 PMFrank
sst.Function
. You can try defining your Lambda function above like this:
const notesQueryHandler = new sst.Function(this, 'QueryDataHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'src/notes/index.handler',
environment: {
NOTES_TABLE: noteTable.tableName,
},
})
Frank
Longyang Zhang
09/17/2021, 11:33 PM