juniper::executor

Struct 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: 'r> Registry<'r, S>

Source

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

Constructs a new Registry out of the given types.

Source

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

Returns a Type instance for the given GraphQLType, registered in this Registry.

If this Registry hasn’t seen a Type with such GraphQLType::name before, it will construct the one and store it.

Source

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

Creates 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>, S: ScalarValue,

Creates 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>

Creates an Argument with the provided default value.

Source

pub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>

Creates a ScalarMeta type.

Source

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

Creates a ListMeta type.

Specifying expected_size will be used to ensure that values of this type will always match it.

Source

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

Creates a NullableMeta 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, S: ScalarValue,

Creates an ObjectMeta type with the given fields.

Source

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

Creates an EnumMeta type out of the provided values.

Source

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

Creates an InterfaceMeta type with the given fields.

Source

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

Creates an UnionMeta type of the given types.

Source

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

Creates an InputObjectMeta type with the given args.

Auto Trait Implementations§

§

impl<'r, S> Freeze for Registry<'r, S>

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.