jacobhausler / gestalt-list

Re-do of the gestaltCLP backend from gestalt's blog-example
1 stars 0 forks source link

Messages #15

Open slightlytyler opened 8 years ago

slightlytyler commented 8 years ago
jacobhausler commented 8 years ago

Implemented as Conversations and Messages

type Conversation implements Node {
  id:ID!
  createdAt: Date!
  updatedAt: Date!
  subject: String
  refPost: Post @relationship(path:"<-REFERENCED-")
  users: User @relationship(path: "<=CHATTED=")
  messages: Message @relationship(path:"=HELD=>")

}

type Message implements Node {
  id:ID!
  createdAt: Date!
  body: String!
  author: User! @relationship(path:"<-AUTHORED-")
  chat: Conversation! @relationship(path:"<-HELD-")

}
jacobhausler commented 8 years ago

conversations are nodes, so for bullet 4

query{
  node(id:[id]){
    ... as Conversation{
      id
      subject
      users
      etc
    }
  }
}
jacobhausler commented 8 years ago

for all conversations:

query{
  session{
    currentUser{
      conversations{
        $conversationFragment
      }
    }
  }
}
slightlytyler commented 8 years ago

@jacobhausler we'll need to track if messages have been viewed or not and the be able to query for the number that haven't been

slightlytyler commented 8 years ago

Notification might be it's own type actually

jacobhausler commented 8 years ago

Need to figure out the logic of (post and message notifications separately):

jacobhausler commented 8 years ago

going to create 1 sendMessage mutation that takes an optional postId to satisfy 1 and 2

jacobhausler commented 8 years ago

are these email style conversations (many conversations between 2 users) or facebook (1 convo between 2 users); many would be easier

jacobhausler commented 8 years ago

email style conversations will use these two forms of the sendMessage mutation; i don't think we need you to be able to access Conversations directly if the following are true:

##This one takes in optional params to create a new conversation; no chatID = new Conv.
mutation{
  sendMessage(input:{
    clientMutationId:"sendMessage to new conversation"
    toUserId:"ID of receiver"
    refPost: "ID of referenced post"
    subject:"test subject"
    body: "test message body"
  }){
    changedConversation{
      id
      subject
      users{
        id
        fullName
      }
      messages{
        id
        author{
          id
          fullName
        }
        body
      }
    }
  }
}

##This one takes in less params for an existing conversation
mutation{
  sendMessage(input:{
    clientMutationId:"sendMessage to existing conversation"
    body: "test message body"
  }){
    changedConversation{
      id
      subject
      users{
        id
        fullName
      }
      messages{
        id
        author{
          id
          fullName
        }
        body
      }
    }
  }
}