fix binstalk_downloader::GhApiClient json deser error (#1193)

When installing `cargo-expand` v1.0.59, I got an error message:

```
Failed to parse http response body as Json: invalid type: null, expected a string at line
1 column 90
```

This is because `GraphQLPageInfo::end_cursor` can actually be `null`, so
I change its type to `Option<CompactString>`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-07-09 20:39:18 +10:00 committed by GitHub
parent 0813e80438
commit c4b6921314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -289,7 +289,7 @@ struct GraphQLReleaseAssets {
#[derive(Deserialize)] #[derive(Deserialize)]
struct GraphQLPageInfo { struct GraphQLPageInfo {
#[serde(rename = "endCursor")] #[serde(rename = "endCursor")]
end_cursor: CompactString, end_cursor: Option<CompactString>,
#[serde(rename = "hasNextPage")] #[serde(rename = "hasNextPage")]
has_next_page: bool, has_next_page: bool,
} }
@ -376,11 +376,14 @@ query {{
if let Some(assets) = assets { if let Some(assets) = assets {
artifacts.assets.extend(assets.nodes); artifacts.assets.extend(assets.nodes);
let page_info = assets.page_info; match assets.page_info {
if !page_info.has_next_page { GraphQLPageInfo {
break Ok(FetchReleaseRet::Artifacts(artifacts)); end_cursor: Some(end_cursor),
} else { has_next_page: true,
cond = FilterCondition::After(page_info.end_cursor); } => {
cond = FilterCondition::After(end_cursor);
}
_ => break Ok(FetchReleaseRet::Artifacts(artifacts)),
} }
} else { } else {
break Ok(FetchReleaseRet::ReleaseNotFound); break Ok(FetchReleaseRet::ReleaseNotFound);