New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api hasMany
relationships are inconsistently retrieved
#2459
Comments
has many
relationships are inconsistenthasMany
relationships are inconsistently retrieved
Further findings:
Functioning code in frontend that retrieves all messages without issue:
|
Updated lambda code to pull messages via Still keeping ticket open to track issue with |
Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂 |
@AakashKB I have not yet been able to repro this issue. Perhaps this is unrelated, but it looks like your function is returning the original I was able to add both Lastly, does this only happen in Lambda? For reference, here is my reproduction code: // Create parent record:
const { data: conversation } = await client.models.Conversation.create({
title: `${Date.now()}`,
});
// Create Message with parent record:
const { data: message } = await client.models.Message.create({
content: "First Message",
conversation,
});
// Update conversation with last message
const { data: updatedConversation } =
await client.models.Conversation.update({
id: conversation.id,
lastMessage: message,
});
// Retrieve `hasMany` messages:
const { data: newMessages } = await updatedConversation.messages();
console.log("retrieve messages:", newMessages);
// Retrieve last message:
const { data: lastMessage } = await updatedConversation.lastMessage();
console.log("retrieve last message:", lastMessage);
// Create second Message, include parent record:
const { data: secondMessage } = await client.models.Message.create({
content: "Second Message",
conversation,
});
// Update conversation with last message
const { data: updatedConversation2 } =
await client.models.Conversation.update({
id: conversation.id,
lastMessage: secondMessage,
});
// Retrieve `hasMany` messages after second update:
const { data: newMessages2 } = await updatedConversation2.messages();
console.log("retrieve messages after second update:", newMessages2);
// Retrieve last message after second update:
const { data: lastMessage2 } = await updatedConversation2.lastMessage();
console.log("retrieve last message after second update:", lastMessage2); |
@david-mcafee I returned the I logged conversation, messages, etc. at every step of the function, and it consistently confirmed my issues. If you look at my further findings comment above, it seems only difference is whether I directly pull via Still need to verify if only on Lambda, but it consistently does happen at lambda. |
Hi @AakashKB can you upgrade to the latest versions of The code you shared is an older syntax and is no longer valid in the release version of Gen 2. The updated syntax requires a After upgrading, please let us know if the issue persists. |
Environment information
Description
data/resources schema:
addNewMessage():
Using the above code, when I add a
message
to aconversation
then check theconversation.messages
list, I do not always see the newly added messages.It seems very inconsistent, sometimes the messages are added and the other times they are missing. All checked via multiple logs.
Useful info:
lastMessage
property to conversation with ahasOne
relationship, maybe there is confusion on lastMessage vs other messages?Side note:
The text was updated successfully, but these errors were encountered: