Miezan
11/17/2017, 5:54 PMquery {
user {
id
posts (# filter by the above id here??) {
postedBy{
id
}
description
}
}
}
agartha
11/17/2017, 6:21 PMposts
is a child of user
, posts
is already filtered by current user
Miezan
11/17/2017, 6:43 PMagartha
11/17/2017, 6:51 PMMiezan
11/17/2017, 7:04 PMchatRooms.users
to show the right user info in the chat header
query rooms {
user {
id
name
auth0UserId
chatRooms {
id
name
topic
users {
id (# filter here to get anyone that is not the current user )
name
picture
}
messages(last:100){
payload
sentBy {
id (# filter here to get message that is not mine )
name
picture
}
}
}
}
}
Here is the schema
type User @model {
id: ID! @isUnique
picture: String
auth0UserId: String @isUnique
chatRooms: [ChatRoom!]! @relation(name: "ChatRoomOnUser")
...
}
type ChatRoom @model {
id: ID! @isUnique
users: [User!]! @relation(name: "ChatRoomOnUser")
messages: [Message!]! @relation(name: "ChatRoomOnMessage")
createdAt: DateTime!
updatedAt: DateTime!
topic: String
name: String @isUnique
}
type Message @model {
chatRoom: ChatRoom! @relation(name: "ChatRoomOnMessage")
id: ID! @isUnique
createdAt: DateTime!
updatedAt: DateTime!
payload: [String!]
sentBy: User! @relation(name: "MessageOnUser")
}
agartha
11/17/2017, 7:07 PMMiezan
11/17/2017, 7:08 PMMiezan
11/17/2017, 7:08 PM