英文:
Serverless App Sync Plugin Resolver Configuration
问题
我试图部署一个无服务器应用程序同步解析器,我正在遵循GitHub上“内联数据源”下的文档。文档建议以下内容应足以创建一个具有内联Lambda数据源的解析器:
以下代码段显示示例:
appSync:
resolvers:
Query.user:
dataSource:
type: 'AWS_LAMBDA'
config:
function:
timeout: 30
handler: 'functions/getUser.handler'
当我尝试按照以下示例进行操作时:
resolvers:
Query.get_data:
dataSource:
type: AWS_LAMBDA
config:
function:
timeout: 30
handler: "functions/get_data.handler"
我收到以下错误:
警告:无效的AppSync配置:
在appSync/resolvers/Query.get_data中:必须具有所需属性 'functions'
在appSync/resolvers中:包含无效的解析器定义
我不确定这个错误的确切含义,如果有人有一个可行的示例,请告诉我,我将很感激,因为这是一个非常简单的示例,几乎完全来自文档。
英文:
I am trying to get a serverless app sync resolver deployed and I am following the documentation on Github under "Inline Datasources". The documentation suggests that the following should be enough to create a resolver with a lambda datasource inline:
The following snippet shows the example:
appSync:
resolvers:
Query.user:
dataSource:
type: 'AWS_LAMBDA'
config:
function:
timeout: 30
handler: 'functions/getUser.handler'
When I try to follow this example (shown below):
resolvers:
Query.get_data:
dataSource:
type: AWS_LAMBDA
config:
function:
timeout: 30
handler: "functions/get_data.handler"
I get the following error:
Warning: Invalid AppSync Configuration:
at appSync/resolvers/Query.get_data: must have required property 'functions'
at appSync/resolvers: contains invalid resolver definitions
I am not sure what this error really means, if someone has got a working example of this I would appreciate seeing where I have gone wrong as its a really simple example and is pretty much straight from the documentation.
答案1
得分: 4
我已解决了这个问题,对于其他人可能会有帮助,我在文档中漏掉了一些东西,这在示例中没有显示, 默认类型是管道解析器,这意味着它需要functions
块。
在我的SLS配置中,向resolvers.Query.my_query
添加kind
属性解决了这个问题:
kind: UNIT
英文:
I have solved this and it might prove helpful for someone else, I was missing something in the docs which is not shown in the example, the default type is pipeline resolver which means it does require the functions block.
Adding the kind
property to resolvers.Query.my_query
in my sls config resolved this issue:
kind: UNIT
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论