Skip to content

Commit fe4f504

Browse files
committed
Update to cynic 2.2
1 parent a372837 commit fe4f504

File tree

5 files changed

+70
-123
lines changed

5 files changed

+70
-123
lines changed

Cargo.lock

Lines changed: 32 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ serde_path_to_error = "0.1.2"
3636
octocrab = "0.9.1"
3737
comrak = "0.8.2"
3838
route-recognizer = "0.3.0"
39-
cynic = { version = "0.14" }
39+
cynic = { version = "2.0.0" }
4040
itertools = "0.10.2"
4141
tower = { version = "0.4.13", features = ["util", "limit", "buffer", "load-shed"] }
4242
github-graphql = { path = "github-graphql" }

github-graphql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ edition = "2021"
55

66
[dependencies]
77
chrono = { version = "0.4", features = ["serde"] }
8-
cynic = { version = "0.14" }
8+
cynic = { version = "2.2.2" }

github-graphql/src/lib.rs

Lines changed: 25 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod queries {
1111

1212
cynic::impl_scalar!(DateTime, schema::DateTime);
1313

14-
#[derive(cynic::FragmentArguments, Debug)]
14+
#[derive(cynic::QueryVariables, Debug, Clone)]
1515
pub struct LeastRecentlyReviewedPullRequestsArguments {
1616
pub repository_owner: String,
1717
pub repository_name: String,
@@ -21,17 +21,23 @@ pub mod queries {
2121
#[derive(cynic::QueryFragment, Debug)]
2222
#[cynic(
2323
graphql_type = "Query",
24-
argument_struct = "LeastRecentlyReviewedPullRequestsArguments"
24+
variables = "LeastRecentlyReviewedPullRequestsArguments"
2525
)]
2626
pub struct LeastRecentlyReviewedPullRequests {
27-
#[arguments(owner = &args.repository_owner, name = &args.repository_name)]
27+
#[arguments(owner: $repository_owner, name: $repository_name)]
2828
pub repository: Option<Repository>,
2929
}
3030

3131
#[derive(cynic::QueryFragment, Debug)]
32-
#[cynic(argument_struct = "LeastRecentlyReviewedPullRequestsArguments")]
32+
#[cynic(variables = "LeastRecentlyReviewedPullRequestsArguments")]
3333
pub struct Repository {
34-
#[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 })]
34+
#[arguments(
35+
states: "OPEN",
36+
first: 100,
37+
after: $after,
38+
labels: ["S-waiting-on-review"],
39+
orderBy: {direction: "ASC", field: "UPDATED_AT"}
40+
)]
3541
pub pull_requests: PullRequestConnection,
3642
}
3743

@@ -53,7 +59,7 @@ pub mod queries {
5359
pub is_draft: bool,
5460
#[arguments(first = 100)]
5561
pub assignees: UserConnection,
56-
#[arguments(first = 100, order_by = IssueCommentOrder { direction: OrderDirection::Desc, field: IssueCommentOrderField::UpdatedAt })]
62+
#[arguments(first = 100, orderBy: { direction: "DESC", field: "UPDATED_AT" })]
5763
pub comments: IssueCommentConnection,
5864
#[arguments(last = 20)]
5965
pub latest_reviews: Option<PullRequestReviewConnection>,
@@ -109,49 +115,13 @@ pub mod queries {
109115
pub created_at: DateTime,
110116
}
111117

112-
#[derive(cynic::Enum, Clone, Copy, Debug)]
113-
pub enum IssueCommentOrderField {
114-
UpdatedAt,
115-
}
116-
117-
#[derive(cynic::Enum, Clone, Copy, Debug)]
118-
pub enum IssueOrderField {
119-
Comments,
120-
CreatedAt,
121-
UpdatedAt,
122-
}
123-
124-
#[derive(cynic::Enum, Clone, Copy, Debug)]
125-
pub enum OrderDirection {
126-
Asc,
127-
Desc,
128-
}
129-
130-
#[derive(cynic::Enum, Clone, Copy, Debug)]
131-
pub enum PullRequestState {
132-
Closed,
133-
Merged,
134-
Open,
135-
}
136-
137-
#[derive(cynic::InputObject, Debug)]
138-
pub struct IssueOrder {
139-
pub direction: OrderDirection,
140-
pub field: IssueOrderField,
141-
}
142-
143-
#[derive(cynic::InputObject, Debug)]
144-
pub struct IssueCommentOrder {
145-
pub direction: OrderDirection,
146-
pub field: IssueCommentOrderField,
147-
}
148-
149118
#[derive(cynic::QueryFragment, Debug)]
150119
pub struct Actor {
151120
pub login: String,
152121
}
153122

154123
#[derive(cynic::Scalar, Debug, Clone)]
124+
#[cynic(graphql_type = "URI")]
155125
pub struct Uri(pub String);
156126
}
157127

