I am building a CDK stack using GithubActions.
The package builds successfully until I add an AppSync resolver using resolver code from an asset. Weirdly, the appsync.SchemaFile.fromAsset()
using the exact same directory works just fine. It's just the resolver appsync.Code.fromAsset()
that fails?
The error message from GitHub Actions output is:
Error: Cannot find asset at /home/runner/work/Website/Website/lib/graphql/putProduct.js
The code:
const api = new appsync.GraphqlApi(this, 'api', {
name: 'api',
definition: {
schema: appsync.SchemaFile.fromAsset('lib/graphql/schema.graphql')
},
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.USER_POOL,
userPoolConfig: {userPool: userPool},
},
additionalAuthorizationModes: [
{authorizationType: appsync.AuthorizationType.API_KEY}
]
},
})
const apiDataSource = api.addDynamoDbDataSource('table', userProduct)
new appsync.Resolver(this, 'putProductResolver', {
api: api,
fieldName: 'putProduct',
typeName: 'Mutation',
code: appsync.Code.fromAsset('lib/graphql/putProduct.js'),
dataSource: apiDataSource,
runtime: appsync.FunctionRuntime.JS_1_0_0,
})
I found out that the package I had cloned had a .gitignore exclusion of *.js so these files weren't being included (facepalm)