Appsync操作Lambda层教程问题

huangapple go评论60阅读模式
英文:

Appsync operations Lambda Layer tutorial issue

问题

我正在按照AWS这里的教程操作:Functions - Exporting AppSync operations to a Lambda layer for easy reuse - JavaScript - AWS Amplify Docs,为我的AppSync GraphQL操作创建一个Lambda Layer,以便在其他Lambda函数中使用。

在按照教程操作时,当我运行packages.json中的脚本中的代码生成部分时,它运行通过,但是完成时显示以下消息:

>成功用Babel编译了0个文件(9毫秒)

看起来一切都指向了正确的位置。我还尝试了在我的Babel脚本命令中指定扩展名。这是我添加到packages.json的脚本:

"updateAppsyncOperations": "amplify api gql-compile && amplify codegen && babel src/graphql --config-file ./babel.config.json -d ./amplify/backend/function/my_function_name/opt/graphql/"

其中my_function_name是Lambda Layer函数的名称。

有没有人按照这个教程成功地完成了操作?我无法弄清楚为什么它没有将我的mutations.jsqueries.jssubscriptions.js添加到Lambda Layer的graphql文件夹中。

英文:

I am following the tutorial from AWS here: Functions - Exporting AppSync operations to a Lambda layer for easy reuse - JavaScript - AWS Amplify Docs to create a Lambda Layer for my AppSync graphql operations to use in other Lambda functions.

In following the tutorial, when I get to the part of running the codegen from the script in packages.json, it runs through but finishes with the message:

>Successfully compiled 0 files with Babel (9ms)

It looks like everything is pointing to the correct locations. I have also tried specifying extensions in my the script command for babel. Here is my script added to packages:

"updateAppsyncOperations": "amplify api gql-compile && amplify codegen && babel src/graphql --config-file ./babel.config.json -d ./amplify/backend/function/my_function_name/opt/graphql/"

where my_function_name is the name of the Lambda Layer function.

Has anyone run though this tutorial and got this to work successfully? I cannot figure out why it is not adding my mutations.js, queries.js and subscriptions.js to the Lambda Layer graphql folder.

答案1

得分: 0

如果其他人遇到了这个问题,问题在于我的Angular项目的代码生成设置生成了 .graphql 文件,这是正确的。然而,Babel 无法编译和复制这些文件,所以我不得不首先在我的 .graphqlconfig.yml 文件中将 codeGenTarget: angular 更改为 codeGenTarget: javascript

在我做了这个改变之后,代码生成器会生成 JavaScript 中的操作,然后将其复制过去。之后,我不得不将它改回为生成 Angular 代码。这不是最好的解决办法,但我不确定还有什么其他尝试的方法。

英文:

If anyone else runs into this issue, the problem was that my codegen settings for my angular project were generating .graphql files, which is correct. Babel could not compile and copy those, so I had to first change the codeGenTarget: angular

to codeGenTarget: javascript in my .graphqlconfig.yml

After I made that change, the codegen generates the operations in javascript which will then be copied over. After that I have to change it back to generate for angular. Not the best solution but I am not sure what else to try.

huangapple
  • 本文由 发表于 2023年2月18日 00:01:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定