File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use std::path::PathBuf;
1010
1111use anyhow:: { Result , bail} ;
1212use argh:: FromArgs ;
13+ use async_graphql:: Schema ;
1314
1415#[ cfg( unix) ]
1516use libc:: geteuid;
@@ -166,6 +167,10 @@ struct Cli {
166167 /// show version information
167168 #[ argh( switch) ]
168169 version : bool ,
170+
171+ /// print GraphQL schema to stdout
172+ #[ argh( switch) ]
173+ printschema : bool ,
169174}
170175
171176#[ tokio:: main( flavor = "multi_thread" , worker_threads = 2 ) ]
@@ -185,13 +190,26 @@ async fn main() -> Result<()> {
185190 endpoint,
186191 query,
187192 version,
193+ printschema,
188194 } = argh:: from_env ( ) ;
189195
190196 if version {
191197 println ! ( "riverql {}" , env!( "CARGO_PKG_VERSION" ) ) ;
192198 return Ok ( ( ) ) ;
193199 }
194200
201+ if printschema {
202+ let schema: Schema < gql:: QueryRoot , async_graphql:: EmptyMutation , gql:: SubscriptionRoot > =
203+ Schema :: build (
204+ gql:: QueryRoot ,
205+ async_graphql:: EmptyMutation ,
206+ gql:: SubscriptionRoot ,
207+ )
208+ . finish ( ) ;
209+ println ! ( "{}" , schema. sdl( ) ) ;
210+ return Ok ( ( ) ) ;
211+ }
212+
195213 if server {
196214 if endpoint. is_some ( ) || query. is_some ( ) {
197215 bail ! ( "--server does not take endpoint or query arguments" ) ;
You can’t perform that action at this time.
0 commit comments