Skip to content

Commit

Permalink
Changelog & a test for #835 (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
obmarg authored Jan 22, 2024
1 parent c401a92 commit 0887c84
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## Unreleased - xxxx-xx-xx

### Bug Fixes

- Fixed an issue with object literals inside arguments

## v3.4.0 - 2024-01-09

### New Features
Expand Down
43 changes: 43 additions & 0 deletions cynic/tests/arguments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! Tests of the generated serialization code for InputObjects

use serde::Serialize;

mod schema {
cynic::use_schema!("tests/test-schema.graphql");
}

#[test]
fn test_literal_object_inside_list() {
use cynic::QueryBuilder;

#[derive(cynic::QueryFragment, Serialize)]
#[cynic(graphql_type = "BlogPost", schema_path = "tests/test-schema.graphql")]
struct Post {
has_metadata: Option<bool>,
}

#[derive(cynic::QueryFragment)]
#[cynic(schema_path = "tests/test-schema.graphql")]
struct Query {
#[allow(dead_code)]
#[arguments(filters: { any: [{states: DRAFT}] })]
filtered_posts: Vec<BlogPost>,
}

let query = Query::build(());

insta::assert_display_snapshot!(query.query, @r###"
query Query {
filteredPosts(filters: {any: [{states: [DRAFT, ], }, ], }) {
hasMetadata
}
}
"###);
}

#[derive(cynic::QueryFragment, Serialize)]
#[cynic(schema_path = "tests/test-schema.graphql")]
struct BlogPost {
has_metadata: Option<bool>,
}
1 change: 1 addition & 0 deletions cynic/tests/test-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ scalar DateTime
input PostFilters {
authorId: ID
states: [PostState!]
any: [PostFilters!]
}

input InputWithDefaults {
Expand Down

0 comments on commit 0887c84

Please sign in to comment.