artemis_normalized_cache/lib.rs
1//! This is a normalized cache exchange for the [`artemis`](../artemis/index.html) GraphQL Client.
2//! This is a drop-in replacement for the default [`CacheExchange`] that, instead of document
3//! caching, caches normalized data by keys and connections between data.
4//!
5//! `artemis` is already quite a comprehensive GraphQL client. However in several cases it may be
6//! desirable to have data update across the entirety of an app when a response updates some known
7//! pieces of data.
8//!
9//! # Quick Start
10//!
11//! After installing this crate, change the default `artemis` Client like from something like this:
12//!
13//! ```
14//! let client = artemis::ClientBuilder::new("http://0.0.0.0")
15//! .with_default_exchanges()
16//! .build();
17//! ```
18//!
19//! to this
20//!
21//! ```
22//! use artemis::default_exchanges::{FetchExchange, DedupExchange};
23//! use artemis_normalized_cache::NormalizedCacheExchange;
24//!
25//! let client = artemis::ClientBuilder::new("http://0.0.0.0")
26//! .with_exchange(FetchExchange)
27//! .with_exchange(NormalizedCacheExchange::new())
28//! .with_exchange(DedupExchange)
29//! .build();
30//! ```
31//!
32//! TODO: Don't steal urlq's docs you plagiarist
33
34#![allow(unused_parens)]
35#![cfg_attr(test, feature(proc_macro_hygiene))]
36
37#[macro_use]
38extern crate async_trait;
39
40#[cfg(test)]
41#[macro_use]
42extern crate lazy_static;
43
44pub mod cache_exchange;
45mod store;
46mod types;
47
48pub use cache_exchange::NormalizedCacheExchange;
49use fnv::FnvBuildHasher;
50pub use store::QueryStore;
51#[doc(hidden)]
52pub use store::Store;
53pub use types::{NormalizedCacheExtension, NormalizedCacheOptions};
54
55pub type HashSet<V> = std::collections::HashSet<V, FnvBuildHasher>;
56pub type Dependencies = HashSet<String>;