Skip to content

Commit

Permalink
Step 7.7: Add Message.chat resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB authored and Urigo committed May 20, 2020
1 parent dedd1d0 commit 110f7b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions schema/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const resolvers: Resolvers = {
Date: DateTimeResolver,
URL: URLResolver,

Message: {
chat(message) {
return chats.find(c => c.messages.some(m => m === message.id)) || null;
},
},

Chat: {
messages(chat) {
return messages.filter((m) => chat.messages.includes(m.id));
Expand Down
1 change: 1 addition & 0 deletions schema/typeDefs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Message {
id: ID!
content: String!
createdAt: Date!
chat: Chat
}

type Chat {
Expand Down

0 comments on commit 110f7b3

Please sign in to comment.