From 50fd458339ecec16cf3f7750c29592bf6394054f Mon Sep 17 00:00:00 2001 From: Danny Browning Date: Sat, 17 Feb 2024 16:43:47 -0700 Subject: [PATCH] fix: cursors are optional (#10) --- src/api.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index d58486d..07a9212 100644 --- a/src/api.rs +++ b/src/api.rs @@ -316,7 +316,8 @@ pub struct PageInfo { #[serde(default)] pub end_cursor: Option, /// Cursor for previous page - pub start_cursor: Base64UrlString, + #[serde(default)] + pub start_cursor: Option, } /// Response to query @@ -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()); + } }