1
1
use crate :: blocking:: GraphQLClient ;
2
+ use crate :: query:: subgraph:: introspect:: types:: * ;
2
3
use crate :: RoverClientError ;
4
+
3
5
use graphql_client:: * ;
4
- use std:: collections:: HashMap ;
5
6
6
7
#[ derive( GraphQLQuery ) ]
7
8
#[ graphql(
8
- query_path = "src/query/subgraph/introspect_query.graphql" ,
9
- schema_path = "src/query/subgraph/introspect_schema.graphql" ,
9
+ query_path = "src/query/subgraph/introspect/ introspect_query.graphql" ,
10
+ schema_path = "src/query/subgraph/introspect/ introspect_schema.graphql" ,
10
11
response_derives = "PartialEq, Debug, Serialize, Deserialize" ,
11
12
deprecated = "warn"
12
13
) ]
13
14
14
- pub struct IntrospectionQuery ;
15
-
16
- #[ derive( Debug , PartialEq ) ]
17
- pub struct IntrospectionResponse {
18
- pub result : String ,
19
- }
15
+ pub ( crate ) struct SubgraphIntrospectQuery ;
20
16
21
17
pub fn run (
18
+ input : SubgraphIntrospectInput ,
22
19
client : & GraphQLClient ,
23
- headers : & HashMap < String , String > ,
24
- ) -> Result < IntrospectionResponse , RoverClientError > {
25
- let variables = introspection_query:: Variables { } ;
26
- let response_data = client. post :: < IntrospectionQuery > ( variables, headers) ;
20
+ ) -> Result < SubgraphIntrospectResponse , RoverClientError > {
21
+ let response_data =
22
+ client. post :: < SubgraphIntrospectQuery > ( input. clone ( ) . into ( ) , & input. headers ) ;
27
23
28
24
match response_data {
29
25
Ok ( data) => build_response ( data) ,
@@ -39,14 +35,12 @@ pub fn run(
39
35
}
40
36
}
41
37
42
- fn build_response (
43
- data : introspection_query:: ResponseData ,
44
- ) -> Result < IntrospectionResponse , RoverClientError > {
38
+ fn build_response ( data : QueryResponseData ) -> Result < SubgraphIntrospectResponse , RoverClientError > {
45
39
let service_data = data. service . ok_or ( RoverClientError :: IntrospectionError {
46
40
msg : "No introspection response available." . to_string ( ) ,
47
41
} ) ?;
48
42
49
- Ok ( IntrospectionResponse {
43
+ Ok ( SubgraphIntrospectResponse {
50
44
result : service_data. sdl ,
51
45
} )
52
46
}
0 commit comments