3
3
use std:: io:: stdin;
4
4
5
5
use anyhow:: anyhow;
6
+ use apollo_federation_types:: config:: FederationVersion :: LatestFedTwo ;
6
7
use apollo_federation_types:: config:: RouterVersion ;
7
8
use camino:: Utf8PathBuf ;
8
9
use futures:: StreamExt ;
9
10
use houston:: { Config , Profile } ;
10
11
use router:: { install:: InstallRouter , run:: RunRouter , watchers:: file:: FileWatcher } ;
11
12
use rover_client:: operations:: config:: who_am_i:: WhoAmI ;
13
+ use rover_std:: { infoln, warnln} ;
12
14
15
+ use self :: router:: config:: { RouterAddress , RunRouterConfig } ;
13
16
use crate :: {
14
17
command:: Dev ,
15
18
composition:: {
@@ -30,8 +33,6 @@ use crate::{
30
33
RoverError , RoverOutput , RoverResult ,
31
34
} ;
32
35
33
- use self :: router:: config:: { RouterAddress , RunRouterConfig } ;
34
-
35
36
mod router;
36
37
37
38
impl Dev {
@@ -65,6 +66,9 @@ impl Dev {
65
66
66
67
let profile = & self . opts . plugin_opts . profile ;
67
68
let graph_ref = & self . opts . supergraph_opts . graph_ref ;
69
+ if let Some ( graph_ref) = graph_ref {
70
+ eprintln ! ( "retrieving subgraphs remotely from {graph_ref}" )
71
+ }
68
72
let supergraph_config_path = & self . opts . supergraph_opts . clone ( ) . supergraph_config_path ;
69
73
70
74
let service = client_config. get_authenticated_client ( profile) ?. service ( ) ?;
@@ -90,7 +94,11 @@ impl Dev {
90
94
. resolve_federation_version (
91
95
& client_config,
92
96
make_fetch_remote_subgraph,
93
- self . opts . supergraph_opts . federation_version . clone ( ) ,
97
+ self . opts
98
+ . supergraph_opts
99
+ . federation_version
100
+ . clone ( )
101
+ . or ( Some ( LatestFedTwo ) ) ,
94
102
)
95
103
. await ?
96
104
. install_supergraph_binary (
@@ -100,6 +108,7 @@ impl Dev {
100
108
skip_update,
101
109
)
102
110
. await ?;
111
+
103
112
let composition_success = composition_pipeline
104
113
. compose ( & exec_command_impl, & read_file_impl, & write_file_impl, None )
105
114
. await ?;
@@ -126,7 +135,12 @@ impl Dev {
126
135
127
136
let composition_messages = composition_runner. run ( ) ;
128
137
129
- let mut run_router = RunRouter :: default ( )
138
+ eprintln ! (
139
+ "composing supergraph with Federation {}" ,
140
+ composition_pipeline. state. supergraph_binary. version( )
141
+ ) ;
142
+
143
+ let run_router = RunRouter :: default ( )
130
144
. install :: < InstallRouter > (
131
145
router_version,
132
146
client_config. clone ( ) ,
@@ -138,7 +152,9 @@ impl Dev {
138
152
. load_config ( & read_file_impl, router_address, router_config_path)
139
153
. await ?
140
154
. load_remote_config ( service, graph_ref. clone ( ) , Some ( credential) )
141
- . await
155
+ . await ;
156
+ let router_address = run_router. state . config . address ( ) . clone ( ) ;
157
+ let mut run_router = run_router
142
158
. run (
143
159
FsWriteFile :: default ( ) ,
144
160
TokioSpawn :: default ( ) ,
@@ -150,6 +166,12 @@ impl Dev {
150
166
. watch_for_changes ( write_file_impl, composition_messages)
151
167
. await ;
152
168
169
+ warnln ! (
170
+ "Do not run this command in production! It is intended for local development only."
171
+ ) ;
172
+
173
+ infoln ! ( "your supergraph is running! head to {router_address} to query your supergraph" ) ;
174
+
153
175
loop {
154
176
tokio:: select! {
155
177
_ = tokio:: signal:: ctrl_c( ) => {
@@ -160,7 +182,9 @@ impl Dev {
160
182
Some ( router_log) = run_router. router_logs( ) . next( ) => {
161
183
match router_log {
162
184
Ok ( router_log) => {
163
- eprintln!( "{}" , router_log) ;
185
+ if !router_log. to_string( ) . is_empty( ) {
186
+ eprintln!( "{}" , router_log) ;
187
+ }
164
188
}
165
189
Err ( err) => {
166
190
tracing:: error!( "{:?}" , err) ;
@@ -170,7 +194,6 @@ impl Dev {
170
194
else => break ,
171
195
}
172
196
}
173
-
174
197
Ok ( RoverOutput :: EmptySuccess )
175
198
}
176
199
}
0 commit comments