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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### vNEXT

- Added `subscribe` method to `Angular2Apollo` service ([PR #113](https://github.com/apollostack/angular2-apollo/pull/113))
- Added `updateQuery` to `ApolloQueryObservable` ([PR #113](https://github.com/apollostack/angular2-apollo/pull/113))

### v0.4.6

- Moved to Angular 2 final and updated RxJS to the latest version ([PR #96](https://github.com/apollostack/angular2-apollo/pull/96))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"rxjs": "^5.0.0-beta.12"
},
"dependencies": {
"apollo-client-rxjs": "^0.0.1",
"apollo-client-rxjs": "^0.1.0",
"lodash.assign": "^4.0.9",
"lodash.forin": "^4.2.0",
"lodash.isequal": "^4.2.0"
Expand Down
17 changes: 13 additions & 4 deletions src/Angular2Apollo.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { OpaqueToken, Injectable, Inject } from '@angular/core';
import { rxify } from 'apollo-client-rxjs';
import { ApolloQueryResult } from 'apollo-client';
import { Observable } from 'rxjs/Observable';

import { ApolloQueryObservable } from './ApolloQueryObservable';

import ApolloClient from 'apollo-client';

import 'rxjs/add/operator/switchMap';
import 'rxjs/add/observable/from';

export const angularApolloClient = new OpaqueToken('AngularApolloClient');
export const defaultApolloClient = (client: ApolloClient): any => {
Expand All @@ -22,15 +23,23 @@ export class Angular2Apollo {
@Inject(angularApolloClient) private client: any
) {}

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

public query(options) {
public query(options: any) {
return this.client.query(options);
}

public mutate(options) {
public mutate(options: any) {
return this.client.mutate(options);
}

public subscribe(options: any): Observable<any> {
if (typeof this.client.subscribe === 'undefined') {
throw new Error(`Your version of ApolloClient doesn't support subscriptions`);
}

return Observable.from(this.client.subscribe(options));
}
}