diff --git a/.travis.yml b/.travis.yml
index 6d06cce04..c0ef72ef4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,8 +24,6 @@ install:
- npm i
- npm install -g typings
- npm install -g coveralls
- # temporary fix
- - (cd node_modules/apollo-client && npm run compile)
script:
# remove unused node modules from cache
diff --git a/examples/hello-world/client/main.html b/examples/hello-world/client/main.html
index e8cfdf698..75cfd2c4a 100644
--- a/examples/hello-world/client/main.html
+++ b/examples/hello-world/client/main.html
@@ -6,8 +6,9 @@
Add new
List
+
- -
+
-
{{ user.firstName }} {{ user.lastName }}
diff --git a/examples/hello-world/client/main.ts b/examples/hello-world/client/main.ts
index 79da479f0..d54aab110 100644
--- a/examples/hello-world/client/main.ts
+++ b/examples/hello-world/client/main.ts
@@ -1,11 +1,11 @@
import {
bootstrap,
-} from "angular2/platform/browser";
+} from "@angular/platform-browser-dynamic";
import {
Component,
Injectable,
-} from "angular2/core";
+} from "@angular/core";
import {
Observable,
@@ -20,6 +20,8 @@ import ApolloClient, {
createNetworkInterface,
} from 'apollo-client';
+import gql from 'apollo-client/gql';
+
import {
graphQLResult
} from 'graphql';
@@ -39,7 +41,7 @@ const client = new ApolloClient({
queries(state: any) {
return {
users: {
- query: `
+ query: gql`
query getUsers($name: String) {
users(name: $name) {
firstName
@@ -60,7 +62,7 @@ const client = new ApolloClient({
mutations(state: any) {
return {
addUser: (firstName: string) => ({
- mutation: `
+ mutation: gql`
mutation addUser(
$firstName: String!
$lastName: String!
diff --git a/examples/hello-world/package.json b/examples/hello-world/package.json
index 031c9904a..16507f4aa 100644
--- a/examples/hello-world/package.json
+++ b/examples/hello-world/package.json
@@ -5,15 +5,20 @@
"start": "meteor run"
},
"dependencies": {
- "angular2": "^2.0.0-beta.15",
+ "@angular/core": "2.0.0-rc.1",
+ "@angular/common": "2.0.0-rc.1",
+ "@angular/compiler": "2.0.0-rc.1",
+ "@angular/platform-browser": "2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "2.0.0-rc.1",
"angular2-apollo": "file:../../",
- "apollo-client": "0.1.2",
+ "apollo-client": "0.3.12",
"casual-browserify": "^1.5.2",
"express": "^4.13.4",
"fs.extra": "^1.3.2",
"graphql": "^0.5.0",
"graphql-tools": "^0.3.8",
"http-proxy-middleware": "^0.14.0",
- "meteor-node-stubs": "~0.2.0"
+ "meteor-node-stubs": "~0.2.0",
+ "rxjs": "^5.0.0-beta.6"
}
}
diff --git a/package.json b/package.json
index 5e2317167..af29c6047 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,8 @@
"lint": "tslint -e src/*.ts && tslint test/*.ts ",
"build": "tsc",
"watch": "tsc -w",
- "clear": "rimraf build/* coverage/*"
+ "clear": "rimraf build/* coverage/*",
+ "prepublish": "npm run build"
},
"repository": {
"type": "git",
@@ -36,7 +37,7 @@
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
- "apollo-client": "0.1.2",
+ "apollo-client": "^0.3.0",
"es6-shim": "0.35.0",
"graphql": "^0.5.0",
"lodash": "^4.11.1",
diff --git a/src/apolloQueryPipe.ts b/src/apolloQueryPipe.ts
index 9b7629370..c20059fcf 100644
--- a/src/apolloQueryPipe.ts
+++ b/src/apolloQueryPipe.ts
@@ -1,14 +1,14 @@
///
-import {Pipe} from '@angular/core';
+import {
+ Pipe,
+} from '@angular/core';
@Pipe({
name: 'apolloQuery',
})
export class ApolloQueryPipe {
- public transform(obj, args) {
- const name = args[0] || '';
-
+ public transform(obj: any, name: string = '') {
if (obj && obj.data && name !== '' && obj.data[name]) {
return obj.data[name];
}
diff --git a/tests/apolloQueryPipe.ts b/tests/apolloQueryPipe.ts
index adef0e26a..be5aca95d 100644
--- a/tests/apolloQueryPipe.ts
+++ b/tests/apolloQueryPipe.ts
@@ -13,7 +13,7 @@ describe('ApolloQueryPipe', () => {
foo: 'bar',
},
};
- const result = pipe.transform(object, ['foo']);
+ const result = pipe.transform(object, 'foo');
expect(result).toEqual(object.data.foo);
});
diff --git a/typings.json b/typings.json
index 148e2e124..fbd117eae 100644
--- a/typings.json
+++ b/typings.json
@@ -4,7 +4,7 @@
"jasmine": "registry:dt/jasmine#2.2.0+20160412134438"
},
"dependencies": {
- "apollo-client": "file:node_modules/apollo-client/lib/src/index.d.ts",
+ "apollo-client": "file:node_modules/apollo-client/index.d.ts",
"lodash": "registry:npm/lodash#4.0.0+20160416211519"
}
}
diff --git a/typings/browser/definitions/apollo-client/index.d.ts b/typings/browser/definitions/apollo-client/index.d.ts
index 20a1637d7..36209f03b 100644
--- a/typings/browser/definitions/apollo-client/index.d.ts
+++ b/typings/browser/definitions/apollo-client/index.d.ts
@@ -1,5 +1,5 @@
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/middleware.d.ts
+// Source: node_modules/apollo-client/middleware.d.ts
declare module '~apollo-client/middleware' {
import { Request } from '~apollo-client/networkInterface';
export interface MiddlewareRequest {
@@ -22,7 +22,7 @@ export * from '~apollo-client/middleware';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/networkInterface.d.ts
+// Source: node_modules/apollo-client/networkInterface.d.ts
declare module '~apollo-client/networkInterface' {
import { GraphQLResult } from 'graphql';
import { MiddlewareInterface } from '~apollo-client/middleware';
@@ -32,20 +32,26 @@ export interface Request {
variables?: Object;
}
export interface NetworkInterface {
+ query(request: Request): Promise;
+}
+export interface HTTPNetworkInterface extends NetworkInterface {
_uri: string;
_opts: RequestInit;
_middlewares: MiddlewareInterface[];
- query(request: Request): Promise;
use(middlewares: MiddlewareInterface[]): any;
}
-export function createNetworkInterface(uri: string, opts?: RequestInit): NetworkInterface;
+export interface RequestAndOptions {
+ request: Request;
+ options: RequestInit;
+}
+export function createNetworkInterface(uri: string, opts?: RequestInit): HTTPNetworkInterface;
}
declare module 'apollo-client/networkInterface' {
export * from '~apollo-client/networkInterface';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/store.d.ts
+// Source: node_modules/apollo-client/data/store.d.ts
declare module '~apollo-client/data/store' {
import { ApolloAction } from '~apollo-client/actions';
import { QueryStore } from '~apollo-client/queries/store';
@@ -66,7 +72,7 @@ export * from '~apollo-client/data/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/queries/store.d.ts
+// Source: node_modules/apollo-client/queries/store.d.ts
declare module '~apollo-client/queries/store' {
import { ApolloAction } from '~apollo-client/actions';
import { SelectionSet, GraphQLError } from 'graphql';
@@ -98,7 +104,7 @@ export * from '~apollo-client/queries/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/mutations/store.d.ts
+// Source: node_modules/apollo-client/mutations/store.d.ts
declare module '~apollo-client/mutations/store' {
import { ApolloAction } from '~apollo-client/actions';
import { SelectionSet } from 'graphql';
@@ -124,26 +130,26 @@ export * from '~apollo-client/mutations/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/actions.d.ts
+// Source: node_modules/apollo-client/actions.d.ts
declare module '~apollo-client/actions' {
import { GraphQLResult } from 'graphql';
import { SelectionSetWithRoot } from '~apollo-client/queries/store';
export interface QueryResultAction {
- type: 'QUERY_RESULT';
+ type: 'APOLLO_QUERY_RESULT';
result: GraphQLResult;
queryId: string;
requestId: number;
}
export function isQueryResultAction(action: ApolloAction): action is QueryResultAction;
export interface QueryErrorAction {
- type: 'QUERY_ERROR';
+ type: 'APOLLO_QUERY_ERROR';
error: Error;
queryId: string;
requestId: number;
}
export function isQueryErrorAction(action: ApolloAction): action is QueryErrorAction;
export interface QueryInitAction {
- type: 'QUERY_INIT';
+ type: 'APOLLO_QUERY_INIT';
queryString: string;
query: SelectionSetWithRoot;
minimizedQueryString: string;
@@ -156,19 +162,19 @@ export interface QueryInitAction {
}
export function isQueryInitAction(action: ApolloAction): action is QueryInitAction;
export interface QueryResultClientAction {
- type: 'QUERY_RESULT_CLIENT';
+ type: 'APOLLO_QUERY_RESULT_CLIENT';
result: GraphQLResult;
complete: boolean;
queryId: string;
}
export function isQueryResultClientAction(action: ApolloAction): action is QueryResultClientAction;
export interface QueryStopAction {
- type: 'QUERY_STOP';
+ type: 'APOLLO_QUERY_STOP';
queryId: string;
}
export function isQueryStopAction(action: ApolloAction): action is QueryStopAction;
export interface MutationInitAction {
- type: 'MUTATION_INIT';
+ type: 'APOLLO_MUTATION_INIT';
mutationString: string;
mutation: SelectionSetWithRoot;
variables: Object;
@@ -176,7 +182,7 @@ export interface MutationInitAction {
}
export function isMutationInitAction(action: ApolloAction): action is MutationInitAction;
export interface MutationResultAction {
- type: 'MUTATION_RESULT';
+ type: 'APOLLO_MUTATION_RESULT';
result: GraphQLResult;
mutationId: string;
}
@@ -188,19 +194,7 @@ export * from '~apollo-client/actions';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/extensions.d.ts
-declare module '~apollo-client/data/extensions' {
-export type IdGetter = (value: Object) => string;
-export const getIdField: (data: {
- id: any;
-}) => any;
-}
-declare module 'apollo-client/data/extensions' {
-export * from '~apollo-client/data/extensions';
-}
-
-// Generated by typings
-// Source: node_modules/apollo-client/lib/src/store.d.ts
+// Source: node_modules/apollo-client/store.d.ts
declare module '~apollo-client/store' {
import { NormalizedCache } from '~apollo-client/data/store';
import { QueryStore } from '~apollo-client/queries/store';
@@ -217,8 +211,9 @@ export interface ApolloStore {
getState: () => any;
}
export function createApolloReducer(config: ApolloReducerConfig): Function;
-export function createApolloStore({reduxRootKey, config}?: {
+export function createApolloStore({reduxRootKey, initialState, config}?: {
reduxRootKey?: string;
+ initialState?: any;
config?: ApolloReducerConfig;
}): ApolloStore;
export interface ApolloReducerConfig {
@@ -230,7 +225,7 @@ export * from '~apollo-client/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/util/Observable.d.ts
+// Source: node_modules/apollo-client/util/Observable.d.ts
declare module '~apollo-client/util/Observable' {
export type CleanupFunction = () => void;
export type SubscriberFunction = (observer: Observer) => (Subscription | CleanupFunction);
@@ -253,49 +248,53 @@ export * from '~apollo-client/util/Observable';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/QueryManager.d.ts
+// Source: node_modules/apollo-client/QueryManager.d.ts
declare module '~apollo-client/QueryManager' {
import { NetworkInterface } from '~apollo-client/networkInterface';
import { ApolloStore } from '~apollo-client/store';
-import { GraphQLResult } from 'graphql';
-import { IdGetter } from '~apollo-client/data/extensions';
+import { QueryTransformer } from '~apollo-client/queries/queryTransform';
+import { GraphQLResult, Document } from 'graphql';
import { Observable, Observer, Subscription } from '~apollo-client/util/Observable';
export class ObservableQuery extends Observable {
subscribe(observer: Observer): QuerySubscription;
result(): Promise;
}
export interface QuerySubscription extends Subscription {
- refetch(): any;
+ refetch(variables?: any): Promise;
+ stopPolling(): void;
+ startPolling(pollInterval: number): void;
}
export interface WatchQueryOptions {
- query: string;
+ query: Document;
variables?: {
[key: string]: any;
};
forceFetch?: boolean;
returnPartialData?: boolean;
+ pollInterval?: number;
}
export class QueryManager {
private networkInterface;
private store;
private reduxRootKey;
- private dataIdFromObject;
+ private pollingTimer;
+ private queryTransformer;
private queryListeners;
private idCounter;
- constructor({networkInterface, store, reduxRootKey, dataIdFromObject}: {
+ constructor({networkInterface, store, reduxRootKey, queryTransformer}: {
networkInterface: NetworkInterface;
store: ApolloStore;
reduxRootKey: string;
- dataIdFromObject?: IdGetter;
+ queryTransformer?: QueryTransformer;
});
broadcastNewStore(store: any): void;
mutate({mutation, variables}: {
- mutation: string;
+ mutation: Document;
variables?: Object;
}): Promise;
watchQuery(options: WatchQueryOptions): ObservableQuery;
query(options: WatchQueryOptions): Promise;
- fetchQuery(queryId: string, options: WatchQueryOptions): void;
+ fetchQuery(queryId: string, options: WatchQueryOptions): Promise;
private getApolloState();
private startQuery(options, listener);
private stopQuery(queryId);
@@ -309,26 +308,27 @@ export * from '~apollo-client/QueryManager';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/readFromStore.d.ts
+// Source: node_modules/apollo-client/data/readFromStore.d.ts
declare module '~apollo-client/data/readFromStore' {
-import { SelectionSet } from 'graphql';
+import { SelectionSet, Document } from 'graphql';
import { NormalizedCache } from '~apollo-client/data/store';
export function readQueryFromStore({store, query, variables}: {
store: NormalizedCache;
- query: string;
+ query: Document;
variables?: Object;
}): Object;
export function readFragmentFromStore({store, fragment, rootId, variables}: {
store: NormalizedCache;
- fragment: string;
+ fragment: Document;
rootId: string;
variables?: Object;
}): Object;
-export function readSelectionSetFromStore({store, rootId, selectionSet, variables}: {
+export function readSelectionSetFromStore({store, rootId, selectionSet, variables, returnPartialData}: {
store: NormalizedCache;
rootId: string;
selectionSet: SelectionSet;
variables: Object;
+ returnPartialData?: boolean;
}): Object;
}
declare module 'apollo-client/data/readFromStore' {
@@ -336,27 +336,61 @@ export * from '~apollo-client/data/readFromStore';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/index.d.ts
+// Source: node_modules/apollo-client/data/extensions.d.ts
+declare module '~apollo-client/data/extensions' {
+export type IdGetter = (value: Object) => string;
+export const getIdField: (data: {
+ id: any;
+}) => any;
+}
+declare module 'apollo-client/data/extensions' {
+export * from '~apollo-client/data/extensions';
+}
+
+// Generated by typings
+// Source: node_modules/apollo-client/queries/queryTransform.d.ts
+declare module '~apollo-client/queries/queryTransform' {
+import { SelectionSet, OperationDefinition } from 'graphql';
+export type QueryTransformer = (queryPiece: SelectionSet) => void;
+export function addFieldToSelectionSet(fieldName: string, queryPiece: SelectionSet): SelectionSet;
+export function addTypenameToSelectionSet(queryPiece: SelectionSet): SelectionSet;
+export function addTypenameToQuery(queryDef: OperationDefinition): OperationDefinition;
+export function applyTransformerToOperation(queryDef: OperationDefinition, queryTransformer: QueryTransformer): OperationDefinition;
+}
+declare module 'apollo-client/queries/queryTransform' {
+export * from '~apollo-client/queries/queryTransform';
+}
+
+// Generated by typings
+// Source: node_modules/apollo-client/index.d.ts
declare module 'apollo-client' {
import { NetworkInterface, createNetworkInterface } from '~apollo-client/networkInterface';
-import { GraphQLResult } from 'graphql';
-import { createApolloStore, ApolloStore, createApolloReducer } from '~apollo-client/store';
+import { GraphQLResult, Document } from 'graphql';
+import { createApolloStore, ApolloStore, createApolloReducer, ApolloReducerConfig } from '~apollo-client/store';
import { QueryManager, WatchQueryOptions, ObservableQuery } from '~apollo-client/QueryManager';
import { readQueryFromStore, readFragmentFromStore } from '~apollo-client/data/readFromStore';
+import { IdGetter } from '~apollo-client/data/extensions';
+import { QueryTransformer } from '~apollo-client/queries/queryTransform';
export { createNetworkInterface, createApolloStore, createApolloReducer, readQueryFromStore, readFragmentFromStore };
export default class ApolloClient {
networkInterface: NetworkInterface;
store: ApolloStore;
reduxRootKey: string;
+ initialState: any;
queryManager: QueryManager;
- constructor({networkInterface, reduxRootKey}?: {
+ reducerConfig: ApolloReducerConfig;
+ queryTransformer: QueryTransformer;
+ constructor({networkInterface, reduxRootKey, initialState, dataIdFromObject, queryTransformer}?: {
networkInterface?: NetworkInterface;
reduxRootKey?: string;
+ initialState?: any;
+ dataIdFromObject?: IdGetter;
+ queryTransformer?: QueryTransformer;
});
watchQuery: (options: WatchQueryOptions) => ObservableQuery;
query: (options: WatchQueryOptions) => Promise;
mutate: (options: {
- mutation: string;
+ mutation: Document;
variables?: Object;
}) => Promise;
reducer(): Function;
diff --git a/typings/main/definitions/apollo-client/index.d.ts b/typings/main/definitions/apollo-client/index.d.ts
index 20a1637d7..36209f03b 100644
--- a/typings/main/definitions/apollo-client/index.d.ts
+++ b/typings/main/definitions/apollo-client/index.d.ts
@@ -1,5 +1,5 @@
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/middleware.d.ts
+// Source: node_modules/apollo-client/middleware.d.ts
declare module '~apollo-client/middleware' {
import { Request } from '~apollo-client/networkInterface';
export interface MiddlewareRequest {
@@ -22,7 +22,7 @@ export * from '~apollo-client/middleware';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/networkInterface.d.ts
+// Source: node_modules/apollo-client/networkInterface.d.ts
declare module '~apollo-client/networkInterface' {
import { GraphQLResult } from 'graphql';
import { MiddlewareInterface } from '~apollo-client/middleware';
@@ -32,20 +32,26 @@ export interface Request {
variables?: Object;
}
export interface NetworkInterface {
+ query(request: Request): Promise;
+}
+export interface HTTPNetworkInterface extends NetworkInterface {
_uri: string;
_opts: RequestInit;
_middlewares: MiddlewareInterface[];
- query(request: Request): Promise;
use(middlewares: MiddlewareInterface[]): any;
}
-export function createNetworkInterface(uri: string, opts?: RequestInit): NetworkInterface;
+export interface RequestAndOptions {
+ request: Request;
+ options: RequestInit;
+}
+export function createNetworkInterface(uri: string, opts?: RequestInit): HTTPNetworkInterface;
}
declare module 'apollo-client/networkInterface' {
export * from '~apollo-client/networkInterface';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/store.d.ts
+// Source: node_modules/apollo-client/data/store.d.ts
declare module '~apollo-client/data/store' {
import { ApolloAction } from '~apollo-client/actions';
import { QueryStore } from '~apollo-client/queries/store';
@@ -66,7 +72,7 @@ export * from '~apollo-client/data/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/queries/store.d.ts
+// Source: node_modules/apollo-client/queries/store.d.ts
declare module '~apollo-client/queries/store' {
import { ApolloAction } from '~apollo-client/actions';
import { SelectionSet, GraphQLError } from 'graphql';
@@ -98,7 +104,7 @@ export * from '~apollo-client/queries/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/mutations/store.d.ts
+// Source: node_modules/apollo-client/mutations/store.d.ts
declare module '~apollo-client/mutations/store' {
import { ApolloAction } from '~apollo-client/actions';
import { SelectionSet } from 'graphql';
@@ -124,26 +130,26 @@ export * from '~apollo-client/mutations/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/actions.d.ts
+// Source: node_modules/apollo-client/actions.d.ts
declare module '~apollo-client/actions' {
import { GraphQLResult } from 'graphql';
import { SelectionSetWithRoot } from '~apollo-client/queries/store';
export interface QueryResultAction {
- type: 'QUERY_RESULT';
+ type: 'APOLLO_QUERY_RESULT';
result: GraphQLResult;
queryId: string;
requestId: number;
}
export function isQueryResultAction(action: ApolloAction): action is QueryResultAction;
export interface QueryErrorAction {
- type: 'QUERY_ERROR';
+ type: 'APOLLO_QUERY_ERROR';
error: Error;
queryId: string;
requestId: number;
}
export function isQueryErrorAction(action: ApolloAction): action is QueryErrorAction;
export interface QueryInitAction {
- type: 'QUERY_INIT';
+ type: 'APOLLO_QUERY_INIT';
queryString: string;
query: SelectionSetWithRoot;
minimizedQueryString: string;
@@ -156,19 +162,19 @@ export interface QueryInitAction {
}
export function isQueryInitAction(action: ApolloAction): action is QueryInitAction;
export interface QueryResultClientAction {
- type: 'QUERY_RESULT_CLIENT';
+ type: 'APOLLO_QUERY_RESULT_CLIENT';
result: GraphQLResult;
complete: boolean;
queryId: string;
}
export function isQueryResultClientAction(action: ApolloAction): action is QueryResultClientAction;
export interface QueryStopAction {
- type: 'QUERY_STOP';
+ type: 'APOLLO_QUERY_STOP';
queryId: string;
}
export function isQueryStopAction(action: ApolloAction): action is QueryStopAction;
export interface MutationInitAction {
- type: 'MUTATION_INIT';
+ type: 'APOLLO_MUTATION_INIT';
mutationString: string;
mutation: SelectionSetWithRoot;
variables: Object;
@@ -176,7 +182,7 @@ export interface MutationInitAction {
}
export function isMutationInitAction(action: ApolloAction): action is MutationInitAction;
export interface MutationResultAction {
- type: 'MUTATION_RESULT';
+ type: 'APOLLO_MUTATION_RESULT';
result: GraphQLResult;
mutationId: string;
}
@@ -188,19 +194,7 @@ export * from '~apollo-client/actions';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/extensions.d.ts
-declare module '~apollo-client/data/extensions' {
-export type IdGetter = (value: Object) => string;
-export const getIdField: (data: {
- id: any;
-}) => any;
-}
-declare module 'apollo-client/data/extensions' {
-export * from '~apollo-client/data/extensions';
-}
-
-// Generated by typings
-// Source: node_modules/apollo-client/lib/src/store.d.ts
+// Source: node_modules/apollo-client/store.d.ts
declare module '~apollo-client/store' {
import { NormalizedCache } from '~apollo-client/data/store';
import { QueryStore } from '~apollo-client/queries/store';
@@ -217,8 +211,9 @@ export interface ApolloStore {
getState: () => any;
}
export function createApolloReducer(config: ApolloReducerConfig): Function;
-export function createApolloStore({reduxRootKey, config}?: {
+export function createApolloStore({reduxRootKey, initialState, config}?: {
reduxRootKey?: string;
+ initialState?: any;
config?: ApolloReducerConfig;
}): ApolloStore;
export interface ApolloReducerConfig {
@@ -230,7 +225,7 @@ export * from '~apollo-client/store';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/util/Observable.d.ts
+// Source: node_modules/apollo-client/util/Observable.d.ts
declare module '~apollo-client/util/Observable' {
export type CleanupFunction = () => void;
export type SubscriberFunction = (observer: Observer) => (Subscription | CleanupFunction);
@@ -253,49 +248,53 @@ export * from '~apollo-client/util/Observable';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/QueryManager.d.ts
+// Source: node_modules/apollo-client/QueryManager.d.ts
declare module '~apollo-client/QueryManager' {
import { NetworkInterface } from '~apollo-client/networkInterface';
import { ApolloStore } from '~apollo-client/store';
-import { GraphQLResult } from 'graphql';
-import { IdGetter } from '~apollo-client/data/extensions';
+import { QueryTransformer } from '~apollo-client/queries/queryTransform';
+import { GraphQLResult, Document } from 'graphql';
import { Observable, Observer, Subscription } from '~apollo-client/util/Observable';
export class ObservableQuery extends Observable {
subscribe(observer: Observer): QuerySubscription;
result(): Promise;
}
export interface QuerySubscription extends Subscription {
- refetch(): any;
+ refetch(variables?: any): Promise;
+ stopPolling(): void;
+ startPolling(pollInterval: number): void;
}
export interface WatchQueryOptions {
- query: string;
+ query: Document;
variables?: {
[key: string]: any;
};
forceFetch?: boolean;
returnPartialData?: boolean;
+ pollInterval?: number;
}
export class QueryManager {
private networkInterface;
private store;
private reduxRootKey;
- private dataIdFromObject;
+ private pollingTimer;
+ private queryTransformer;
private queryListeners;
private idCounter;
- constructor({networkInterface, store, reduxRootKey, dataIdFromObject}: {
+ constructor({networkInterface, store, reduxRootKey, queryTransformer}: {
networkInterface: NetworkInterface;
store: ApolloStore;
reduxRootKey: string;
- dataIdFromObject?: IdGetter;
+ queryTransformer?: QueryTransformer;
});
broadcastNewStore(store: any): void;
mutate({mutation, variables}: {
- mutation: string;
+ mutation: Document;
variables?: Object;
}): Promise;
watchQuery(options: WatchQueryOptions): ObservableQuery;
query(options: WatchQueryOptions): Promise;
- fetchQuery(queryId: string, options: WatchQueryOptions): void;
+ fetchQuery(queryId: string, options: WatchQueryOptions): Promise;
private getApolloState();
private startQuery(options, listener);
private stopQuery(queryId);
@@ -309,26 +308,27 @@ export * from '~apollo-client/QueryManager';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/data/readFromStore.d.ts
+// Source: node_modules/apollo-client/data/readFromStore.d.ts
declare module '~apollo-client/data/readFromStore' {
-import { SelectionSet } from 'graphql';
+import { SelectionSet, Document } from 'graphql';
import { NormalizedCache } from '~apollo-client/data/store';
export function readQueryFromStore({store, query, variables}: {
store: NormalizedCache;
- query: string;
+ query: Document;
variables?: Object;
}): Object;
export function readFragmentFromStore({store, fragment, rootId, variables}: {
store: NormalizedCache;
- fragment: string;
+ fragment: Document;
rootId: string;
variables?: Object;
}): Object;
-export function readSelectionSetFromStore({store, rootId, selectionSet, variables}: {
+export function readSelectionSetFromStore({store, rootId, selectionSet, variables, returnPartialData}: {
store: NormalizedCache;
rootId: string;
selectionSet: SelectionSet;
variables: Object;
+ returnPartialData?: boolean;
}): Object;
}
declare module 'apollo-client/data/readFromStore' {
@@ -336,27 +336,61 @@ export * from '~apollo-client/data/readFromStore';
}
// Generated by typings
-// Source: node_modules/apollo-client/lib/src/index.d.ts
+// Source: node_modules/apollo-client/data/extensions.d.ts
+declare module '~apollo-client/data/extensions' {
+export type IdGetter = (value: Object) => string;
+export const getIdField: (data: {
+ id: any;
+}) => any;
+}
+declare module 'apollo-client/data/extensions' {
+export * from '~apollo-client/data/extensions';
+}
+
+// Generated by typings
+// Source: node_modules/apollo-client/queries/queryTransform.d.ts
+declare module '~apollo-client/queries/queryTransform' {
+import { SelectionSet, OperationDefinition } from 'graphql';
+export type QueryTransformer = (queryPiece: SelectionSet) => void;
+export function addFieldToSelectionSet(fieldName: string, queryPiece: SelectionSet): SelectionSet;
+export function addTypenameToSelectionSet(queryPiece: SelectionSet): SelectionSet;
+export function addTypenameToQuery(queryDef: OperationDefinition): OperationDefinition;
+export function applyTransformerToOperation(queryDef: OperationDefinition, queryTransformer: QueryTransformer): OperationDefinition;
+}
+declare module 'apollo-client/queries/queryTransform' {
+export * from '~apollo-client/queries/queryTransform';
+}
+
+// Generated by typings
+// Source: node_modules/apollo-client/index.d.ts
declare module 'apollo-client' {
import { NetworkInterface, createNetworkInterface } from '~apollo-client/networkInterface';
-import { GraphQLResult } from 'graphql';
-import { createApolloStore, ApolloStore, createApolloReducer } from '~apollo-client/store';
+import { GraphQLResult, Document } from 'graphql';
+import { createApolloStore, ApolloStore, createApolloReducer, ApolloReducerConfig } from '~apollo-client/store';
import { QueryManager, WatchQueryOptions, ObservableQuery } from '~apollo-client/QueryManager';
import { readQueryFromStore, readFragmentFromStore } from '~apollo-client/data/readFromStore';
+import { IdGetter } from '~apollo-client/data/extensions';
+import { QueryTransformer } from '~apollo-client/queries/queryTransform';
export { createNetworkInterface, createApolloStore, createApolloReducer, readQueryFromStore, readFragmentFromStore };
export default class ApolloClient {
networkInterface: NetworkInterface;
store: ApolloStore;
reduxRootKey: string;
+ initialState: any;
queryManager: QueryManager;
- constructor({networkInterface, reduxRootKey}?: {
+ reducerConfig: ApolloReducerConfig;
+ queryTransformer: QueryTransformer;
+ constructor({networkInterface, reduxRootKey, initialState, dataIdFromObject, queryTransformer}?: {
networkInterface?: NetworkInterface;
reduxRootKey?: string;
+ initialState?: any;
+ dataIdFromObject?: IdGetter;
+ queryTransformer?: QueryTransformer;
});
watchQuery: (options: WatchQueryOptions) => ObservableQuery;
query: (options: WatchQueryOptions) => Promise;
mutate: (options: {
- mutation: string;
+ mutation: Document;
variables?: Object;
}) => Promise;
reducer(): Function;