forum.graphql 6.7 KB

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