How to get ChatRooms where user A and user B apears in ? GraphQl many to many relation

Viewed 25

I am using AWS AppSync and DynamoDB with Amplify. It has generated listUserChatRooms query where I can get all chatrooms by userID, and all users by chatRoomID but... I have to get all chatrooms where user A and user B apears in.

Here is my GraphQl Schema

type User @model @auth(rules: [
    {allow: owner, operations: [create, read, update, delete]},
    {allow: private, operations: [read]}
]) {
  id: ID!
  name: String!
  chatRooms: [ChatRoom] @manyToMany(relationName: "UserChatRoom") 
}

type ChatRoom @model @auth(rules: [{allow: private}]) {
  id: ID!
  name: String
  topic: String
  Users: [User] @manyToMany(relationName: "UserChatRoom")
  Messages: [Message] @hasMany(indexName: "byChatRoom", fields: ["id"])
}
0 Answers
Related