@@ -160,7 +130,7 @@ pub mod docs_update_queries {
160130
use super::queries::{DateTime, PageInfo};
161131
use super::schema;
162132

163-
#[derive(cynic::FragmentArguments, Debug)]
133+
#[derive(cynic::QueryVariables, Clone, Debug)]
164134
pub struct RecentCommitsArguments {
165135
pub branch: String,
166136
pub name: String,
@@ -208,30 +178,30 @@ pub mod docs_update_queries {
208178
/// }
209179
/// ```
210180
#[derive(cynic::QueryFragment, Debug)]
211-
#[cynic(graphql_type = "Query", argument_struct = "RecentCommitsArguments")]
181+
#[cynic(graphql_type = "Query", variables = "RecentCommitsArguments")]
212182
pub struct RecentCommits {
213-
#[arguments(name = &args.name, owner = &args.owner)]
183+
#[arguments(name: $name, owner: $owner)]
214184
pub repository: Option<Repository>,
215185
}
216186

217187
#[derive(cynic::QueryFragment, Debug)]
218-
#[cynic(argument_struct = "RecentCommitsArguments")]
188+
#[cynic(variables = "RecentCommitsArguments")]
219189
pub struct Repository {
220-
#[arguments(qualified_name = &args.branch)]
190+
#[arguments(qualifiedName: $branch)]
221191
#[cynic(rename = "ref")]
222192
pub ref_: Option<Ref>,
223193
}
224194

225195
#[derive(cynic::QueryFragment, Debug)]
226-
#[cynic(argument_struct = "RecentCommitsArguments")]
196+
#[cynic(variables = "RecentCommitsArguments")]
227197
pub struct Ref {
228198
pub target: Option<GitObject>,
229199
}
230200

231201
#[derive(cynic::QueryFragment, Debug)]
232-
#[cynic(argument_struct = "RecentCommitsArguments")]
202+
#[cynic(variables = "RecentCommitsArguments")]
233203
pub struct Commit {
234-
#[arguments(first = 100, after = &args.after)]
204+
#[arguments(first: 100, after: $after)]
235205
pub history: CommitHistoryConnection,
236206
}
237207

@@ -277,33 +247,18 @@ pub mod docs_update_queries {
277247
}
278248

279249
#[derive(cynic::InlineFragments, Debug)]
280-
#[cynic(argument_struct = "RecentCommitsArguments")]
250+
#[cynic(variables = "RecentCommitsArguments")]
281251
pub enum GitObject {
282252
Commit(Commit),
283-
// These three variants are here just to pacify cynic. I don't know
284-
// why it fails to compile without them.
285-
Tree(Tree),
286-
Tag(Tag),
287-
Blob(Blob),
288-
}
289-
290-
#[derive(cynic::QueryFragment, Debug)]
291-
pub struct Tree {
292-
pub id: cynic::Id,
293-
}
294-
#[derive(cynic::QueryFragment, Debug)]
295-
pub struct Tag {
296-
pub id: cynic::Id,
297-
}
298-
#[derive(cynic::QueryFragment, Debug)]
299-
pub struct Blob {
300-
pub id: cynic::Id,
253+
#[cynic(fallback)]
254+
Other,
301255
}
302256

303257
#[derive(cynic::Scalar, Debug, Clone)]
304258
pub struct GitObjectID(pub String);
305259
}
306260

261+
#[allow(non_snake_case, non_camel_case_types)]
307262
mod schema {
308263
cynic::use_schema!("src/github.graphql");
309264
}

0 commit comments

Comments
 (0)