The interface describing graphql errors NOTE: This class implements java.io.Serializable and hence it can be serialised and placed into a distributed cache. However we are not aiming to provide long term compatibility and do not intend for you to place this serialised data into permanen
| 22 | * @see <a href="https://spec.graphql.org/October2021/#sec-Errors">GraphQL Spec - 7.1.2 Errors</a> |
| 23 | */ |
| 24 | @PublicApi |
| 25 | @NullMarked |
| 26 | public interface GraphQLError extends Serializable { |
| 27 | |
| 28 | /** |
| 29 | * @return a description of the error intended for the developer as a guide to understand and correct the error |
| 30 | * |
| 31 | * Non-nullable from the spec: |
| 32 | * Every error must contain an entry with the key "message" with a string description of the error intended for |
| 33 | * the developer as a guide to understand and correct the error. |
| 34 | */ |
| 35 | String getMessage(); |
| 36 | |
| 37 | /** |
| 38 | * @return the location(s) within the GraphQL document at which the error occurred. Each {@link SourceLocation} |
| 39 | * describes the beginning of an associated syntax element |
| 40 | */ |
| 41 | @Nullable List<SourceLocation> getLocations(); |
| 42 | |
| 43 | /** |
| 44 | * @return an object classifying this error |
| 45 | */ |
| 46 | ErrorClassification getErrorType(); |
| 47 | |
| 48 | /** |
| 49 | * The graphql spec says that the (optional) path field of any error must be |
| 50 | * a list of path entries starting at the root of the response |
| 51 | * and ending with the field associated with the error |
| 52 | * <a href="https://spec.graphql.org/draft/#sec-Errors.Error-Result-Format">...</a> |
| 53 | * |
| 54 | * @return the path in list format |
| 55 | */ |
| 56 | default @Nullable List<Object> getPath() { |
| 57 | return null; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * The graphql specification says that result of a call should be a map that follows certain rules on what items |
| 62 | * should be present. Certain JSON serializers may or may interpret the error to spec, so this method |
| 63 | * is provided to produce a map that strictly follows the specification. |
| 64 | * <p> |
| 65 | * See : <a href="https://spec.graphql.org/October2021/#sec-Errors">GraphQL Spec - 7.1.2 Errors</a> |
| 66 | * |
| 67 | * @return a map of the error that strictly follows the specification |
| 68 | */ |
| 69 | default Map<String, Object> toSpecification() { |
| 70 | return GraphqlErrorHelper.toSpecification(this); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return a map of error extensions or null if there are none |
| 75 | */ |
| 76 | default @Nullable Map<String, Object> getExtensions() { |
| 77 | return null; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * This can be called to turn a specification error map into {@link GraphQLError} |
no outgoing calls
no test coverage detected
searching dependent graphs…