Skip to content

Commit 0aef38d

Browse files
committed
request: user-friendly error rather than error json (#122)
1 parent 9ad8b12 commit 0aef38d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/request.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,13 @@ class Request {
4444
variables: variables
4545
}
4646
};
47-
// console.log(options);
47+
4848
const result = await rp(options);
4949
if (result.errors) {
50-
const err = new Error('GraphQL request Error');
50+
const { type, message } = result.errors[0];
51+
const err = new Error(`[${type}] GraphQL request Error: ${message}`);
5152
err.data = {
52-
// query: query,
53-
variables: variables,
54-
errors: result.errors
53+
variables
5554
};
5655
throw err;
5756
}

0 commit comments

Comments
 (0)