Struct juniper::Registry
[−]
[src]
pub struct Registry<'r> { pub types: HashMap<String, MetaType<'r>>, }
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<'r>>
Currently registered types
Methods
impl<'r> Registry<'r>
[src]
fn new(types: HashMap<String, MetaType<'r>>) -> Registry<'r>
Construct a new registry
fn get_type<T>(&mut self) -> Type<'r> where T: GraphQLType
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<'r> where T: GraphQLType
Create a field with the provided name
fn arg<T>(&mut self, name: &str) -> Argument<'r> where T: GraphQLType + FromInputValue
Create an argument with the provided name
fn arg_with_default<T>(&mut self, name: &str, value: &T) -> Argument<'r> where T: GraphQLType + 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<'r> where T: FromInputValue + GraphQLType
Create a scalar meta type
This expects the type to implement FromInputValue
.
fn build_list_type<T: GraphQLType>(&mut self) -> ListMeta<'r>
Create a list meta type
fn build_nullable_type<T: GraphQLType>(&mut self) -> NullableMeta<'r>
Create a nullable meta type
fn build_object_type<T>(&mut self, fields: &[Field<'r>]) -> ObjectMeta<'r> where T: GraphQLType
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, values: &[EnumValue]) -> EnumMeta<'r> where T: FromInputValue + GraphQLType
Create an enum meta type
fn build_interface_type<T>(&mut self, fields: &[Field<'r>]) -> InterfaceMeta<'r> where T: GraphQLType
Create an interface meta type builder
fn build_union_type<T>(&mut self, types: &[Type<'r>]) -> UnionMeta<'r> where T: GraphQLType
Create a union meta type builder
fn build_input_object_type<T>(&mut self,
args: &[Argument<'r>])
-> InputObjectMeta<'r> where T: FromInputValue + GraphQLType
args: &[Argument<'r>])
-> InputObjectMeta<'r> where T: FromInputValue + GraphQLType
Create an input object meta type builder