【发布时间】:2019-03-05 21:53:51
【问题描述】:
我正在尝试获取属于特定用户名的宠物列表。
表格设计(PetTable):
username: partition key
petId: sort key,
petId 的值是通过连接字符串“petId:”和随机的 autoId 值生成的。所以,如果autoId是3838380022,那么petId排序键的值就是“petId:3838380022”
架构:
type Pet {
username: String!
petId: ID!
}
type PetsConnection {
pets: [Pet]
}
type Query {
getPets(username: String): PetsConnection
}
解析器:
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
## Provide a query expression. **
"expression": "username = :username and begins_with(petId, :petId)",
"expressionValues" : {
":username" : {
"S" : "${ctx.args.username}"
},
":petId" : {
"S" : "pet"
}
}
}
}
查询:
query GetUserPets {
getPets(username: "test") {
pets {
petId
}
}
}
查询响应:
{
"data": {
"getPets": {
"pets": null
}
}
}
在 Dynamodb 中,我有 2 个整体,其中 petId(SortKey) 以文本 pet.
开头期望查询应该返回 2 个条目,但它不返回任何内容。不知道错误在哪里。任何帮助将不胜感激。谢谢。
【问题讨论】:
标签: amazon-dynamodb graphql aws-appsync