From a7c1dca1895189589457000ffbc1b6a1b41ccf47 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Sat, 16 Jul 2016 12:22:38 +0200 Subject: [PATCH] feat(Apollo): ApolloQuery interface --- CHANGELOG.md | 1 + examples/hello-world/client/main.ts | 3 ++- src/apolloDecorator.ts | 13 +++++++++++++ src/index.ts | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 112270ffe..3a85639a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Passing all the options of mutation in `Apollo` decorator [PR #39](https://github.com/apollostack/angular2-apollo/pull/39) - Added support for `apollo-client` breaking change that moves methods to query's observable ([PR #40](https://github.com/apollostack/angular2-apollo/pull/40)) - Replaced `lodash` with subpackages, removed `graphql-tag` from dependencies, moved `apollo-client` and `@angular/core` to peerDependecies ([PR #44](https://github.com/apollostack/angular2-apollo/pull/44)) +- Added `ApolloQuery` interface ([PR #45](https://github.com/apollostack/angular2-apollo/pull/45)) ### v0.3.0 diff --git a/examples/hello-world/client/main.ts b/examples/hello-world/client/main.ts index c2c876799..c94fd4ec7 100644 --- a/examples/hello-world/client/main.ts +++ b/examples/hello-world/client/main.ts @@ -13,6 +13,7 @@ import { import { Apollo, + ApolloQuery, } from 'angular2-apollo'; import ApolloClient, { @@ -88,7 +89,7 @@ const client = new ApolloClient({ }, }) class Main { - public data: any; + public data: ApolloQuery; public firstName: string; public lastName: string; public nameFilter: string; diff --git a/src/apolloDecorator.ts b/src/apolloDecorator.ts index 2de0b0804..ffa44936d 100644 --- a/src/apolloDecorator.ts +++ b/src/apolloDecorator.ts @@ -2,10 +2,23 @@ import ApolloClient, { ApolloQueryResult, } from 'apollo-client'; +import { + ApolloError, +} from 'apollo-client/errors'; + import isEqual = require('lodash.isequal'); import forIn = require('lodash.forin'); import assign = require('lodash.assign'); +export interface ApolloQuery { + errors: ApolloError; + loading: boolean; + refetch: (variables?: any) => Promise; + stopPolling: () => void; + startPolling: (pollInterval: number) => void; + unsubscribe: () => void; +} + export interface ApolloOptions { client: ApolloClient; queries?: (component?: any) => any; diff --git a/src/index.ts b/src/index.ts index cf9f14fba..a8ccd1d80 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { import { Apollo, + ApolloQuery, } from './apolloDecorator'; import { @@ -17,6 +18,7 @@ export const APOLLO_PROVIDERS: any[] = [ export { Apollo, + ApolloQuery, ApolloQueryPipe, Angular2Apollo, defaultApolloClient