-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
skip_serializing_none does not work #439
Comments
I unfortunately don't have time to spend on this project to investigate further or fix things, but I'm happy to review PRs. FWIW it looks like a bug. |
Thanks for the quick reply. This is unfortunately a blocking issue for me, unless there's some way to work around this issue. Since hasura 2.x now reports an error if input fields with null values are present, it's no longer possible to get the mutations to work. I might try opening a PR if I get the time. Any hints on how approach fixing this issue would be appreciated. |
So I tried to switch to the git version again, and this time it seems to fix the problem, it's only v0.11.0 that doesn't work. So my first assumption was correct, that this features has not yet been released. Not sure why switching last time didn't work, might have been a caching issue or something. Hoping we'll see a v0.12.0 soon! Until then, I'm just gonna depend on the git repo directly. |
I am also running into this issue in v0.12.0, I think this issue should be reopened. When expanding macro with skip_serialize_none, it doesn't seem like it is applied to the variables. Example:
github.schema.graphql: https://docs.github.com/public/schema.docs.graphql github.query.graphql:
|
I am encountering the same issue in v0.13.0. This problem should be reopened. When expanding a macro with skip_serialize_none, it appears that it is not being applied to the variables in the query. |
It seems like it only works for nested variables. Here's a test patch to reproduce: diff --git a/graphql_client/tests/skip_serializing_none.rs b/graphql_client/tests/skip_serializing_none.rs
index 0d26184..40b0f9f 100644
--- a/graphql_client/tests/skip_serializing_none.rs
+++ b/graphql_client/tests/skip_serializing_none.rs
@@ -13,6 +13,7 @@ fn skip_serializing_none() {
use skip_serializing_none_mutation::*;
let query = SkipSerializingNoneMutation::build_query(Variables {
+ foo: None,
param: Some(Param {
data: Author {
name: "test".to_owned(),
@@ -26,4 +27,5 @@ fn skip_serializing_none() {
println!("{}", stringified);
assert!(stringified.contains(r#""data":{"name":"test"}"#));
+ assert!(stringified.contains(r#""variables":{"param":{"data":{"name":"test"}}}"#));
}
diff --git a/graphql_client/tests/skip_serializing_none/query.graphql b/graphql_client/tests/skip_serializing_none/query.graphql
index 028ae76..f648300 100644
--- a/graphql_client/tests/skip_serializing_none/query.graphql
+++ b/graphql_client/tests/skip_serializing_none/query.graphql
@@ -1,4 +1,4 @@
-mutation SkipSerializingNoneMutation($param: Param) {
+mutation SkipSerializingNoneMutation($param: Param, $foo: Int) {
optInput(query: $param) {
name
__typename
|
@Akremkadri looks like you also ran into this issue recently, I submitted a PR here: #485 Does it work for you? The new test checks for both root level and nested variable |
I tried asking this question on the actual PR #431 that was meant to solve this issue, but got no response, so I'm just gonna move the question into this issue.
I've added
skip_serializing_none
to the struct as stated in the README, but doing so still leaves me withnull
values after serialization.My first guess was that this hasn't been released yet, so I switch over to the
main
branch inCargo.toml
, but that changed nothing. Here's the code I'm using:Output:
Is there something obvious I'm missing here to make this work, or is this something that warrants it's own issue?
The text was updated successfully, but these errors were encountered: