Skip to content

Commit

Permalink
Fix passing empty documents to schema gen
Browse files Browse the repository at this point in the history
Reviewed By: evanyeung

Differential Revision: D58169489

fbshipit-source-id: 892e7751cf6133c1b2ca139cc357ab945dd39d13
  • Loading branch information
tyao1 authored and facebook-github-bot committed Jun 5, 2024
1 parent 6aaa9ce commit 7e41583
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions compiler/crates/relay-compiler/src/compiler_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,22 @@ impl<V: Source + Clone> IncrementalSources<V> {
}

pub fn get_all_non_empty(&self) -> Vec<(&PathBuf, &V)> {
let mut sources: Vec<_> =
if self.pending.is_empty() {
self.processed
.iter()
.filter(|(_, value)| !value.is_empty())
.collect()
} else {
self.pending
.iter()
.chain(self.processed.iter().filter(|(key, value)| {
!self.pending.contains_key(*key) && !value.is_empty()
}))
.collect()
};
let mut sources: Vec<_> = if self.pending.is_empty() {
self.processed
.iter()
.filter(|(_, value)| !value.is_empty())
.collect()
} else {
self.pending
.iter()
.chain(
self.processed
.iter()
.filter(|(key, _)| !self.pending.contains_key(*key)),
)
.filter(|(_, value)| !value.is_empty())
.collect()
};
sources.sort_by_key(|file_content| file_content.0);
sources
}
Expand Down

0 comments on commit 7e41583

Please sign in to comment.