Skip to content

Commit

Permalink
Add retrocompatible import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Virgiel committed Oct 21, 2023
1 parent d68b13b commit 593a4a0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
12 changes: 12 additions & 0 deletions benches/generated/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// This file was generated with `cornucopia`. Do not modify.

pub mod bench;
pub mod sync {
pub mod bench {
pub use super::super::bench::sync::*;
pub use super::super::bench::*;
}
}
pub mod async_ {
pub mod bench {
pub use super::super::bench::async_::*;
pub use super::super::bench::*;
}
}
37 changes: 36 additions & 1 deletion crates/cornucopia/src/codegen/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,43 @@ pub(crate) fn gen_queries(vfs: &mut Vfs, preparation: &Preparation, settings: Co
}

let modules_name = preparation.modules.iter().map(|module| &module.info.name);
let content = code!($WARNING

let mut content = code!($WARNING
$(pub mod $modules_name;)
);
if settings.gen_async && settings.gen_sync {
let sync = |w: &mut String| {
for module in &preparation.modules {
let name = &module.info.name;
code!(w =>
pub mod ${name} {
pub use super::super::${name}::*;
pub use super::super::${name}::sync::*;
}
);
}
};
let async_ = |w: &mut String| {
for module in &preparation.modules {
let name = &module.info.name;
code!(w =>
pub mod ${name} {
pub use super::super::${name}::*;
pub use super::super::${name}::async_::*;
}
);
}
};
let content = &mut content;
code!(content =>
pub mod sync {
$!sync
}
pub mod async_ {
$!async_
}
)
}

vfs.add("src/queries.rs", content);
}
60 changes: 60 additions & 0 deletions test_codegen/codegen/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,63 @@ pub mod nullity;
pub mod params;
pub mod stress;
pub mod syntax;
pub mod sync {
pub mod copy {
pub use super::super::copy::sync::*;
pub use super::super::copy::*;
}
pub mod domain {
pub use super::super::domain::sync::*;
pub use super::super::domain::*;
}
pub mod named {
pub use super::super::named::sync::*;
pub use super::super::named::*;
}
pub mod nullity {
pub use super::super::nullity::sync::*;
pub use super::super::nullity::*;
}
pub mod params {
pub use super::super::params::sync::*;
pub use super::super::params::*;
}
pub mod stress {
pub use super::super::stress::sync::*;
pub use super::super::stress::*;
}
pub mod syntax {
pub use super::super::syntax::sync::*;
pub use super::super::syntax::*;
}
}
pub mod async_ {
pub mod copy {
pub use super::super::copy::async_::*;
pub use super::super::copy::*;
}
pub mod domain {
pub use super::super::domain::async_::*;
pub use super::super::domain::*;
}
pub mod named {
pub use super::super::named::async_::*;
pub use super::super::named::*;
}
pub mod nullity {
pub use super::super::nullity::async_::*;
pub use super::super::nullity::*;
}
pub mod params {
pub use super::super::params::async_::*;
pub use super::super::params::*;
}
pub mod stress {
pub use super::super::stress::async_::*;
pub use super::super::stress::*;
}
pub mod syntax {
pub use super::super::syntax::async_::*;
pub use super::super::syntax::*;
}
}

0 comments on commit 593a4a0

Please sign in to comment.