@@ -12,10 +12,7 @@ In GraphQL, when an error occurs, the server must add an "error" entry in the re
12
12
{
13
13
"message" : " Name for character with ID 1002 could not be fetched." ,
14
14
"locations" : [ { "line" : 6 , "column" : 7 } ],
15
- "path" : [ " hero" , " heroFriends" , 1 , " name" ],
16
- "extensions" : {
17
- "category" : " Exception"
18
- }
15
+ "path" : [ " hero" , " heroFriends" , 1 , " name" ]
19
16
}
20
17
]
21
18
}
@@ -43,30 +40,6 @@ throw new GraphQLException("Not found", 404);
43
40
<div class = " alert alert--info" >GraphQL allows to have several errors for one request. If you have several
44
41
<code >GraphQLException</code > thrown for the same request, the HTTP status code used will be the highest one.</div >
45
42
46
- ## Customizing the category
47
-
48
- By default, GraphQLite adds a "category" entry in the "extensions section". You can customize the category with the
49
- 4th parameter of the constructor:
50
-
51
- ``` php
52
- throw new GraphQLException("Not found", 404, null, "NOT_FOUND");
53
- ```
54
-
55
- will generate:
56
-
57
- ``` json
58
- {
59
- "errors" : [
60
- {
61
- "message" : " Not found" ,
62
- "extensions" : {
63
- "category" : " NOT_FOUND"
64
- }
65
- }
66
- ]
67
- }
68
- ```
69
-
70
43
## Customizing the extensions section
71
44
72
45
You can customize the whole "extensions" section with the 5th parameter of the constructor:
@@ -83,7 +56,6 @@ will generate:
83
56
{
84
57
"message" : " Field required" ,
85
58
"extensions" : {
86
- "category" : " VALIDATION" ,
87
59
"field" : " name"
88
60
}
89
61
}
@@ -109,16 +81,6 @@ class ValidationException extends Exception implements GraphQLExceptionInterface
109
81
return true;
110
82
}
111
83
112
- /**
113
- * Returns string describing a category of the error.
114
- *
115
- * Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
116
- */
117
- public function getCategory(): string
118
- {
119
- return 'VALIDATION';
120
- }
121
-
122
84
/**
123
85
* Returns the "extensions" object attached to the GraphQL error.
124
86
*
0 commit comments