@@ -11,15 +11,15 @@ use graphql_client::GraphQLQuery;
11
11
#[ graphql(
12
12
query_path = "tests/operation_selection/queries.graphql" ,
13
13
schema_path = "tests/operation_selection/schema.graphql" ,
14
- response_derives = "Debug,PartialEq" ,
14
+ response_derives = "Debug,PartialEq"
15
15
) ]
16
16
pub struct Heights ;
17
17
18
18
#[ derive( GraphQLQuery ) ]
19
19
#[ graphql(
20
20
query_path = "tests/operation_selection/queries.graphql" ,
21
21
schema_path = "tests/operation_selection/schema.graphql" ,
22
- response_derives = "Debug,PartialEq" ,
22
+ response_derives = "Debug,PartialEq"
23
23
) ]
24
24
pub struct Echo ;
25
25
@@ -28,10 +28,19 @@ pub struct Echo;
28
28
#[ graphql(
29
29
query_path = "tests/operation_selection/queries.graphql" ,
30
30
schema_path = "tests/operation_selection/schema.graphql" ,
31
- response_derives = "Debug,PartialEq" ,
31
+ response_derives = "Debug,PartialEq"
32
32
) ]
33
33
pub struct Unrelated ;
34
34
35
+ #[ derive( GraphQLQuery ) ]
36
+ #[ graphql(
37
+ query_path = "tests/operation_selection/queries.graphql" ,
38
+ schema_path = "tests/operation_selection/schema.graphql" ,
39
+ response_derives = "Debug,PartialEq" ,
40
+ selected_operation = "Echo"
41
+ ) ]
42
+ pub struct SelectedOperation ;
43
+
35
44
const HEIGHTS_RESPONSE : & ' static str = r##"{"mountainHeight": 224, "buildingHeight": 12}"## ;
36
45
const ECHO_RESPONSE : & ' static str = r##"{"echo": "tiramisù"}"## ;
37
46
@@ -42,6 +51,8 @@ fn operation_selection_works() {
42
51
let heights_unrelated_response_data: unrelated:: ResponseData =
43
52
serde_json:: from_str ( HEIGHTS_RESPONSE ) . unwrap ( ) ;
44
53
let echo_response_data: echo:: ResponseData = serde_json:: from_str ( ECHO_RESPONSE ) . unwrap ( ) ;
54
+ let selected_operation_response_data: selected_operation:: ResponseData =
55
+ serde_json:: from_str ( ECHO_RESPONSE ) . unwrap ( ) ;
45
56
46
57
let _echo_variables = echo:: Variables {
47
58
msg : Some ( "hi" . to_string ( ) ) ,
@@ -56,9 +67,14 @@ fn operation_selection_works() {
56
67
mountain_name : Some ( "canigou" . to_string ( ) ) ,
57
68
} ;
58
69
70
+ let _selected_operation_variables = selected_operation:: Variables {
71
+ msg : Some ( "hi" . to_string ( ) ) ,
72
+ } ;
73
+
59
74
let expected_echo = echo:: ResponseData {
60
75
echo : Some ( "tiramisù" . to_string ( ) ) ,
61
76
} ;
77
+
62
78
let expected_heights = heights:: ResponseData {
63
79
mountain_height : Some ( 224 ) ,
64
80
building_height : Some ( 12 ) ,
@@ -69,9 +85,17 @@ fn operation_selection_works() {
69
85
building_height : Some ( 12 ) ,
70
86
} ;
71
87
88
+ let expected_selected_operation = selected_operation:: ResponseData {
89
+ echo : Some ( "tiramisù" . to_string ( ) ) ,
90
+ } ;
91
+
72
92
assert_eq ! ( expected_echo, echo_response_data) ;
73
93
assert_eq ! ( expected_heights, heights_response_data) ;
74
94
assert_eq ! ( expected_heights_unrelated, heights_unrelated_response_data) ;
95
+ assert_eq ! (
96
+ expected_selected_operation,
97
+ selected_operation_response_data
98
+ ) ;
75
99
}
76
100
77
101
#[ test]
0 commit comments