From eec3c31791a1b32b34d12534573292da262b5258 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Tue, 8 Nov 2016 13:46:00 +0100 Subject: [PATCH] fix(Angular2Apollo): use deprecated options, fix the Document type origin --- CHANGELOG.md | 2 +- src/Angular2Apollo.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ccbbd1a..4c91f9080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### vNEXT - Made `mutate()` and `query()` methods to return `Observable` instead of `Promise` ([PR #140](https://github.com/apollostack/angular2-apollo/pull/140)) -- Define types of options and results (of `watchQuery`, `query`, `mutate`) ([PR #145](https://github.com/apollostack/angular2-apollo/pull/145)) +- Define types of options and results (of `watchQuery`, `query`, `mutate`) ([PR #145](https://github.com/apollostack/angular2-apollo/pull/145) [PR #148](https://github.com/apollostack/angular2-apollo/pull/148)) ### v0.7.0 diff --git a/src/Angular2Apollo.ts b/src/Angular2Apollo.ts index fa94ea31a..22e96d310 100644 --- a/src/Angular2Apollo.ts +++ b/src/Angular2Apollo.ts @@ -2,7 +2,7 @@ import { OpaqueToken, Injectable, Inject } from '@angular/core'; import { rxify } from 'apollo-client-rxjs'; import { ApolloClient, ApolloQueryResult, WatchQueryOptions, MutationBehavior, MutationQueryReducersMap } from 'apollo-client'; import { Observable } from 'rxjs/Observable'; -import { FragmentDefinition } from 'graphql'; +import { Document, FragmentDefinition } from 'graphql'; import { ApolloQueryObservable } from './ApolloQueryObservable'; @@ -19,6 +19,10 @@ export interface MutateOptions { refetchQueries?: string[]; } +export interface DeprecatedWatchQueryOptions extends WatchQueryOptions { + fragments?: FragmentDefinition[]; +} + export const angularApolloClient = new OpaqueToken('AngularApolloClient'); export function defaultApolloClient(client: ApolloClient): any { return { @@ -33,11 +37,11 @@ export class Angular2Apollo { @Inject(angularApolloClient) private client: any ) {} - public watchQuery(options: WatchQueryOptions): ApolloQueryObservable { + public watchQuery(options: DeprecatedWatchQueryOptions): ApolloQueryObservable { return new ApolloQueryObservable(rxify(this.client.watchQuery)(options)); } - public query(options: WatchQueryOptions): Observable { + public query(options: DeprecatedWatchQueryOptions): Observable { return Observable.fromPromise(this.client.query(options)); }