From 767971d4928e9fe89640687742971c940f6a9f64 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Wed, 2 Nov 2016 18:19:30 +0100 Subject: [PATCH 1/3] feat(Angular2Apollo): Add more types WatchQueryOptions as options and Promise as result --- src/Angular2Apollo.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Angular2Apollo.ts b/src/Angular2Apollo.ts index 09b1575b4..f624397dc 100644 --- a/src/Angular2Apollo.ts +++ b/src/Angular2Apollo.ts @@ -1,12 +1,22 @@ import { OpaqueToken, Injectable, Inject } from '@angular/core'; import { rxify } from 'apollo-client-rxjs'; -import { ApolloClient, ApolloQueryResult } from 'apollo-client'; +import { ApolloClient, ApolloQueryResult, WatchQueryOptions, MutationBehavior, MutationQueryReducersMap } from 'apollo-client'; import { Observable } from 'rxjs/Observable'; import { ApolloQueryObservable } from './ApolloQueryObservable'; import 'rxjs/add/observable/from'; +export interface MutateOptions { + mutation: Document; + variables?: Object; + resultBehaviors?: MutationBehavior[]; + fragments?: any[]; + optimisticResponse?: Object; + updateQueries?: MutationQueryReducersMap; + refetchQueries?: string[]; +} + export const angularApolloClient = new OpaqueToken('AngularApolloClient'); export function defaultApolloClient(client: ApolloClient): any { return { @@ -21,15 +31,15 @@ export class Angular2Apollo { @Inject(angularApolloClient) private client: any ) {} - public watchQuery(options: any): ApolloQueryObservable { + public watchQuery(options: WatchQueryOptions): ApolloQueryObservable { return new ApolloQueryObservable(rxify(this.client.watchQuery)(options)); } - public query(options: any) { + public query(options: WatchQueryOptions): Promise { return this.client.query(options); } - public mutate(options: any) { + public mutate(options: MutateOptions): Promise { return this.client.mutate(options); } From 183e8e491ef535ddf973ad59831dfbed5856882f Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Wed, 2 Nov 2016 18:24:08 +0100 Subject: [PATCH 2/3] feat(Angular2Apollo): use FragmentDefinition --- src/Angular2Apollo.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Angular2Apollo.ts b/src/Angular2Apollo.ts index f624397dc..b96476840 100644 --- a/src/Angular2Apollo.ts +++ b/src/Angular2Apollo.ts @@ -2,6 +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 { ApolloQueryObservable } from './ApolloQueryObservable'; @@ -11,7 +12,7 @@ export interface MutateOptions { mutation: Document; variables?: Object; resultBehaviors?: MutationBehavior[]; - fragments?: any[]; + fragments?: FragmentDefinition[]; optimisticResponse?: Object; updateQueries?: MutationQueryReducersMap; refetchQueries?: string[]; From 532c6582922b62384cd1ef960b27e96c0358dffd Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Wed, 2 Nov 2016 18:39:25 +0100 Subject: [PATCH 3/3] docs(changelog): add recent changes --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9269533..1b8bfc507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### vNEXT +- Define types of options and results (of `watchQuery`, `query`, `mutate`) ([PR #145](https://github.com/apollostack/angular2-apollo/pull/145)) + ### v0.7.0 - Added support for **Ahead of Time** compilation ([PR #124](https://github.com/apollostack/angular2-apollo/pull/124))