I am trying to perform a listItem call with AppSync from my NextJS front-end. I can successfully make the following calls:
- listItems from front-end
- listItems with filter from the AppSync console.
When I try the call I get this error:
Error: Invalid AST Node: { query: "\n query ListCards(\n $filter: ModelCardFilterInput\n $limit: Int\n $nextToken: String\n ) {\n listCards(filter: $filter, limit: $limit, nextToken: $nextToken) {\n items {\n approvedTime\n approvedUser\n canRead\n canUpdate\n clientID\n id\n input\n feedback\n name\n output\n scheduledTime\n status\n type\n createdAt\n updatedAt\n _version\n _deleted\n _lastChangedAt\n }\n nextToken\n startedAt\n }\n }\n", filter: { cardID: [Object] } }.
My failing code:
const listCardsFilteredResponse = (await API.graphql(
graphqlOperation({
query: listCards,
filter: { clientID: { eq: "d9a6c7a2-45b1-48a8-b012-5908d216f86f" } },
})
))
My working js code:
const listCardsResponse = (await API.graphql(
graphqlOperation(listCards)
))
My working query in the AppSync console:
query MyQuery {
listCards(filter: {clientID: {eq: "d9a6c7a2-45b1-48a8-b012-5908d216f86f"}}) {
nextToken
startedAt
items {
id
name
}
}
}
I've looked for similar posts, but I still haven't had any luck.