graphql-client
graphql-client copied to clipboard
Add skip_serializing_none feature
Closes #411 and #262 :)
@tomhoule requested changes were made, let me know if the test looks good.
Sorry for bumping this closed PR, but I'm really struggling to get this to work.
I've added skip_serializing_none
to the struct as stated in the README, but doing so still leaves me with null
values after serialization.
My first guess was that this hasn't been released yet, so I switch over to the main
branch in Cargo.toml
, but that changed nothing. Here's the code I'm using:
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.graphql",
query_path = "graphql/insert_mutation.graphql",
response_derives = "Debug",
skip_serializing_none
)]
pub struct InsertMutation;
let vars = Variables {
// .. omitted
user_id: None,
// .. omitted
};
let q = crate::graphql::InsertMutation::build_query(vars);
let skipped = serde_json::to_string_pretty(&q).unwrap();
println!("{skipped}");
Output:
{
"variables": {
// .. omitted
"user_id": null,
// .. omitted
},
...
}
Is there something obvious I'm missing here to make this work, or is this something that warrants it's own issue?