Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions src/Angular2Apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 {
Expand All @@ -33,11 +37,11 @@ export class Angular2Apollo {
@Inject(angularApolloClient) private client: any
) {}

public watchQuery(options: WatchQueryOptions): ApolloQueryObservable<ApolloQueryResult> {
public watchQuery(options: DeprecatedWatchQueryOptions): ApolloQueryObservable<ApolloQueryResult> {
return new ApolloQueryObservable(rxify(this.client.watchQuery)(options));
}

public query(options: WatchQueryOptions): Observable<ApolloQueryResult> {
public query(options: DeprecatedWatchQueryOptions): Observable<ApolloQueryResult> {
return Observable.fromPromise(this.client.query(options));
}

Expand Down