-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't require skip_serializing_none to have any attribute set and add…
… end-to-end test for it.
- Loading branch information
Showing
5 changed files
with
95 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use graphql_client::*; | ||
|
||
#[derive(GraphQLQuery)] | ||
#[graphql( | ||
schema_path = "tests/skip_serializing_none/schema.graphql", | ||
query_path = "tests/skip_serializing_none/query.graphql", | ||
skip_serializing_none | ||
)] | ||
pub struct SkipSerializingNoneMutation; | ||
|
||
#[test] | ||
fn skip_serializing_none() { | ||
use skip_serializing_none_mutation::*; | ||
|
||
let query = SkipSerializingNoneMutation::build_query(Variables { | ||
param: Some(Param { | ||
data: Author { | ||
name: "test".to_owned(), | ||
id: None, | ||
}, | ||
}), | ||
}); | ||
|
||
let stringified = serde_json::to_string(&query).expect("SkipSerializingNoneMutation is valid"); | ||
|
||
println!("{}", stringified); | ||
|
||
assert!(stringified.contains(r#""data":{"name":"test"}"#)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mutation SkipSerializingNoneMutation($param: Param) { | ||
optInput(query: $param) { | ||
name | ||
__typename | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
schema { | ||
mutation: Mutation | ||
} | ||
|
||
# The query type, represents all of the entry points into our object graph | ||
type Mutation { | ||
optInput(mutation: Param!): Named | ||
} | ||
|
||
input Param { | ||
data: Author! | ||
} | ||
|
||
input Author { | ||
id: String, | ||
name: String! | ||
} | ||
|
||
# A named entity | ||
type Named { | ||
# The ID of the entity | ||
id: ID! | ||
# The name of the entity | ||
name: String! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters