#[non_exhaustive]pub struct BeforeMutationRequest<'a> {
pub principal: Option<&'a SecurityContext>,
pub mutation: &'a str,
pub response_key: &'a str,
pub arguments: &'a Value,
pub reader: Option<Arc<dyn GuestQueryBridge>>,
}Expand description
The write a BeforeMutationGate is being asked to adjudicate.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.principal: Option<&'a SecurityContext>The authenticated principal, or None for an unauthenticated (anonymous) request.
mutation: &'a strThe mutation field name — the key the chain is looked up under. Never the response alias.
response_key: &'a strThe key this root’s result appears under in data (the alias when the document
supplies one, otherwise the same as mutation). Diagnostics only.
arguments: &'a ValueThe arguments this write will run with: request variables merged with the root
field’s inline literals, nested $var references resolved. Null when the write
has no arguments at all.
reader: Option<Arc<dyn GuestQueryBridge>>The caller-scoped, read-only GraphQL bridge this hook may read through
(#1328), or None on a request built by hand.
Owned rather than borrowed because the gate hands it to guest code that runs on another thread — the Deno runtime spawns an OS thread per invocation — so it has to outlive this call. The engine builds one per adjudicated write; a gate that never reads simply drops it.
Implementations§
Source§impl<'a> BeforeMutationRequest<'a>
impl<'a> BeforeMutationRequest<'a>
Sourcepub const fn new(
principal: Option<&'a SecurityContext>,
mutation: &'a str,
response_key: &'a str,
arguments: &'a Value,
) -> Self
pub const fn new( principal: Option<&'a SecurityContext>, mutation: &'a str, response_key: &'a str, arguments: &'a Value, ) -> Self
Build a request with no read bridge. The engine is the only production
constructor; this exists so an implementor outside this crate can exercise
its own gate, which #[non_exhaustive] would otherwise make impossible.
Sourcepub fn with_reader(self, reader: Arc<dyn GuestQueryBridge>) -> Self
pub fn with_reader(self, reader: Arc<dyn GuestQueryBridge>) -> Self
Attach the caller-scoped read bridge (#1328).