mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-07-26 03:19:21 +02:00
with scalars
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
pub mod scalar;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use genco::prelude::rust::Tokens;
|
||||
@@ -25,7 +27,7 @@ pub trait Handler {
|
||||
let name = t.name.as_ref().ok_or(eyre::anyhow!("name not found"))?;
|
||||
|
||||
Ok(quote! {
|
||||
pub $name {} {
|
||||
pub struct $name {} {
|
||||
// TODO: Add fields
|
||||
}
|
||||
})
|
||||
@@ -35,7 +37,7 @@ pub trait Handler {
|
||||
let name = t.name.as_ref().ok_or(eyre::anyhow!("name not found"))?;
|
||||
|
||||
Ok(quote! {
|
||||
pub $name {} {
|
||||
impl $name {} {
|
||||
// TODO: Add fields
|
||||
}
|
||||
})
|
||||
@@ -48,6 +50,7 @@ pub type Handlers = Vec<DynHandler>;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use graphql_introspection_query::introspection_response::FullType;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::Handler;
|
||||
|
||||
@@ -73,8 +76,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
res,
|
||||
"
|
||||
pub SomeName {} { }
|
||||
pub SomeName {} { }
|
||||
pub struct SomeName {} { }
|
||||
impl SomeName {} { }
|
||||
"
|
||||
.to_string()
|
||||
);
|
||||
|
14
crates/dagger-codegen/src/handlers/scalar.rs
Normal file
14
crates/dagger-codegen/src/handlers/scalar.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use genco::Tokens;
|
||||
use graphql_introspection_query::introspection_response::FullType;
|
||||
|
||||
use crate::predicates::is_custom_scalar_type;
|
||||
|
||||
use super::Handler;
|
||||
|
||||
pub struct Scalar;
|
||||
|
||||
impl Handler for Scalar {
|
||||
fn predicate(&self, t: &FullType) -> bool {
|
||||
is_custom_scalar_type(t)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user