Skip to content

Commit

Permalink
fix: cursors are optional (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbcfd authored Feb 17, 2024
1 parent d140bc2 commit 50fd458
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ pub struct PageInfo {
#[serde(default)]
pub end_cursor: Option<Base64UrlString>,
/// Cursor for previous page
pub start_cursor: Base64UrlString,
#[serde(default)]
pub start_cursor: Option<Base64UrlString>,
}

/// Response to query
Expand Down Expand Up @@ -498,4 +499,13 @@ mod tests {
r#"{"model":"kjzl6hvfrbw6c8apa5yce6ah3fsz9sgrh6upniy0tz8z76gdm169ds3tf8c051t","account":"test","queryFilters":{"where":{"id":{"equalTo":"1"}}},"first":100}"#
);
}

#[test]
fn should_deserialize_empty_result() {
let res: QueryResponse = serde_json::from_str(
r#"{"edges":[],"pageInfo":{"hasNextPage":false,"hasPreviousPage":false}}"#,
)
.unwrap();
assert!(res.edges.is_empty());
}
}

0 comments on commit 50fd458

Please sign in to comment.