Skip to content

Commit

Permalink
Combine preloaded queries with mock files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgasson committed Mar 25, 2024
1 parent 8b62713 commit 307171f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions compiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions compiler/crates/persisted-mocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

use relay_codegen::QueryID;
use relay_compiler::build_project::generate_extra_artifacts::default_generate_extra_artifacts_fn;
use relay_compiler::config::Config;
use relay_compiler::Artifact;
use relay_compiler::ArtifactContent;
use relay_compiler::ProjectConfig;
Expand All @@ -20,12 +22,14 @@ struct QueryForMock {
}

pub fn generate_persisted_mocks(
config: &Config,
project_config: &ProjectConfig,
_schema: &SDLSchema,
_programs: &Programs,
schema: &SDLSchema,
program: &Programs,
artifacts: &[Artifact],
) -> Vec<Artifact> {
let mut extra = vec![];
let mut extra =
default_generate_extra_artifacts_fn(config, project_config, schema, program, artifacts);
if let Some(folder) = &project_config.extra_artifacts_output {
for artifact in artifacts {
if let ArtifactContent::Operation {
Expand Down
8 changes: 3 additions & 5 deletions compiler/crates/relay-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use intern::string_key::Intern;
use log::error;
use log::info;
use relay_compiler::build_project::artifact_writer::ArtifactValidationWriter;
use relay_compiler::build_project::generate_extra_artifacts::default_generate_extra_artifacts_fn;
use relay_compiler::compiler::Compiler;
use relay_compiler::config::Config;
use relay_compiler::errors::Error as CompilerError;
Expand Down Expand Up @@ -284,9 +283,6 @@ async fn handle_compiler_command(command: CompileCommand) -> Result<(), Error> {
)
}));

// Atlassian: Output id -> query text for testing / mocking usage
config.generate_extra_artifacts = Some(Box::new(persisted_mocks::generate_persisted_mocks));

config.file_source_config = if should_use_watchman() {
FileSourceKind::Watchman
} else {
Expand All @@ -300,7 +296,9 @@ async fn handle_compiler_command(command: CompileCommand) -> Result<(), Error> {
);
}

config.generate_extra_artifacts = Some(Box::new(default_generate_extra_artifacts_fn));
// Atlassian:
// Edited to output id -> query text for testing / mocking usage
config.generate_extra_artifacts = Some(Box::new(persisted_mocks::generate_persisted_mocks));

let compiler = Compiler::new(Arc::new(config), Arc::new(ConsoleLogger));

Expand Down

0 comments on commit 307171f

Please sign in to comment.