Note: If your question is regarding the AWS Amplify Console service, please log it in the
official AWS Amplify Console forum
Which Category is your question related to?
src/graphql so I don't duplicate mutations. Should I copy the schema in each lambda function? or other ways?You can use amplify -v to check the amplify cli version on your system
What AWS Services are you utilizing?
amplify, lambda
Provide additional details e.g. code snippets
{
"data": {
"getSomeThing": null
},
"errors": [
{
"path": [
"getSomeThing"
],
"data": null,
"errorType": "Lambda:Unhandled",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Error: Cannot find module '../../../../../../src/graphql/es2015/mutations'"
}
]
}
@gautamkshitij the current tooling does not have out of box support for this kind of code sharing as it can be done in a lot of different ways from published packages to local file copying during the build process. The generated source files are outside of the lambda directory and are not deployed with the lambda, hence the error message. As you've stated you've to add this functionality to your project that fit your needs. Either as a script or some other ways.
Personally when I was in this situation I had a node package in the root of my repository and followed yalc guide to allow me to reference local packages in a clean way. It still requires yarn like commands to keep up to date with the references, but it worked well for me.
I'm closing the issue are the question is answered, if you have other related question feel free to reopen the issue or create a new one.
Most helpful comment
@gautamkshitij the current tooling does not have out of box support for this kind of code sharing as it can be done in a lot of different ways from published packages to local file copying during the build process. The generated source files are outside of the lambda directory and are not deployed with the lambda, hence the error message. As you've stated you've to add this functionality to your project that fit your needs. Either as a script or some other ways.
Personally when I was in this situation I had a node package in the root of my repository and followed yalc guide to allow me to reference local packages in a clean way. It still requires yarn like commands to keep up to date with the references, but it worked well for me.
I'm closing the issue are the question is answered, if you have other related question feel free to reopen the issue or create a new one.