startgg-helper-browser 1.1.2 → 1.1.3
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.
- package/main.js +20 -2
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -18,7 +18,23 @@ class GraphQLError extends Error {
|
|
|
18
18
|
* @param {{schema: {}, variables: {}}} request
|
|
19
19
|
*/
|
|
20
20
|
constructor(response, request, resBody){
|
|
21
|
-
|
|
21
|
+
let message = "";
|
|
22
|
+
if (resBody.message){
|
|
23
|
+
message = resBody.message + ` (error id ${resBody.errorId})\n`;
|
|
24
|
+
} else if (resBody.errors){
|
|
25
|
+
message = "Errors : \n";
|
|
26
|
+
for (let error of resBody.errors){
|
|
27
|
+
message += "- " + error.message + ` (error id ${error.errorId})\n`;
|
|
28
|
+
}
|
|
29
|
+
message += '\n';
|
|
30
|
+
}
|
|
31
|
+
super(
|
|
32
|
+
"Received code " + response.status + " \n " +
|
|
33
|
+
message +
|
|
34
|
+
"Original request : " + JSON.stringify(request)
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
//super("Received code " + response.status + " ; " + JSON.stringify(request));
|
|
22
38
|
this.name = "GraphQLError"
|
|
23
39
|
this.response = response;
|
|
24
40
|
this.resBody = resBody;
|
|
@@ -42,10 +58,12 @@ async function requestStartGG(schema, variables, token){
|
|
|
42
58
|
if (!json){
|
|
43
59
|
throw "Empty response"
|
|
44
60
|
}
|
|
45
|
-
if (json.
|
|
61
|
+
if (!json.data){
|
|
46
62
|
throw new GraphQLError(response, {schema, variables}, json);
|
|
47
63
|
}
|
|
64
|
+
|
|
48
65
|
return json.data;
|
|
66
|
+
|
|
49
67
|
}
|
|
50
68
|
|
|
51
69
|
export class SGGHelperClient {
|