with scalars

This commit is contained in:
2023-01-29 13:29:11 +01:00
parent 3263f1d589
commit 0d6e6e57ae
6 changed files with 141 additions and 7 deletions

View File

@@ -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()
);

View 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)
}
}