diff --git a/compiler/crates/relay-compiler/src/status_reporter.rs b/compiler/crates/relay-compiler/src/status_reporter.rs index e22389f861cf1..9d96b01999198 100644 --- a/compiler/crates/relay-compiler/src/status_reporter.rs +++ b/compiler/crates/relay-compiler/src/status_reporter.rs @@ -151,3 +151,23 @@ impl StatusReporter for ConsoleStatusReporter { } } } + +pub struct JSONStatusReporter; + +impl StatusReporter for JSONStatusReporter { + fn build_starts(&self) {} + + fn build_completes(&self, diagnostics: &[Diagnostic]) { + println!( + "{{\"completed\":true,\"diagnostics\":{}}}", + serde_json::to_string(diagnostics).unwrap() + ); + } + + fn build_errors(&self, error: &Error) { + println!( + "{{\"completed\":false,\"error\":{}}}", + serde_json::to_string(error).unwrap() + ); + } +}