Skip to content

Instantly share code, notes, and snippets.

View MikeRyanDev's full-sized avatar

Mike Ryan MikeRyanDev

View GitHub Profile
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 115 32 168 255 255 92 32 56 32 255 255 255
255 255 255 32 32 32 115 255 32 69 59 44 255 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
import { Observable, Observer } from 'rxjs';
import { createSelector, MemoizedSelector } from '@ngrx/store';
import { createEntityAdapter } from '@ngrx/entity';
export interface View<T> extends Observable<T> {
isView: true;
release(): void;
}
export interface Value<T> extends View<T> {

First you have to define the scalar type in the GraphQL schema:

scalar Date

Then you have to provide a resolver for the scalar type. Here's an example implementation using Luxon:

import { DateTime } from 'luxon';

makeExecutableSchema({
export class BookEffects {
@Effect() deleteBook$ = this.action$.pipe(
ofType(INPUT_ACTION_TYPE),
mergeMap(action => this.bookService.deleteBook(action.bookId)),
);
}
export class BookEffects {
@Effect() updateBook$ = this.actions$.pipe(
ofType(INPUT_ACTION_TYPE),
groupBy(
action => action.bookId,
action => action,
action$ => action$.pipe(
timeoutWith(15000, Observable.empty()),
ignoreElements(),
),
export class BookEffects {
@Effect() getOneBook$ = this.action$.pipe(
ofType(INPUT_ACTION_TYPE),
groupBy(
action => action.bookId,
action => action.bookId,
bookId$ => bookId$.pipe(
timeoutWith(15000, Observable.empty(),
ignoreElements(),
),
groupBy(
/**
* Select groups by their `bookId`
*/
action => action.bookId,
/**
* Map each action to the `bookId` for convenience
*/
action => action.bookId,
/**
export class BookEffects {
@Effect() getOneBook$ = this.actions$.pipe(
// Step 1 Type: Observable<InputActionType>
ofType(INPUT_ACTION_TYPE),
// Step 2 Type: Observable<Observable<InputActionType>>
groupBy(action => action.bookId),
// Step 3 Type: Observable<Observable<BookModel>>,
map(action$ => action$.pipe(
exhaustMap(action => this.bookService.getOne(action.bookId),
)),
export class BookEffects {
@Effect() getOneBook$ = this.actions$.pipe(
ofType(INPUT_ACTION_TYPE),
exhaustMap(action => this.booksService.getOne(action.bookId)),
);
}
export class BookEffects {
@Effect() searchBooks$ = this.actions$.pipe(
ofType(INPUT_ACTION_TYPE),
switchMap(action => this.booksService.searchBooks(
action.searchTerm,
)),
);
}