@@ -12,10 +12,7 @@ In GraphQL, when an error occurs, the server must add an "error" entry in the re
1212 {
1313 "message" : " Name for character with ID 1002 could not be fetched." ,
1414 "locations" : [ { "line" : 6 , "column" : 7 } ],
15- "path" : [ " hero" , " heroFriends" , 1 , " name" ],
16- "extensions" : {
17- "category" : " Exception"
18- }
15+ "path" : [ " hero" , " heroFriends" , 1 , " name" ]
1916 }
2017 ]
2118}
@@ -43,30 +40,6 @@ throw new GraphQLException("Not found", 404);
4340<div class = " alert alert--info" >GraphQL allows to have several errors for one request. If you have several
4441<code >GraphQLException</code > thrown for the same request, the HTTP status code used will be the highest one.</div >
4542
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-
7043## Customizing the extensions section
7144
7245You can customize the whole "extensions" section with the 5th parameter of the constructor:
@@ -83,7 +56,6 @@ will generate:
8356 {
8457 "message" : " Field required" ,
8558 "extensions" : {
86- "category" : " VALIDATION" ,
8759 "field" : " name"
8860 }
8961 }
@@ -109,16 +81,6 @@ class ValidationException extends Exception implements GraphQLExceptionInterface
10981 return true;
11082 }
11183
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-
12284 /**
12385 * Returns the "extensions" object attached to the GraphQL error.
12486 *
0 commit comments