-
Notifications
You must be signed in to change notification settings - Fork 61
/
types.d.ts
38 lines (38 loc) · 1.31 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
declare namespace Lokka {
export type QL = string;
export interface ITransport {
send(rawQuery: string, variables: { [index: string]: any }, operationName: string);
}
export interface IConfig {
transport: ITransport;
}
export interface IVars { [index: string]: any }
export type IFragment = string;
export interface IWatchHandler<T> {
(err, payload: T): any;
}
export interface IStop {
(): void;
}
export interface ICacheConfig {
cacheExpirationTimeout?: number;
}
export interface ICache {
getItemPayload<T>(query: QL, vars?: IVars): T;
setItemPayload<T>(query: QL, vars: IVars, payload: T): void;
fireError(query: QL, vars: IVars, error): void;
removeItem(query: QL, vars?: IVars): void;
getItem<T>(query: QL, vars?: IVars): T;
}
export class Lokka {
constructor(config: IConfig);
query<T>(query: QL, vars?: IVars): Promise<T>;
mutate<T>(query: QL, vars?: IVars): Promise<T>;
watchQuery<T>(query: QL, handler?: IWatchHandler<T>): IStop;
watchQuery<T>(query: QL, vars?: IVars, handler?: IWatchHandler<T>): IStop;
createFragment(fragment: QL): IFragment;
refetchQuery(query: QL, vars?: IVars): void;
cache: ICache;
}
}
export = Lokka