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
sourceimpl<'r, S> Registry<'r, S> where
S: ScalarValue + 'r,
impl<'r, S> Registry<'r, S> where
S: ScalarValue + 'r,
sourcepub fn new(types: FnvHashMap<Name, MetaType<'r, S>>) -> Registry<'r, S>
pub fn new(types: FnvHashMap<Name, MetaType<'r, S>>) -> Registry<'r, S>
Construct a new registry
sourcepub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r> where
T: GraphQLType<S> + ?Sized,
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.
sourcepub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S> where
T: GraphQLType<S> + ?Sized,
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
sourcepub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S> where
T: GraphQLType<S> + FromInputValue<S> + ?Sized,
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
sourcepub 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,
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>
.
sourcepub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S> where
T: FromInputValue<S> + GraphQLType<S> + ParseScalarValue<S> + ?Sized + 'r,
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
.
sourcepub fn build_list_type<T: GraphQLType<S> + ?Sized>(
&mut self,
info: &T::TypeInfo
) -> ListMeta<'r>
pub fn build_list_type<T: GraphQLType<S> + ?Sized>(
&mut self,
info: &T::TypeInfo
) -> ListMeta<'r>
Create a list meta type
sourcepub fn build_nullable_type<T: GraphQLType<S> + ?Sized>(
&mut self,
info: &T::TypeInfo
) -> NullableMeta<'r>
pub fn build_nullable_type<T: GraphQLType<S> + ?Sized>(
&mut self,
info: &T::TypeInfo
) -> NullableMeta<'r>
Create a nullable meta type
sourcepub fn build_object_type<T>(
&mut self,
info: &T::TypeInfo,
fields: &[Field<'r, S>]
) -> ObjectMeta<'r, S> where
T: GraphQLType<S> + ?Sized,
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.
sourcepub fn build_enum_type<T>(
&mut self,
info: &T::TypeInfo,
values: &[EnumValue]
) -> EnumMeta<'r, S> where
T: FromInputValue<S> + GraphQLType<S> + ?Sized,
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
sourcepub fn build_interface_type<T>(
&mut self,
info: &T::TypeInfo,
fields: &[Field<'r, S>]
) -> InterfaceMeta<'r, S> where
T: GraphQLType<S> + ?Sized,
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.
sourcepub fn build_union_type<T>(
&mut self,
info: &T::TypeInfo,
types: &[Type<'r>]
) -> UnionMeta<'r> where
T: GraphQLType<S> + ?Sized,
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
sourcepub 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,
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more