forum.graphql 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. type CategoryStatusActive @variant {
  2. # No additional information required
  3. _phantom: Int
  4. }
  5. type CategoryStatusArchived @variant {
  6. "Event the category was archived in"
  7. categoryArchivalStatusUpdatedEvent: CategoryArchivalStatusUpdatedEvent!
  8. }
  9. type CategoryStatusRemoved @variant {
  10. "Event the category was deleted in"
  11. categoryDeletedEvent: CategoryDeletedEvent!
  12. }
  13. union CategoryStatus = CategoryStatusActive | CategoryStatusArchived | CategoryStatusRemoved
  14. type ForumCategory @entity {
  15. "Runtime category id"
  16. id: ID!
  17. "Parent category (if none - this is a root category)"
  18. parent: ForumCategory
  19. "Category title"
  20. title: String!
  21. "Category description"
  22. description: String!
  23. "List of all threads in the category"
  24. threads: [ForumThread!] @derivedFrom(field: "category")
  25. "List of all moderators managing this category"
  26. moderators: [Worker!]
  27. "The event the category was created in"
  28. createdInEvent: CategoryCreatedEvent! @derivedFrom(field: "category")
  29. "Current category status"
  30. status: CategoryStatus!
  31. }
  32. "The thread is visible and editable (unless belongs to archived category)"
  33. type ThreadStatusActive @variant {
  34. # No additional information required
  35. _phantom: Int
  36. }
  37. "The thread is visible, but not editable - it was removed by the author from the runtime state, but the `hide` flag was set to FALSE"
  38. type ThreadStatusLocked @variant {
  39. "Event the thread was deleted (locked) in"
  40. threadDeletedEvent: ThreadDeletedEvent!
  41. }
  42. "The thread is hidden - it was removed by the moderator and the associated stake was slashed"
  43. type ThreadStatusModerated @variant {
  44. "Event the thread was moderated in"
  45. threadModeratedEvent: ThreadModeratedEvent!
  46. }
  47. "The thread is hidden - it was removed by the author and the `hide` flag was set to TRUE"
  48. type ThreadStatusRemoved @variant {
  49. "Event the thread was removed in"
  50. threadDeletedEvent: ThreadDeletedEvent!
  51. }
  52. union ThreadStatus = ThreadStatusActive | ThreadStatusLocked | ThreadStatusModerated | ThreadStatusRemoved
  53. type ForumThread @entity {
  54. "Runtime thread id"
  55. id: ID!
  56. "Author of the forum thread"
  57. author: Membership!
  58. "Category the thread belongs to"
  59. category: ForumCategory!
  60. "Thread title"
  61. title: String! @fulltext(query: "threadsByTitle")
  62. "All posts in the thread"
  63. posts: [ForumPost!] @derivedFrom(field: "thread")
  64. "Optional poll associated with the thread"
  65. poll: ForumPoll @derivedFrom(field: "thread")
  66. "Whether the thread is sticky in the category"
  67. isSticky: Boolean!
  68. "The event the thread was created in"
  69. createdInEvent: ThreadCreatedEvent! @derivedFrom(field: "thread")
  70. "Current thread status"
  71. status: ThreadStatus!
  72. "Theread title update events"
  73. titleUpdates: [ThreadTitleUpdatedEvent!] @derivedFrom(field: "thread")
  74. # Required to create Many-to-Many relation
  75. "The events the thred was made sticky in"
  76. madeStickyInEvents: [CategoryStickyThreadUpdateEvent!] @derivedFrom(field: "newStickyThreads")
  77. "List of events that moved the thread to a different category"
  78. movedInEvents: [ThreadMovedEvent!] @derivedFrom(field: "thread")
  79. }
  80. type ForumPoll @entity {
  81. "The thread the poll belongs to"
  82. thread: ForumThread!
  83. "Poll description"
  84. description: String!
  85. "The time at which the poll ends"
  86. endTime: DateTime!
  87. "List of poll alternatives"
  88. pollAlternatives: [ForumPollAlternative!] @derivedFrom(field: "poll")
  89. }
  90. type ForumPollAlternative @entity {
  91. "Index uniquely identifying the alternative in given poll"
  92. index: Int!
  93. "The related poll"
  94. poll: ForumPoll!
  95. "The alternative text"
  96. text: String!
  97. "List of all associated vote events"
  98. votes: [VoteOnPollEvent!] @derivedFrom(field: "pollAlternative")
  99. }
  100. enum PostReaction {
  101. LIKE
  102. # We may support some other ones in the future...
  103. }
  104. type ForumPostReaction @entity {
  105. "{memberId}-{postId}"
  106. id: ID!
  107. "The member that reacted"
  108. member: Membership!
  109. "The post that has been reacted to"
  110. post: ForumPost!
  111. "The reaction"
  112. reaction: PostReaction!
  113. }
  114. "The post is visible and editable (unless belongs to archived category)"
  115. type PostStatusActive @variant {
  116. # No additional information required
  117. _phantom: Int
  118. }
  119. "The post is visible but not editable - either it wasn't editable to begin with or it was removed from the runtime state, but with `hide` flag beeing set to FALSE"
  120. type PostStatusLocked @variant {
  121. "Post deleted event in case the post became locked through runtime removal"
  122. postDeletedEvent: PostDeletedEvent
  123. }
  124. "The post is hidden - it was removed by the moderator and the associated stake was slashed"
  125. type PostStatusModerated @variant {
  126. "Event the post was moderated in"
  127. postModeratedEvent: PostModeratedEvent!
  128. }
  129. "The post is hidden - it was removed from the runtime state by the author and the `hide` flag was set to TRUE"
  130. type PostStatusRemoved @variant {
  131. "Event the post was removed in"
  132. postDeletedEvent: PostDeletedEvent!
  133. }
  134. union PostStatus = PostStatusActive | PostStatusLocked | PostStatusModerated | PostStatusRemoved
  135. type PostOriginThreadInitial @variant {
  136. "Thread creation event"
  137. # Must be optional because of post<->event cross-relationship
  138. threadCreatedEvent: ThreadCreatedEvent
  139. }
  140. type PostOriginThreadReply @variant {
  141. "Related PostAdded event"
  142. # Must be optional because of post<->event cross-relationship
  143. postAddedEvent: PostAddedEvent
  144. }
  145. union PostOrigin = PostOriginThreadInitial | PostOriginThreadReply
  146. type ForumPost @entity {
  147. "Runtime post id"
  148. id: ID!
  149. "Author of the forum post"
  150. author: Membership!
  151. "Thread the post was submitted in"
  152. thread: ForumThread!
  153. "Content of the post (md-formatted)"
  154. text: String! @fulltext(query: "postsByText")
  155. "A post that this post replies to (if any)"
  156. repliesTo: ForumPost
  157. "Current post status"
  158. status: PostStatus!
  159. "The origin of the post (either thread creation event or regular PostAdded event)"
  160. origin: PostOrigin!
  161. "List of all text update events (edits)"
  162. edits: [PostTextUpdatedEvent!] @derivedFrom(field: "post")
  163. "List of all current post reactions"
  164. reactions: [ForumPostReaction!] @derivedFrom(field: "post")
  165. # Required for PostDeletedEvent One-to-Many relation
  166. "The event the post was deleted in (if any)"
  167. deletedInEvent: PostDeletedEvent
  168. }