@wenex/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
2
|
export type GraphqlException = {
|
|
3
|
-
|
|
3
|
+
message: string;
|
|
4
4
|
extensions: {
|
|
5
5
|
code: string;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
+
export type GraphqlResponse<T = any> = {
|
|
9
|
+
data: T | null;
|
|
10
|
+
errors?: GraphqlException[];
|
|
11
|
+
};
|
|
8
12
|
export type GraphqlRequest = Partial<{
|
|
9
13
|
query: string;
|
|
10
14
|
mutation: string;
|
|
11
15
|
variables: any;
|
|
12
16
|
}>;
|
|
13
|
-
export type GraphqlResponse<T = any> = {
|
|
14
|
-
data: T | null;
|
|
15
|
-
errors?: GraphqlException[];
|
|
16
|
-
};
|
|
17
17
|
export declare class GraphqlService {
|
|
18
18
|
protected readonly axios: AxiosInstance;
|
|
19
19
|
constructor(axios: AxiosInstance);
|
|
20
|
-
request<T>(data: GraphqlRequest, config?: AxiosRequestConfig): Promise<
|
|
20
|
+
request<T>(data: GraphqlRequest, config?: AxiosRequestConfig): Promise<T>;
|
|
21
21
|
}
|
|
@@ -18,10 +18,10 @@ class GraphqlService {
|
|
|
18
18
|
var _a;
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const { data: res } = yield this.axios.post('/graphql', data, config);
|
|
21
|
-
if ((_a = res
|
|
22
|
-
throw res;
|
|
21
|
+
if ((_a = res.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
22
|
+
throw res.errors;
|
|
23
23
|
else
|
|
24
|
-
return res;
|
|
24
|
+
return res.data;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.service.js","sourceRoot":"","sources":["../../src/common/classes/graphql.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAa,cAAc;IACzB,YAA+B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"graphql.service.js","sourceRoot":"","sources":["../../src/common/classes/graphql.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,MAAa,cAAc;IACzB,YAA+B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IAEjD,OAAO,CAAI,IAAoB,EAAE,MAA2B;;;YAChE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CACzC,UAAU,EACV,IAAI,EACJ,MAAM,CACP,CAAC;YAEF,IAAI,MAAA,GAAG,CAAC,MAAM,0CAAE,MAAM;gBAAE,MAAM,GAAG,CAAC,MAAM,CAAC;;gBACpC,OAAO,GAAG,CAAC,IAAK,CAAC;;KACvB;CACF;AAbD,wCAaC"}
|