forum.graphql 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. "Number of non-deleted posts in the thread"
  65. visiblePostsCount: Int!
  66. "Optional poll associated with the thread"
  67. poll: ForumPoll @derivedFrom(field: "thread")
  68. "Whether the thread is sticky in the category"
  69. isSticky: Boolean!
  70. "The event the thread was created in"
  71. createdInEvent: ThreadCreatedEvent! @derivedFrom(field: "thread")
  72. "Current thread status"
  73. status: ThreadStatus!
  74. "Theread metadata update events"
  75. metadataUpdates: [ThreadMetadataUpdatedEvent!] @derivedFrom(field: "thread")
  76. # Required to create Many-to-Many relation
  77. "The events the thred was made sticky in"
  78. madeStickyInEvents: [CategoryStickyThreadUpdateEvent!] @derivedFrom(field: "newStickyThreads")
  79. "List of events that moved the thread to a different category"
  80. movedInEvents: [ThreadMovedEvent!] @derivedFrom(field: "thread")
  81. "Assigned thread tags"
  82. tags: [ForumThreadTag!]
  83. }
  84. type ForumThreadTag @entity {
  85. "Tag id (and simultaneously - tag label)"
  86. id: ID!
  87. "Forum threads assigned to the tag"
  88. threads: [ForumThread!] @derivedFrom(field: "tags")
  89. "Number of non-removed threads currently assigned to the tag"
  90. visibleThreadsCount: Int!
  91. }
  92. type ForumPoll @entity {
  93. "The thread the poll belongs to"
  94. thread: ForumThread!
  95. "Poll description"
  96. description: String!
  97. "The time at which the poll ends"
  98. endTime: DateTime!
  99. "List of poll alternatives"
  100. pollAlternatives: [ForumPollAlternative!] @derivedFrom(field: "poll")
  101. }
  102. type ForumPollAlternative @entity {
  103. "Index uniquely identifying the alternative in given poll"
  104. index: Int!
  105. "The related poll"
  106. poll: ForumPoll!
  107. "The alternative text"
  108. text: String!
  109. "List of all associated vote events"
  110. votes: [VoteOnPollEvent!] @derivedFrom(field: "pollAlternative")
  111. }
  112. enum PostReaction {
  113. LIKE
  114. # We may support some other ones in the future...
  115. }
  116. type ForumPostReaction @entity {
  117. "{memberId}-{postId}"
  118. id: ID!
  119. "The member that reacted"
  120. member: Membership!
  121. "The post that has been reacted to"
  122. post: ForumPost!
  123. "The reaction"
  124. reaction: PostReaction!
  125. }
  126. "The post is visible and editable (unless belongs to archived category)"
  127. type PostStatusActive @variant {
  128. # No additional information required
  129. _phantom: Int
  130. }
  131. "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"
  132. type PostStatusLocked @variant {
  133. "Post deleted event in case the post became locked through runtime removal"
  134. postDeletedEvent: PostDeletedEvent
  135. }
  136. "The post is hidden - it was removed by the moderator and the associated stake was slashed"
  137. type PostStatusModerated @variant {
  138. "Event the post was moderated in"
  139. postModeratedEvent: PostModeratedEvent!
  140. }
  141. "The post is hidden - it was removed from the runtime state by the author and the `hide` flag was set to TRUE"
  142. type PostStatusRemoved @variant {
  143. "Event the post was removed in"
  144. postDeletedEvent: PostDeletedEvent!
  145. }
  146. union PostStatus = PostStatusActive | PostStatusLocked | PostStatusModerated | PostStatusRemoved
  147. type PostOriginThreadInitial @variant {
  148. "Thread creation event"
  149. # Must be optional because of post<->event cross-relationship
  150. threadCreatedEvent: ThreadCreatedEvent
  151. }
  152. type PostOriginThreadReply @variant {
  153. "Related PostAdded event"
  154. # Must be optional because of post<->event cross-relationship
  155. postAddedEvent: PostAddedEvent
  156. }
  157. union PostOrigin = PostOriginThreadInitial | PostOriginThreadReply
  158. type ForumPost @entity {
  159. "Runtime post id"
  160. id: ID!
  161. "Author of the forum post"
  162. author: Membership!
  163. "Thread the post was submitted in"
  164. thread: ForumThread!
  165. "Content of the post (md-formatted)"
  166. text: String! @fulltext(query: "postsByText")
  167. "A post that this post replies to (if any)"
  168. repliesTo: ForumPost
  169. "Current post status"
  170. status: PostStatus!
  171. "The origin of the post (either thread creation event or regular PostAdded event)"
  172. origin: PostOrigin!
  173. "List of all text update events (edits)"
  174. edits: [PostTextUpdatedEvent!] @derivedFrom(field: "post")
  175. "List of all current post reactions"
  176. reactions: [ForumPostReaction!] @derivedFrom(field: "post")
  177. # Required for PostDeletedEvent One-to-Many relation
  178. "The event the post was deleted in (if any)"
  179. deletedInEvent: PostDeletedEvent
  180. }