pub struct Node<RequestCtx>where
RequestCtx: Debug + RequestContext,{ /* private fields */ }Expand description
Represents a node in the graph data structure for auto-generated CRUD operations and custom resolvers.
§Examples
fn custom_resolve(facade: ResolverFacade<()>) -> BoxFuture<ExecutionResult> {
Box::pin(async move {
let typename = "User";
let mut props = HashMap::new();
props.insert("role".to_string(), Value::String("Admin".to_string()));
let n = facade.node(typename, props);
facade.resolve_node(&n).await
})
}Implementations§
Source§impl<RequestCtx> Node<RequestCtx>where
RequestCtx: RequestContext,
impl<RequestCtx> Node<RequestCtx>where
RequestCtx: RequestContext,
pub fn new( concrete_typename: String, fields: HashMap<String, Value>, ) -> Node<RequestCtx>
Sourcepub fn deser<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn deser<T: DeserializeOwned>(&self) -> Result<T, Error>
Attempts to deserialize a Node into a struct.
§Example
#[derive(Deserialize)]
struct Team {
name: String
}
fn handle_node(n: Node<()>) {
// succeeds if the fields of `n` can be deserialized into `Team`
let team: Team = n.deser().unwrap();
}pub fn id(&self) -> Result<&Value, Error>
pub fn type_name(&self) -> &String
Trait Implementations§
Source§impl<RequestCtx> GraphQLType for Node<RequestCtx>where
RequestCtx: RequestContext,
impl<RequestCtx> GraphQLType for Node<RequestCtx>where
RequestCtx: RequestContext,
Source§impl<RequestCtx> GraphQLValue for Node<RequestCtx>where
RequestCtx: RequestContext,
impl<RequestCtx> GraphQLValue for Node<RequestCtx>where
RequestCtx: RequestContext,
Source§type Context = GraphQLContext<RequestCtx>
type Context = GraphQLContext<RequestCtx>
Context type for this
GraphQLValue. Read moreSource§type TypeInfo = Info
type TypeInfo = Info
Type that may carry additional schema information for this
GraphQLValue. Read moreSource§fn concrete_type_name(
&self,
_context: &Self::Context,
info: &Self::TypeInfo,
) -> String
fn concrete_type_name( &self, _context: &Self::Context, info: &Self::TypeInfo, ) -> String
Returns the concrete
GraphQLType name for this GraphQLValue being an interface,
an union or an object. Read moreSource§fn resolve_field(
&self,
_info: &Self::TypeInfo,
_field_name: &str,
_arguments: &Arguments<'_, S>,
_executor: &Executor<'_, '_, Self::Context, S>,
) -> Result<Value<S>, FieldError<S>>
fn resolve_field( &self, _info: &Self::TypeInfo, _field_name: &str, _arguments: &Arguments<'_, S>, _executor: &Executor<'_, '_, Self::Context, S>, ) -> Result<Value<S>, FieldError<S>>
Resolves the value of a single field on this
GraphQLValue. Read moreSource§fn resolve_into_type(
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, '_, Self::Context, S>,
) -> Result<Value<S>, FieldError<S>>
fn resolve_into_type( &self, info: &Self::TypeInfo, type_name: &str, selection_set: Option<&[Selection<'_, S>]>, executor: &Executor<'_, '_, Self::Context, S>, ) -> Result<Value<S>, FieldError<S>>
Resolves this
GraphQLValue (being an interface or an union) into a concrete
downstream object type. Read moreSource§impl<RequestCtx> GraphQLValueAsync for Node<RequestCtx>where
RequestCtx: RequestContext,
impl<RequestCtx> GraphQLValueAsync for Node<RequestCtx>where
RequestCtx: RequestContext,
Source§fn resolve_field_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
field_name: &'a str,
args: &'a Arguments<'_>,
executor: &'a Executor<'_, '_, Self::Context>,
) -> BoxFuture<'a, ExecutionResult>
fn resolve_field_async<'a>( &'a self, info: &'a Self::TypeInfo, field_name: &'a str, args: &'a Arguments<'_>, executor: &'a Executor<'_, '_, Self::Context>, ) -> BoxFuture<'a, ExecutionResult>
Resolves the value of a single field on this
GraphQLValueAsync. Read moreSource§fn resolve_into_type_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
type_name: &str,
_selection_set: Option<&'a [Selection<'a>]>,
executor: &'a Executor<'a, 'a, Self::Context>,
) -> BoxFuture<'a, ExecutionResult>
fn resolve_into_type_async<'a>( &'a self, info: &'a Self::TypeInfo, type_name: &str, _selection_set: Option<&'a [Selection<'a>]>, executor: &'a Executor<'a, 'a, Self::Context>, ) -> BoxFuture<'a, ExecutionResult>
Resolves this
GraphQLValueAsync (being an interface or an union) into a
concrete downstream object type. Read moreAuto Trait Implementations§
impl<RequestCtx> Freeze for Node<RequestCtx>
impl<RequestCtx> RefUnwindSafe for Node<RequestCtx>where
RequestCtx: RefUnwindSafe,
impl<RequestCtx> Send for Node<RequestCtx>
impl<RequestCtx> Sync for Node<RequestCtx>
impl<RequestCtx> Unpin for Node<RequestCtx>where
RequestCtx: Unpin,
impl<RequestCtx> UnsafeUnpin for Node<RequestCtx>
impl<RequestCtx> UnwindSafe for Node<RequestCtx>where
RequestCtx: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Erased for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more