【发布时间】:2019-10-22 15:41:39
【问题描述】:
我的schema.graphql 文件通过运行amplify push 命令在graphql/queries.js 文件中的查询下方自动生成。
这是自动生成查询的架构文件。
schema.graphql
type User @model {
id: String!
uuid: String!
following: [String]
follower: [String]
posts: [Post] @connection(name: "Userposts", sortField: "createdAt")
}
type Post
@model
@auth(
rules: [
{ allow: owner },
{ allow: groups, groups: ["Admin"] }
]
) {
id: ID!
author: User! @connection(name: "Userposts")
status: Status!
draft: Boolean
content: AWSJSON!
loved: [String]
comments: [Comment] @connection(name: "PostComments", sortField: "createdAt")
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
enum Status {
PRIVATE
PUBLIC
}
这是由 schema graphql 生成的查询。
queries.js
export const getUser = `query GetUser($id: ID!) {
getUser(id: $id) {
id
uuid
following
follower
posts(limit: 10, sortDirection: DESC) {
items {
id
privacy
draft
content
loved
createdAt
updatedAt
}
nextToken
}
notifications {
items {
id
content
category
link
createdAt
}
nextToken
}
}
}
`;
我将(limit: 10, sortDirection: DESC) 添加到posts 以获取用户的10 个最新帖子,但无法弄清楚如何在第一次查询后传递nextToken 值以获取另外10 个帖子。
如何将nextToken 值传递给帖子,以便获得接下来的 10 个帖子?
【问题讨论】:
-
你介意分享你的 schema.graphql 吗?
-
添加了架构!
标签: graphql aws-amplify aws-appsync