@@ -99,3 +99,79 @@ fn graphql_can_return_config_as_json_string() {
9999 ) ;
100100 } ) ;
101101}
102+
103+ #[ test]
104+ fn graphql_can_check_how_specific_subgraph_would_be_placed ( ) {
105+ run_test ( || async {
106+ let curr_dir = std:: env:: current_dir ( )
107+ . unwrap ( )
108+ . to_str ( )
109+ . unwrap ( )
110+ . to_string ( ) ;
111+ let config_dir = format ! ( "{}/tests/test_config.toml" , curr_dir) ;
112+ std:: env:: set_var ( "GRAPH_NODE_CONFIG" , config_dir) ;
113+
114+ let resp = send_graphql_request (
115+ json ! ( {
116+ "query" : r#"{
117+ config {
118+ place(subgraph: "subgraph_1", network: "bsc") {
119+ subgraph
120+ network
121+ shards
122+ nodes
123+ }
124+ }
125+ }"#
126+ } ) ,
127+ VALID_TOKEN ,
128+ )
129+ . await ;
130+
131+ let expected_resp = json ! ( {
132+ "data" : {
133+ "config" : {
134+ "place" : {
135+ "subgraph" : String :: from( "subgraph_1" ) ,
136+ "network" : String :: from( "bsc" ) ,
137+ "shards" : vec![ "primary" . to_string( ) , "shard_a" . to_string( ) ] ,
138+ "nodes" : vec![ "index_node_1_a" . to_string( ) , "index_node_2_a" . to_string( ) , "index_node_3_a" . to_string( ) ] ,
139+ }
140+ }
141+ }
142+ } ) ;
143+
144+ let resp_custom = send_graphql_request (
145+ json ! ( {
146+ "query" : r#"{
147+ config {
148+ place(subgraph: "custom/subgraph_1", network: "bsc") {
149+ subgraph
150+ network
151+ shards
152+ nodes
153+ }
154+ }
155+ }"#
156+ } ) ,
157+ VALID_TOKEN ,
158+ )
159+ . await ;
160+
161+ let expected_resp_custom = json ! ( {
162+ "data" : {
163+ "config" : {
164+ "place" : {
165+ "subgraph" : String :: from( "custom/subgraph_1" ) ,
166+ "network" : String :: from( "bsc" ) ,
167+ "shards" : vec![ "primary" . to_string( ) ] ,
168+ "nodes" : vec![ "index_custom_0" . to_string( ) ] ,
169+ }
170+ }
171+ }
172+ } ) ;
173+
174+ assert_eq ! ( resp, expected_resp) ;
175+ assert_eq ! ( resp_custom, expected_resp_custom) ;
176+ } ) ;
177+ }
0 commit comments