Bootstrap, vol.1

This commit is contained in:
tyranron 2022-04-19 18:47:42 +03:00
parent 30d80dff12
commit 56a68a9e24
No known key found for this signature in database
GPG key ID: 762E144FB230A4F0
4 changed files with 51 additions and 4 deletions

View file

@ -0,0 +1 @@
pub mod resolve;

View file

@ -0,0 +1,33 @@
use crate::{executor::Registry, resolve, schema::meta::MetaType, DefaultScalarValue};
pub trait TypeName {
fn type_name<Info: ?Sized>(info: &Info) -> &str
where
Self: resolve::TypeName<Info>;
}
impl<T: ?Sized> TypeName for T {
fn type_name<Info: ?Sized>(info: &Info) -> &str
where
Self: resolve::TypeName<Info>,
{
<Self as resolve::TypeName<Info>>::type_name(info)
}
}
pub trait Type<S = DefaultScalarValue> {
fn meta<'r, Info: ?Sized>(info: &Info, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
where
S: 'r,
Self: resolve::Type<Info, S>;
}
impl<T: ?Sized, S> Type<S> for T {
fn meta<'r, Info: ?Sized>(info: &Info, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
where
S: 'r,
Self: resolve::Type<Info, S>,
{
<Self as resolve::Type<Info, S>>::meta(info, registry)
}
}

View file

@ -28,19 +28,20 @@ pub use juniper_codegen::{
#[doc(hidden)]
#[macro_use]
pub mod macros;
mod ast;
pub mod executor;
pub mod graphql;
pub mod http;
pub mod integrations;
mod introspection;
pub mod parser;
pub mod resolve;
pub(crate) mod schema;
mod types;
mod util;
pub mod validation;
mod value;
// This needs to be public until docs have support for private modules:
// https://github.com/rust-lang/cargo/issues/1520
pub mod http;
pub mod integrations;
#[cfg(all(test, not(feature = "expose-test-schema")))]
mod tests;

View file

@ -0,0 +1,12 @@
use crate::{executor::Registry, schema::meta::MetaType, DefaultScalarValue, ScalarValue};
pub trait TypeName<Info: ?Sized> {
fn type_name(info: &Info) -> &str;
}
pub trait Type<Info: ?Sized, S = DefaultScalarValue> {
fn meta<'r>(info: &Info, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
where
S: 'r;
}