I've used Amplify to generate AppSync schema and GraphQL resolvers automatically. All of sudden, a major fetch stopped working. This is the query that I am running in the AppSync console:
query CreamByUuid {
creamByUUID(streamUUID: "6e1a5555-9999-6666-84c1-54e777777777", id: {}) {
items {
id
}
nextToken
}
milkBySlug(slug: "cherry-rare-solo-appearance") {
nextToken
items {
price
id
}
}
getCream(id: "77bababa-8888-3333-bb2b-857c470d5555") {
id
creamUUID
}
}
The first part is a GSI that fetches a stream by a field called the “creamUUID”. The problem is, the result returns an empty array:
{
"data": {
"creamByUUID": {
"items": [],
"nextToken": null
},
"milkBySlug": {
"nextToken": null,
"items": [
{
"price": 7,
"id": "17e50e71-ay7d-8382-1098-25c616444444"
}
]
},
"getCream": {
"id": "77bababa-8888-3333-bb2b-857c470d5555",
"creamUUID": "6e1a5555-9999-6666-84c1-54e777777777"
},
}
}
I’ve tested another GSI, milkBySlug, to make sure it’s not a broader GSI issue. As you see though, I am correctly getting an item back.
More troubling, when I fetch the Cream by its ID, I actually get the Cream record back (“getCream” returns the record with a creamUUID of “6e1a5555-9999-6666-84c1-54e777777777”)
So the Cream record exists in DynamoDB, and a direct query of it using an ID returns it. But a GSI creamByUUID with the creamUUID returns an empty array.
The resolver is autogenerated by amplify push, and I can share that if it is helpful. The queries I’m making are directly within the AWS console, so it can’t be a coding error on my part…
Can anyone help? I'm out of ideas about why the creamByUUID returns an empty array when it should return the Cream record with ID 77bababa-8888-3333-bb2b-857c470d5555
Thanks for this heads up - in my case I couldn't figure out why some queries would return an empty array, while others would return partial data, it made no sense at all. Removing a GSI on a different model, that had the same @key name and queryfield fixed the problem.
I agree that amplify should warn the user!