Struct artemis_normalized_cache::NormalizedCacheExtension [−][src]
A query extension that lets you pass additional logic into the cache.
Implementations
impl NormalizedCacheExtension
[src]
pub fn new() -> Self
[src]
Create a new query extension with default options.
pub fn update<Q: GraphQLQuery, F>(self, update: F) -> Self where
F: Fn(&Option<Q::ResponseData>, QueryStore, &mut HashSet<String>) + Send + Sync + 'static,
[src]
F: Fn(&Option<Q::ResponseData>, QueryStore, &mut HashSet<String>) + Send + Sync + 'static,
A custom updater function to run against related queries, such as lists of the same entity The function has 3 parameters:
current_data
- The returned data of the query you’re running. This may also be an optimistic result.store
- AQueryStore
object used to run custom update logic against other queries.dependencies
- This must be passed through to theQueryStore
without modification.
Example
let extension = NormalizedCacheExtension::new() .update::<GetConference, _>(|current_data, store, dependencies| { let conference = current_data.as_ref().unwrap().conference.as_ref().unwrap(); store.update_query(GetConferences, Variables, move |mut data| { if let Some(ResponseData { conferences: Some(ref mut conferences) }) = data { conferences.push(get_conferences::GetConferencesConferences { id: conference.id.clone(), name: conference.name.clone(), city: None, talks: None }); } data }, dependencies) });
pub fn optimistic_result<Q: GraphQLQuery, F: Fn() -> Option<Q::ResponseData> + 'static + Send + Sync>(
self,
optimistic_result: F
) -> Self
[src]
self,
optimistic_result: F
) -> Self
A function returning an optimistic result. This result will be written to a temporary cache layer and will be pushed to subscribers immediately. If subscribers aren’t used the optimistic result is ignored.
This closure must return an optional ResponseData
- None
is interpreted as
skip optimistic result
.
Trait Implementations
impl Clone for NormalizedCacheExtension
[src]
fn clone(&self) -> NormalizedCacheExtension
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for NormalizedCacheExtension
[src]
fn default() -> NormalizedCacheExtension
[src]
impl Extension for NormalizedCacheExtension
[src]
Auto Trait Implementations
impl !RefUnwindSafe for NormalizedCacheExtension
impl Send for NormalizedCacheExtension
impl Sync for NormalizedCacheExtension
impl Unpin for NormalizedCacheExtension
impl !UnwindSafe for NormalizedCacheExtension
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,