pub struct InterfaceBuilder<'a, Ctx: 'static> { /* private fields */ }Expand description
Builder for one interface type, received by Schema::interface.
Implementations§
Source§impl<'a, Ctx: 'static> InterfaceBuilder<'a, Ctx>
impl<'a, Ctx: 'static> InterfaceBuilder<'a, Ctx>
Sourcepub fn description(&mut self, description: impl Into<Arc<str>>) -> &mut Self
pub fn description(&mut self, description: impl Into<Arc<str>>) -> &mut Self
Set the interface’s description.
Sourcepub fn directive(&mut self, directive: AppliedDirective) -> &mut Self
pub fn directive(&mut self, directive: AppliedDirective) -> &mut Self
Apply a directive to this interface type.
Each call adds an application in declaration order. See Schema::directive for the
definition side and validation rules.
Sourcepub fn has_field(&self, name: &str) -> bool
pub fn has_field(&self, name: &str) -> bool
Whether this interface already declares a field with name.
Read-only, for extensions that add a field only when it is absent.
Sourcepub fn implements(&mut self, interface: impl Into<InterfaceRef>) -> &mut Self
pub fn implements(&mut self, interface: impl Into<InterfaceRef>) -> &mut Self
Declare that this interface implements another interface.
Both node and &node are accepted.
Sourcepub fn auth(
&mut self,
predicate: impl Fn(&Ctx) -> bool + Send + Sync + 'static,
) -> &mut Self
pub fn auth( &mut self, predicate: impl Fn(&Ctx) -> bool + Send + Sync + 'static, ) -> &mut Self
Require every field of every implementing object to satisfy predicate.
The rule is inherited by objects that implement this interface, directly or through another interface. It composes with object-level and field-level checks. A rule declared when the interface is reopened adds to the existing rules rather than replacing them.
Sourcepub fn auth_async(
&mut self,
predicate: impl for<'r> Fn(&'r Ctx) -> BoxFuture<'r, bool> + Send + Sync + 'static,
) -> &mut Self
pub fn auth_async( &mut self, predicate: impl for<'r> Fn(&'r Ctx) -> BoxFuture<'r, bool> + Send + Sync + 'static, ) -> &mut Self
Like InterfaceBuilder::auth, but the predicate is asynchronous.
Sourcepub fn auth_error(&mut self, message: impl Into<Arc<str>>) -> &mut Self
pub fn auth_error(&mut self, message: impl Into<Arc<str>>) -> &mut Self
Set the message returned when the interface-level authorization denies access.
Sourcepub fn field<T: OutputType>(
&mut self,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>
pub fn field<T: OutputType>( &mut self, name: &'static str, ) -> InterfaceFieldConfig<'_, Ctx>
Add a field with no arguments.
Interface fields have no resolver: the concrete objects supply one. The field’s type must be a covariant match for every implementing object’s field. Authorization declared on the field is inherited by those objects.
Sourcepub fn field_ref<T, N>(
&mut self,
reference: &ObjectRef<N>,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>where
T: OutputType,
N: ObjectModel,
pub fn field_ref<T, N>(
&mut self,
reference: &ObjectRef<N>,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>where
T: OutputType,
N: ObjectModel,
Add a field whose output type is a runtime-named object.
T supplies the list and nullability wrappers; reference supplies the name. Use it for
interface fields that return a dynamically named type such as a connection.
Sourcepub fn field_ref_type<T: OutputType>(
&mut self,
ty: TypeRef,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>
pub fn field_ref_type<T: OutputType>( &mut self, ty: TypeRef, name: &'static str, ) -> InterfaceFieldConfig<'_, Ctx>
Add a field with an explicitly built runtime type reference.
Sourcepub fn field_with<T, A>(
&mut self,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>where
T: OutputType,
A: InputObject,
pub fn field_with<T, A>(
&mut self,
name: &'static str,
) -> InterfaceFieldConfig<'_, Ctx>where
T: OutputType,
A: InputObject,
Add a field with arguments.
Sourcepub fn resolve_type(
&mut self,
resolver: impl Fn(&Value, &ExecutionContext) -> Result<Name, GraphQLError> + Send + Sync + 'static,
) -> &mut Self
pub fn resolve_type( &mut self, resolver: impl Fn(&Value, &ExecutionContext) -> Result<Name, GraphQLError> + Send + Sync + 'static, ) -> &mut Self
Install a custom abstract type resolver.
By default the executor uses each object’s is_type_of check.