Struct juniper::executor::Registry

source ·
pub struct Registry<'r, S = DefaultScalarValue> {
    pub types: FnvHashMap<Name, MetaType<'r, S>>,
}
Expand description

A type registry used to build schemas

The registry gathers metadata for all types in a schema. It provides convenience methods to convert types implementing the GraphQLType trait into Type instances and automatically registers them.

Fields§

§types: FnvHashMap<Name, MetaType<'r, S>>

Currently registered types

Implementations§

source§

impl<'r, S> Registry<'r, S>where
    S: ScalarValue + 'r,

source

pub fn new(types: FnvHashMap<Name, MetaType<'r, S>>) -> Registry<'r, S>

Construct a new registry

source

pub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r>where
    T: GraphQLType<S> + ?Sized,

Get the Type instance for a given GraphQL type

If the registry hasn’t seen a type with this name before, it will construct its metadata and store it.

source

pub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S>where
    T: GraphQLType<S> + ?Sized,

Create a field with the provided name

source

pub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S>where
    T: GraphQLType<S> + FromInputValue<S> + ?Sized,

Create an argument with the provided name

source

pub fn arg_with_default<T>(
    &mut self,
    name: &str,
    value: &T,
    info: &T::TypeInfo
) -> Argument<'r, S>where
    T: GraphQLType<S> + ToInputValue<S> + FromInputValue<S> + ?Sized,

Create an argument with a default value

When called with type T, the actual argument will be given the type Option<T>.

source

pub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>where
    T: FromInputValue<S> + GraphQLType<S> + ParseScalarValue<S> + ?Sized + 'r,

Create a scalar meta type

This expects the type to implement FromInputValue.

source

pub fn build_list_type<T: GraphQLType<S> + ?Sized>(
    &mut self,
    info: &T::TypeInfo
) -> ListMeta<'r>

Create a list meta type

source

pub fn build_nullable_type<T: GraphQLType<S> + ?Sized>(
    &mut self,
    info: &T::TypeInfo
) -> NullableMeta<'r>

Create a nullable meta type

source

pub fn build_object_type<T>(
    &mut self,
    info: &T::TypeInfo,
    fields: &[Field<'r, S>]
) -> ObjectMeta<'r, S>where
    T: GraphQLType<S> + ?Sized,

Create an object meta type

To prevent infinite recursion by enforcing ordering, this returns a function that needs to be called with the list of fields on the object.

source

pub fn build_enum_type<T>(
    &mut self,
    info: &T::TypeInfo,
    values: &[EnumValue]
) -> EnumMeta<'r, S>where
    T: FromInputValue<S> + GraphQLType<S> + ?Sized,

Create an enum meta type

source

pub fn build_interface_type<T>(
    &mut self,
    info: &T::TypeInfo,
    fields: &[Field<'r, S>]
) -> InterfaceMeta<'r, S>where
    T: GraphQLType<S> + ?Sized,

Create an interface meta type, by providing a type info object.

source

pub fn build_union_type<T>(
    &mut self,
    info: &T::TypeInfo,
    types: &[Type<'r>]
) -> UnionMeta<'r>where
    T: GraphQLType<S> + ?Sized,

Create a union meta type

source

pub fn build_input_object_type<T>(
    &mut self,
    info: &T::TypeInfo,
    args: &[Argument<'r, S>]
) -> InputObjectMeta<'r, S>where
    T: FromInputValue<S> + GraphQLType<S> + ?Sized,

Create an input object meta type

Auto Trait Implementations§

§

impl<'r, S> RefUnwindSafe for Registry<'r, S>where
    S: RefUnwindSafe,

§

impl<'r, S> Send for Registry<'r, S>where
    S: Send,

§

impl<'r, S> Sync for Registry<'r, S>where
    S: Sync,

§

impl<'r, S> Unpin for Registry<'r, S>where
    S: Unpin,

§

impl<'r, S> UnwindSafe for Registry<'r, S>where
    S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V