Skip to content

Commit 8b9f605

Browse files
Add compile and serde test
1 parent d3934f9 commit 8b9f605

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

graphql_client/tests/input_object_variables.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,32 @@ fn indirectly_recursive_input_objects_can_be_constructed() {
117117
})),
118118
};
119119
}
120+
121+
#[derive(GraphQLQuery)]
122+
#[graphql(
123+
query_path = "tests/input_object_variables/input_object_variables_query.graphql",
124+
schema_path = "tests/input_object_variables/input_object_variables_schema.graphql",
125+
variables_derives = "Default",
126+
response_derives = "Debug, PartialEq"
127+
)]
128+
pub struct RustNameQuery;
129+
130+
#[test]
131+
fn rust_name_correctly_mapped() {
132+
use rust_name_query::*;
133+
let value = serde_json::to_value(&Variables {
134+
extern_: Some("hello".to_owned()),
135+
msg: <_>::default(),
136+
})
137+
.unwrap();
138+
assert_eq!(
139+
value
140+
.as_object()
141+
.unwrap()
142+
.get("extern")
143+
.unwrap()
144+
.as_str()
145+
.unwrap(),
146+
"hello"
147+
);
148+
}

graphql_client/tests/input_object_variables/input_object_variables_query.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ query IndirectlyRecursiveInputQuery($input: IndirectlyRecursiveInput!) {
1515
query InputCaseTestsQuery($input: CaseTestInput!) {
1616
testQueryCase(caseTestInput: $input)
1717
}
18+
19+
query RustNameQuery($msg: Message, $extern: String) {
20+
echo(message: $msg, extern: $extern) {
21+
result
22+
}
23+
}

graphql_client/tests/input_object_variables/input_object_variables_schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type CaseTestResult {
4949
}
5050

5151
type InputObjectVariablesQuery {
52-
echo(message: Message!, options: Options = { pgpSignature: true }): EchoResult
52+
echo(message: Message!, options: Options = { pgpSignature: true }, extern: String = ""): EchoResult
5353
testQueryCase(caseTestInput: CaseTestInput!): CaseTestResult
5454
saveRecursiveInput(recursiveInput: RecursiveInput!): Category
5555
}

0 commit comments

Comments
 (0)