Skip to content

Commit 361b9fe

Browse files
committed
Update error codes, refactor to separate file
1 parent fad5f69 commit 361b9fe

File tree

5 files changed

+48
-75
lines changed

5 files changed

+48
-75
lines changed

.eslintrc

Lines changed: 0 additions & 46 deletions
This file was deleted.

index.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
// DB Flags
2-
// Database error due to violation of duplicate constraint
3-
exports.OBJECT_DUPLICATE = 'OBJECT_DUPLICATE';
4-
// Object matching query does not exist
5-
exports.OBJECT_NOT_FOUND = 'OBJECT_NOT_FOUND';
1+
exports.codes = require("./lib/codes");
62

7-
// Token Flags
8-
// Expiration time is passed
9-
exports.TOKEN_EXPIRED = 'TOKEN_EXPIRED';
10-
// Token does not contain expected parts after decrypting
11-
exports.TOKEN_MALFORMED = 'TOKEN_MALFORMED';
12-
13-
// Permissions Flags
14-
// User has insufficient permissions for the desired action
15-
exports.ACCESS_DENIED = 'ACCESS_DENIED';
16-
// Failed to authorize the user
17-
exports.UNAUTHORIZED = 'UNAUTHORIZED';
18-
19-
// Query Flags
20-
// Layers of query exceed maximum allowed limit
21-
exports.QUERY_DEPTH_EXCEEDED = 'QUERY_DEPTH_EXCEEDED';
22-
// Calculated complexity exceeds the maximum allowed limit
23-
exports.QUERY_COMPLEXITY_EXCEEDED = 'QUERY_COMPLEXITY_EXCEEDED';
24-
// At least one layer contains nodes exceeding the maximum allowed limit
25-
exports.QUERY_BREADTH_EXCEEDED = 'QUERY_BREADTH_EXCEEDED';
26-
27-
// Mystery Flags
28-
// New phone, who dis?
29-
exports.UNKNOWN_ERROR = 'UKNOWN_ERROR';
3+
exports.isValidCode = code => Object.keys(exports.codes).includes(code);

lib/codes.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// DB Flags
2+
// Database error due to violation of duplicate constraint
3+
exports.OBJECT_DUPLICATE = "OBJECT_DUPLICATE";
4+
// Object matching query does not exist
5+
exports.OBJECT_NOT_FOUND = "OBJECT_NOT_FOUND";
6+
7+
// Token Flags
8+
// Expiration time is passed
9+
exports.TOKEN_EXPIRED = "TOKEN_EXPIRED";
10+
// Token does not contain expected parts after decrypting
11+
exports.TOKEN_MALFORMED = "TOKEN_MALFORMED";
12+
13+
// Permissions Flags
14+
// User has insufficient permissions for the desired action
15+
exports.ACCESS_DENIED = "ACCESS_DENIED";
16+
// User input an invalid email or password
17+
exports.INVALID_CREDENTIALS = "INVALID_CREDENTIALS";
18+
19+
// Query Flags
20+
// Layers of query exceed maximum allowed limit
21+
exports.QUERY_DEPTH_EXCEEDED = "QUERY_DEPTH_EXCEEDED";
22+
// Calculated complexity exceeds the maximum allowed limit
23+
exports.QUERY_COMPLEXITY_EXCEEDED = "QUERY_COMPLEXITY_EXCEEDED";
24+
// At least one layer contains nodes exceeding the maximum allowed limit
25+
exports.QUERY_BREADTH_EXCEEDED = "QUERY_BREADTH_EXCEEDED";
26+
27+
// Mystery Flags
28+
// New phone, who dis?
29+
exports.UNKNOWN_ERROR = "UKNOWN_ERROR";

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adgorithmics/graphql-errors",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Response erorr codes for graphql.",
55
"main": "index.js",
66
"scripts": {
@@ -20,6 +20,7 @@
2020
"homepage": "https://github.com/adgorithmics-inc/graphql-errors#readme",
2121
"dependencies": {},
2222
"devDependencies": {
23+
"@adgorithmics/eslint-config-base": "^1.3.0",
2324
"eslint": "6.1.0"
2425
}
2526
}

0 commit comments

Comments
 (0)