forked from graphql-rust/graphql-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request graphql-rust#431 from Selyatin/skip_none
- Loading branch information
Showing
10 changed files
with
217 additions
and
2 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
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
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
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