Skip to content

Commit

Permalink
fix(ts): renew typescript declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
gucheen committed Sep 1, 2018
1 parent d54fbd8 commit 80286f8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "GraphQL query client with Fetch",
"main": "index.js",
"module": "lib/fetchql.es.js",
"types": "src/index.d.ts",
"types": "src/fetchql.d.ts",
"scripts": {
"test": "NODE_ENV=test istanbul cover _mocha -- ./test/test",
"compile": "run-p compile:es compile:cjs",
Expand Down
56 changes: 56 additions & 0 deletions src/fetchql.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Type definitions for FetchQL
// Project: FetchQL
// Definitions by: gucheen https://github.com/gucheen/

export default FetchQL;

declare class FetchQL {
constructor(options: FetchQLOptions);

private interceptors: FetchQLInterceptor[];

private url: string;

private requestObject: Object;

private EnumMap: Object;

addInterceptors(interceptors: FetchQLInterceptor | FetchQLInterceptor[]): Function;

clearInterceptors(): void;

query(options: FetchQLQuery): Promise<{data, errors}>;

getEnumTypes(enums: string[]): Promise<{data, errors}>;

setUrl(): void;

getUrl(): string;
}

export interface FetchQLInterceptor {
request: (url: string, config) => { url: string, config };
reueqstError: (error) => Promise<{errors}>;
response: (response) => Object;
responseError: (error) => Promise<{errors}>;
}

export interface FetchQLOptions {
url: string;
interceptors?: FetchQLInterceptor | FetchQLInterceptor[];
headers?: Object;
onStart?: (queueLength: number) => void;
onEnd?: (queueLength: number) => void;
omitEmptyVariables?: boolean;
requestOptions?: Object;
}

export interface FetchQLQuery {
operationName: string;
query: string;
variables?: Object;
opts?: {
omitEmptyVariables: boolean;
};
requestOptions?: Object;
}
56 changes: 0 additions & 56 deletions src/index.d.ts

This file was deleted.

12 changes: 12 additions & 0 deletions test/ts-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FetchQL from '../'

const ql = new FetchQL({
url: '',
})

ql.query({
operationName: '',
query: '',
})
.then(() => {})
.catch(() => {});

0 comments on commit 80286f8

Please sign in to comment.