#graphql #graphql-client #exchange #cache #artemis #web

artemis-normalized-cache

A graph-based normalized cache exchange for the artemis crate

7 releases

0.1.1 Mar 6, 2021
0.1.0 Mar 6, 2021
0.1.0-alpha.4 Apr 26, 2020

#2 in #artemis

Download history 7/week @ 2024-09-19 8/week @ 2024-09-26 5/week @ 2024-10-10 1/week @ 2024-10-17 1/week @ 2024-10-31 11/week @ 2024-11-28 64/week @ 2024-12-05 27/week @ 2024-12-12

102 downloads per month

MIT/Apache

1MB
4.5K SLoC

artemis-normalized-cache

This is a normalized cache exchange for the artemis GraphQL Client. This is a drop-in replacement for the default CacheExchange that, instead of document caching, caches normalized data by keys and connections between data.

artemis is already quite a comprehensive GraphQL client. However in several cases it may be desirable to have data update across the entirety of an app when a response updates some known pieces of data.

Quick Start

After installing this crate, change the default artemis Client like from something like this:

let client = artemis::ClientBuilder::new("http://0.0.0.0")
    .with_default_exchanges()
    .build();

to this

use artemis::default_exchanges::{FetchExchange, DedupExchange};
use artemis_normalized_cache::NormalizedCacheExchange;

let client = artemis::ClientBuilder::new("http://0.0.0.0")
    .with_exchange(FetchExchange)
    .with_exchange(NormalizedCacheExchange::new())
    .with_exchange(DedupExchange)
    .build();

TODO: Don't steal urlq's docs you plagiarist

Dependencies

~5–7.5MB
~153K SLoC