[][src]Struct async_graphql::CacheControl

pub struct CacheControl {
    pub public: bool,
    pub max_age: usize,
}

Cache control values

Examples

use async_graphql::*;

struct QueryRoot;

#[Object(cache_control(max_age = 60))]
impl QueryRoot {
    #[field(cache_control(max_age = 30))]
    async fn value1(&self) -> i32 {
        unimplemented!()
    }

    #[field(cache_control(private))]
    async fn value2(&self) -> i32 {
        unimplemented!()
    }
}

#[async_std::main]
async fn main() {
    let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
    assert_eq!(schema.query("{ value1 }").prepare().unwrap().cache_control(), CacheControl { public: true, max_age: 30 });
    assert_eq!(schema.query("{ value2 }").prepare().unwrap().cache_control(), CacheControl { public: false, max_age: 60 });
    assert_eq!(schema.query("{ value1 value2 }").prepare().unwrap().cache_control(), CacheControl { public: false, max_age: 30 });
}

Fields

public: bool

Scope is public, default is true

max_age: usize

Cache max age, default is 0.

Methods

impl CacheControl[src]

pub fn value(&self) -> Option<String>[src]

Get 'Cache-Control' header value.

Trait Implementations

impl Clone for CacheControl[src]

impl Copy for CacheControl[src]

impl Debug for CacheControl[src]

impl Default for CacheControl[src]

impl Eq for CacheControl[src]

impl PartialEq<CacheControl> for CacheControl[src]

impl StructuralEq for CacheControl[src]

impl StructuralPartialEq for CacheControl[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,