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>
impl<'r, S: 'r> Registry<'r, S>
Sourcepub fn new(types: FnvHashMap<Name, MetaType<'r, S>>) -> Self
pub fn new(types: FnvHashMap<Name, MetaType<'r, S>>) -> Self
Constructs a new Registry out of the given types.
Sourcepub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r>
pub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r>
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.
Sourcepub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S>
pub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S>
Creates a Field with the provided name.
Sourcepub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S>
pub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S>
Creates an Argument with the provided name.
Sourcepub fn arg_with_default<T>(
&mut self,
name: &str,
value: &T,
info: &T::TypeInfo,
) -> Argument<'r, S>
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.
Sourcepub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>where
T: GraphQLType<S> + FromInputValue<S> + ParseScalarValue<S>,
T::Error: IntoFieldError<S>,
S: ScalarValue,
pub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>where
T: GraphQLType<S> + FromInputValue<S> + ParseScalarValue<S>,
T::Error: IntoFieldError<S>,
S: ScalarValue,
Creates a ScalarMeta type.
Sourcepub fn build_list_type<T>(
&mut self,
info: &T::TypeInfo,
expected_size: Option<usize>,
) -> ListMeta<'r>
pub fn build_list_type<T>( &mut self, info: &T::TypeInfo, expected_size: Option<usize>, ) -> ListMeta<'r>
Creates a ListMeta type.
Specifying expected_size will be used to ensure that values of this
type will always match it.
Sourcepub fn build_nullable_type<T>(&mut self, info: &T::TypeInfo) -> NullableMeta<'r>
pub fn build_nullable_type<T>(&mut self, info: &T::TypeInfo) -> NullableMeta<'r>
Creates a NullableMeta type.
Sourcepub fn build_object_type<T>(
&mut self,
info: &T::TypeInfo,
fields: &[Field<'r, S>],
) -> ObjectMeta<'r, S>
pub fn build_object_type<T>( &mut self, info: &T::TypeInfo, fields: &[Field<'r, S>], ) -> ObjectMeta<'r, S>
Creates an ObjectMeta type with the given fields.
Sourcepub fn build_enum_type<T>(
&mut self,
info: &T::TypeInfo,
values: &[EnumValue],
) -> EnumMeta<'r, S>
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.
Sourcepub fn build_interface_type<T>(
&mut self,
info: &T::TypeInfo,
fields: &[Field<'r, S>],
) -> InterfaceMeta<'r, S>
pub fn build_interface_type<T>( &mut self, info: &T::TypeInfo, fields: &[Field<'r, S>], ) -> InterfaceMeta<'r, S>
Creates an InterfaceMeta type with the given fields.
Sourcepub fn build_union_type<T>(
&mut self,
info: &T::TypeInfo,
types: &[Type<'r>],
) -> UnionMeta<'r>
pub fn build_union_type<T>( &mut self, info: &T::TypeInfo, types: &[Type<'r>], ) -> UnionMeta<'r>
Creates an UnionMeta type of the given types.
Sourcepub fn build_input_object_type<T>(
&mut self,
info: &T::TypeInfo,
args: &[Argument<'r, S>],
) -> InputObjectMeta<'r, S>
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.