我是AppSync的新手,它试图了解它的工作原理以及正确的设置方法。
我创建了schema.graphql如下所示。
type User @model {
id: String!
following: [String]
follower: [String]
journals: [Journal] @connection(name: "UserJournals", sortField: "createdAt")
notifications: [Notification] @connection(name: "UserNotifications", sortField: "createdAt")
}
type Journal @model {
id: ID!
author: User! @connection(name: "UserJournals")
privacy: String!
content: AWSJSON!
loved: [String]
createdAt: String
updatedAt: String
}
,AppSync自动创建了querys.js。
export const getUser = `query GetUser($id: ID!) {
getUser(id: $id) {
id
following
follower
journals {
items {
id
privacy
content
loved
createdAt
updatedAt
}
nextToken
}
notifications {
items {
id
content
category
link
createdAt
}
nextToken
}
}
}
`;
我注意到,查询getUser
仅返回10个journals
项目,并且不确定如何将其设置为10个以上,或者不确定以何种方式查询和向{所查询的10个项目中添加更多日记帐{1}}。
答案 0 :(得分:2)
由于您没有在查询中显式传递limit
参数,因此journals
解析器的“请求映射模板”将其默认设置为10个项目。如果要更改此默认值,请转到AppSync控制台上的架构页面,导航到架构页面“解析器”部分下的journals
字段。然后将显示该字段的解析器定义,然后您可以将默认值 10 更新为所需的任何值。或者,您可以将此作为您的查询参数传递。
FYI-此默认值在GitHub上的 amplify-cli 存储库中定义,可以在here上找到。