Struct juniper::Registry
[−]
[src]
pub struct Registry<CtxT> { pub types: HashMap<String, MetaType>, // some fields omitted }
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: HashMap<String, MetaType>
Currently registered types
Methods
impl<CtxT> Registry<CtxT>
[src]
fn new(types: HashMap<String, MetaType>) -> Registry<CtxT>
Construct a new registry
fn get_type<T>(&mut self) -> Type where T: GraphQLType<CtxT>
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.
fn field<T>(&mut self, name: &str) -> Field where T: GraphQLType<CtxT>
Create a field with the provided name
fn arg<T>(&mut self, name: &str) -> Argument where T: GraphQLType<CtxT> + FromInputValue
Create an argument with the provided name
fn arg_with_default<T>(&mut self, name: &str, value: &T) -> Argument where T: GraphQLType<CtxT> + ToInputValue + FromInputValue
Create an argument with a default value
When called with type T
, the actual argument will be given the type
Option<T>
.
fn build_scalar_type<T>(&mut self) -> ScalarMeta where T: FromInputValue + GraphQLType<CtxT>
Create a scalar meta type
This expects the type to implement FromInputValue
.
fn build_list_type<T: GraphQLType<CtxT>>(&mut self) -> ListMeta
Create a list meta type
fn build_nullable_type<T: GraphQLType<CtxT>>(&mut self) -> NullableMeta
Create a nullable meta type
fn build_object_type<T>(&mut self) -> Box<Fn(&[Field]) -> ObjectMeta> where T: GraphQLType<CtxT>
Create an object meta type builder
To prevent infinite recursion by enforcing ordering, this returns a function that needs to be called with the list of fields on the object.
fn build_enum_type<T>(&mut self) -> Box<Fn(&[EnumValue]) -> EnumMeta> where T: FromInputValue + GraphQLType<CtxT>
Create an enum meta type
fn build_interface_type<T>(&mut self) -> Box<Fn(&[Field]) -> InterfaceMeta> where T: GraphQLType<CtxT>
Create an interface meta type builder
fn build_union_type<T>(&mut self) -> Box<Fn(&[Type]) -> UnionMeta> where T: GraphQLType<CtxT>
Create a union meta type builder
fn build_input_object_type<T>(&mut self)
-> Box<Fn(&[Argument]) -> InputObjectMeta> where T: FromInputValue + GraphQLType<CtxT>
-> Box<Fn(&[Argument]) -> InputObjectMeta> where T: FromInputValue + GraphQLType<CtxT>
Create an input object meta type builder