apollo-angular-cache-ngrx
v1.0.0-beta.2
Published
Allows to use @ngrx/store as Apollo Cache
Downloads
22
Readme
NGRX Cache
Purpose
Allows to use @ngrx/store as Apollo Cache
Installation
npm install apollo-angular-cache-ngrx --save
Usage
Put apolloReducer
under apollo
in your State and simply import
NgrxCacheModule
.
import {StoreModule} from '@ngrx/store';
import {
NgrxCacheModule,
NgrxCache,
apolloReducer,
} from 'apollo-angular-cache-ngrx';
@NgModule({
imports: [
StoreModule.forRoot({
apollo: apolloReducer,
}),
NgrxCacheModule,
],
})
class AppModule {
constructor(ngrxCache: NgrxCache) {
const cache = ngrxCache.create({});
}
}
Second method is about putting apolloReducer
under any key you want to in your
State and because of that, use NgrxCacheModule.forRoot(key: string)
in
imports, where key
points to that key.
import {StoreModule} from '@ngrx/store';
import {
NgrxCacheModule,
NgrxCache,
apolloReducer,
} from 'apollo-angular-cache-ngrx';
@NgModule({
imports: [
StoreModule.forRoot({
myCustomApollo: apolloReducer,
}),
NgrxCacheModule.forRoot('myCustomApollo'),
],
})
class AppModule {
constructor(ngrxCache: NgrxCache) {
const cache = ngrxCache.create({});
}
}
Options
Same options as in apollo-cache-inmemory
.