Reactjs AppSync列表查询从JS客户端应用程序返回空数组,但从AppSync控制台返回填充数组
当从AppSync控制台运行列表查询时,我得到一个包含3个项的数组(这是预期的,因为我的DynamoDB表中有三个对应项) 当我从React客户端应用程序运行完全相同的查询时,我得到一个空数组。我尝试过在schema.graphql文件中使用@auth decorator,但到目前为止没有任何效果。当从Postman运行查询时,我也经历了同样的行为——我得到了一个空的items数组 schema.graphql中的类型定义:Reactjs AppSync列表查询从JS客户端应用程序返回空数组,但从AppSync控制台返回填充数组,reactjs,graphql,clojurescript,aws-amplify,aws-appsync,Reactjs,Graphql,Clojurescript,Aws Amplify,Aws Appsync,当从AppSync控制台运行列表查询时,我得到一个包含3个项的数组(这是预期的,因为我的DynamoDB表中有三个对应项) 当我从React客户端应用程序运行完全相同的查询时,我得到一个空数组。我尝试过在schema.graphql文件中使用@auth decorator,但到目前为止没有任何效果。当从Postman运行查询时,我也经历了同样的行为——我得到了一个空的items数组 schema.graphql中的类型定义: type Item @model @auth(rules: [
type Item @model @auth(rules: [
{ allow: owner },
{ allow: public, provider: iam, operations: [read] }]) {
id: ID!
itemName: String!
anotherProperty: String!
anotherProperty: String!
anotherProperty: String!
anotherProperty: String
anotherProperty: AnotherType @connection
anotherProperty: String
anotherProperty: String
anotherProperty: String
anotherProperty: String
anotherProperty: String
anotherProperty: SomeType @connection
anotherProperty: [SomeOtherType] @connection(keyName: "byItemID", fields: ["id"])
anotherProperty: String
anotherProperty: [YetAnotherType] @connection(keyName: "byItemID", fields: ["id"])
}
调用API的客户端代码(ClojureScript):
对来自客户端应用程序的调用的响应:
{"data":{"listItems":{"items":[]}}}
来自AppSync控制台的相同查询:
query ListItems {
listItems {
items {
itemName
}
}
}
{
"data": {
"listItems": {
"items": [
{
"itemName": "Thingy"
},
{
"itemName": "Contraption"
},
{
"itemName": "Apparatus"
}
]
}
}
}
对来自AppSync控制台的调用的响应:
query ListItems {
listItems {
items {
itemName
}
}
}
{
"data": {
"listItems": {
"items": [
{
"itemName": "Thingy"
},
{
"itemName": "Contraption"
},
{
"itemName": "Apparatus"
}
]
}
}
}
我不确定我做错了什么。我怀疑这与@auth设置的权限有关,但我不知道这可能是什么。任何帮助都将不胜感激。提前谢谢 具有身份验证权限的内容。提供者是iam。为什么不在设置中将api auth设置为api key,然后在postman提供数据的情况下尝试一下呢。这样您就知道这是权限问题