lib.rs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //! Definitions for GitHub GraphQL.
  2. //!
  3. //! See <https://docs.github.com/en/graphql> for more GitHub's GraphQL API.
  4. // This schema can be downloaded from https://docs.github.com/en/graphql/overview/public-schema
  5. #[cynic::schema_for_derives(file = "src/github.graphql", module = "schema")]
  6. pub mod queries {
  7. use super::schema;
  8. pub type DateTime = chrono::DateTime<chrono::Utc>;
  9. cynic::impl_scalar!(DateTime, schema::DateTime);
  10. #[derive(cynic::FragmentArguments, Debug)]
  11. pub struct LeastRecentlyReviewedPullRequestsArguments {
  12. pub repository_owner: String,
  13. pub repository_name: String,
  14. pub after: Option<String>,
  15. }
  16. #[derive(cynic::QueryFragment, Debug)]
  17. #[cynic(
  18. graphql_type = "Query",
  19. argument_struct = "LeastRecentlyReviewedPullRequestsArguments"
  20. )]
  21. pub struct LeastRecentlyReviewedPullRequests {
  22. #[arguments(owner = &args.repository_owner, name = &args.repository_name)]
  23. pub repository: Option<Repository>,
  24. }
  25. #[derive(cynic::QueryFragment, Debug)]
  26. #[cynic(argument_struct = "LeastRecentlyReviewedPullRequestsArguments")]
  27. pub struct Repository {
  28. #[arguments(states = Some(vec![PullRequestState::Open]), first = 100, after = &args.after, labels = Some(vec!["S-waiting-on-review".to_string()]), order_by = IssueOrder { direction: OrderDirection::Asc, field: IssueOrderField::UpdatedAt })]
  29. pub pull_requests: PullRequestConnection,
  30. }
  31. #[derive(cynic::QueryFragment, Debug)]
  32. pub struct PullRequestConnection {
  33. pub total_count: i32,
  34. pub page_info: PageInfo,
  35. pub nodes: Option<Vec<Option<PullRequest>>>,
  36. }
  37. #[derive(cynic::QueryFragment, Debug)]
  38. pub struct PullRequest {
  39. pub number: i32,
  40. pub created_at: DateTime,
  41. pub url: Uri,
  42. pub title: String,
  43. #[arguments(first = 100)]
  44. pub labels: Option<LabelConnection>,
  45. pub is_draft: bool,
  46. #[arguments(first = 100)]
  47. pub assignees: UserConnection,
  48. #[arguments(first = 100, order_by = IssueCommentOrder { direction: OrderDirection::Desc, field: IssueCommentOrderField::UpdatedAt })]
  49. pub comments: IssueCommentConnection,
  50. #[arguments(last = 20)]
  51. pub latest_reviews: Option<PullRequestReviewConnection>,
  52. }
  53. #[derive(cynic::QueryFragment, Debug)]
  54. pub struct PullRequestReviewConnection {
  55. pub total_count: i32,
  56. pub nodes: Option<Vec<Option<PullRequestReview>>>,
  57. }
  58. #[derive(cynic::QueryFragment, Debug)]
  59. pub struct PullRequestReview {
  60. pub author: Option<Actor>,
  61. pub created_at: DateTime,
  62. }
  63. #[derive(cynic::QueryFragment, Debug)]
  64. pub struct UserConnection {
  65. pub nodes: Option<Vec<Option<User>>>,
  66. }
  67. #[derive(cynic::QueryFragment, Debug)]
  68. pub struct User {
  69. pub login: String,
  70. }
  71. #[derive(cynic::QueryFragment, Debug)]
  72. pub struct PageInfo {
  73. pub has_next_page: bool,
  74. pub end_cursor: Option<String>,
  75. }
  76. #[derive(cynic::QueryFragment, Debug)]
  77. pub struct LabelConnection {
  78. pub nodes: Option<Vec<Option<Label>>>,
  79. }
  80. #[derive(cynic::QueryFragment, Debug)]
  81. pub struct Label {
  82. pub name: String,
  83. }
  84. #[derive(cynic::QueryFragment, Debug)]
  85. pub struct IssueCommentConnection {
  86. pub total_count: i32,
  87. pub nodes: Option<Vec<Option<IssueComment>>>,
  88. }
  89. #[derive(cynic::QueryFragment, Debug)]
  90. pub struct IssueComment {
  91. pub author: Option<Actor>,
  92. pub created_at: DateTime,
  93. }
  94. #[derive(cynic::Enum, Clone, Copy, Debug)]
  95. pub enum IssueCommentOrderField {
  96. UpdatedAt,
  97. }
  98. #[derive(cynic::Enum, Clone, Copy, Debug)]
  99. pub enum IssueOrderField {
  100. Comments,
  101. CreatedAt,
  102. UpdatedAt,
  103. }
  104. #[derive(cynic::Enum, Clone, Copy, Debug)]
  105. pub enum OrderDirection {
  106. Asc,
  107. Desc,
  108. }
  109. #[derive(cynic::Enum, Clone, Copy, Debug)]
  110. pub enum PullRequestState {
  111. Closed,
  112. Merged,
  113. Open,
  114. }
  115. #[derive(cynic::InputObject, Debug)]
  116. pub struct IssueOrder {
  117. pub direction: OrderDirection,
  118. pub field: IssueOrderField,
  119. }
  120. #[derive(cynic::InputObject, Debug)]
  121. pub struct IssueCommentOrder {
  122. pub direction: OrderDirection,
  123. pub field: IssueCommentOrderField,
  124. }
  125. #[derive(cynic::QueryFragment, Debug)]
  126. pub struct Actor {
  127. pub login: String,
  128. }
  129. #[derive(cynic::Scalar, Debug, Clone)]
  130. pub struct Uri(pub String);
  131. }
  132. mod schema {
  133. cynic::use_schema!("src/github.graphql");
  134. }