forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphQLError.java
More file actions
62 lines (50 loc) · 1.79 KB
/
GraphQLError.java
File metadata and controls
62 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package graphql;
import graphql.language.SourceLocation;
import java.util.List;
import java.util.Map;
/**
* @see <a href="https://facebook.github.io/graphql/#sec-Errors">GraphQL Spec - 7.2.2 Errors</a>
*/
@PublicApi
public interface GraphQLError {
/**
* @return a description of the error intended for the developer as a guide to understand and correct the error
*/
String getMessage();
/**
* @return the location(s) within the GraphQL document at which the error occurred. Each {@link SourceLocation}
* describes the beginning of an associated syntax element
*/
List<SourceLocation> getLocations();
/**
* @return an enum classifying this error
*/
ErrorType getErrorType();
/**
* The graphql spec says that the (optional) path field of any error should be a list
* of path entries - http://facebook.github.io/graphql/#sec-Errors
*
* @return the path in list format
*/
default List<Object> getPath() {
return null;
}
/**
* The graphql specification says that result of a call should be a map that follows certain rules on what items
* should be present. Certain JSON serializers may or may interpret the error to spec, so this method
* is provided to produce a map that strictly follows the specification.
*
* See : <a href="http://facebook.github.io/graphql/#sec-Errors">http://facebook.github.io/graphql/#sec-Errors</a>
*
* @return a map of the error that strictly follows the specification
*/
default Map<String, Object> toSpecification() {
return GraphqlErrorHelper.toSpecification(this);
}
/**
* @return a map of error extensions or null if there are none
*/
default Map<String, Object> getExtensions() {
return null;
}
}