I'm new to AppSync and trying to see how this works and what's the proper way to set this up.
I created schema.graphql looks like below.
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
}
and this created queries.js automatically by AppSync.
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
}
}
}
`;
I noticed that querying getUser
only returns 10 journals
items and not sure how to set that to more than 10 or proper way to query and add more journals into that 10 items that were queried by getUser
.
Since you do not pass the limit
argument explicitly in your query, the Request Mapping Template of the journals
resolver defaults it to 10 items. If you would like to change this default value, go to your schema page on the AppSync console, navigate to the journals
field, found under the Resolvers section of the schema page. This will then show the resolver definition for this field, and you can then update the default value of 10 to anything you like. Alternatively, you can pass this as your query argument.
FYI - This default value is defined in the amplify-cli repo on GitHub and can be found here.