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