apollo-angular-cache-ngrx
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.2 • Public • Published

NGRX Cache

npm version Get on Slack

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.

Readme

Keywords

none

Package Sidebar

Install

npm i apollo-angular-cache-ngrx

Weekly Downloads

10

Version

1.0.0-beta.2

License

MIT

Unpacked Size

45.9 kB

Total Files

37

Last publish

Collaborators

  • kamilkisiela