Closed dantasfiles closed 4 years ago
In this sample app, in order to display the messages of a conversation, a "getConvo" query is used, which returns the conversation and its messages.
type Conversation @model (mutations: { create: "createConvo" }, queries: { get: "getConvo" }, subscriptions: null) { id: ID! messages: [Message] @connection(name: "ConvoMsgs", sortField: "createdAt") ... } type Message @model(subscriptions: null, queries: null) { id: ID! conversation: Conversation! @connection(name: "ConvoMsgs") messageConversationId: ID! ... } type Subscription { onCreateMessage(messageConversationId: ID!): Message @aws_subscribe(mutations: ["createMessage"]) }
However, in many of the sample apps from @dabit3 , like conference app in a box, he uses a different style of getting messages, with a "listMessagesByConversationId" query, and a keyfield on the connection between conversations and messages
type Conversation @model { id: ID! messages: [Message] @connection(name: "ConvoMsgs", keyfield: "messageConversationId") ... } type Message @model { id: ID! conversation: Conversation! @connection(name: "ConvoMsgs", sortField: "createdAt", keyfield: "messageConversationId") messageConversationId: ID! ... } type Query { listMessagesByConversationId(messageConversationId: ID!): ModelMessageConnection } type Subscription { onCreateMessageWithId(messageConversationId: ID!): Message @aws_subscribe(mutations: ["createMessage"]) }
Is one method more efficient than the other in cost or speed, or are they very similar?
In this sample app, in order to display the messages of a conversation, a "getConvo" query is used, which returns the conversation and its messages.
However, in many of the sample apps from @dabit3 , like conference app in a box, he uses a different style of getting messages, with a "listMessagesByConversationId" query, and a keyfield on the connection between conversations and messages
Is one method more efficient than the other in cost or speed, or are they very similar?