Skip to main content

InterfaceBuilder

Struct InterfaceBuilder 

Source
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>

Source

pub fn description(&mut self, description: impl Into<Arc<str>>) -> &mut Self

Set the interface’s description.

Source

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.

Source

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.

Source

pub fn implements(&mut self, interface: impl Into<InterfaceRef>) -> &mut Self

Declare that this interface implements another interface.

Both node and &node are accepted.

Source

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.

Source

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.

Source

pub fn auth_error(&mut self, message: impl Into<Arc<str>>) -> &mut Self

Set the message returned when the interface-level authorization denies access.

Source

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.

Source

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.

Source

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.

Source

pub fn field_with<T, A>( &mut self, name: &'static str, ) -> InterfaceFieldConfig<'_, Ctx>
where T: OutputType, A: InputObject,

Add a field with arguments.

Source

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.

Trait Implementations§

Source§

impl<Ctx> Debug for InterfaceBuilder<'_, Ctx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, Ctx> !RefUnwindSafe for InterfaceBuilder<'a, Ctx>

§

impl<'a, Ctx> !UnwindSafe for InterfaceBuilder<'a, Ctx>

§

impl<'a, Ctx> Forget for InterfaceBuilder<'a, Ctx>

§

impl<'a, Ctx> Freeze for InterfaceBuilder<'a, Ctx>
where IndexMap<Arc<str>, Arc<AuthGuard<Ctx>>>: Freeze, Vec<Arc<AuthGuard<Ctx>>>: Freeze, PhantomData<fn() -> Ctx>: Freeze,

§

impl<'a, Ctx> Move for InterfaceBuilder<'a, Ctx>

§

impl<'a, Ctx> Send for InterfaceBuilder<'a, Ctx>
where IndexMap<Arc<str>, Arc<AuthGuard<Ctx>>>: Send, Vec<Arc<AuthGuard<Ctx>>>: Send, PhantomData<fn() -> Ctx>: Send,

§

impl<'a, Ctx> Sync for InterfaceBuilder<'a, Ctx>
where IndexMap<Arc<str>, Arc<AuthGuard<Ctx>>>: Sync, Vec<Arc<AuthGuard<Ctx>>>: Sync, PhantomData<fn() -> Ctx>: Sync,

§

impl<'a, Ctx> Unpin for InterfaceBuilder<'a, Ctx>
where IndexMap<Arc<str>, Arc<AuthGuard<Ctx>>>: Unpin, Vec<Arc<AuthGuard<Ctx>>>: Unpin, PhantomData<fn() -> Ctx>: Unpin,

§

impl<'a, Ctx> UnsafeUnpin for InterfaceBuilder<'a, Ctx>
where IndexMap<Arc<str>, Arc<AuthGuard<Ctx>>>: UnsafeUnpin, Vec<Arc<AuthGuard<Ctx>>>: UnsafeUnpin, PhantomData<fn() -> Ctx>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.