MCPcopy Index your code
hub / github.com/graphql-java/graphql-java / GraphQLError

Interface GraphQLError

src/main/java/graphql/GraphQLError.java:24–173  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

22 * @see <a href="https://spec.graphql.org/October2021/#sec-Errors">GraphQL Spec - 7.1.2 Errors</a>
23 */
24@PublicApi
25@NullMarked
26public 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}

Callers 36

printLastErrorMethod · 0.95
equalsMethod · 0.95
equalsMethod · 0.95
mainMethod · 0.65
SpecialErrorMethod · 0.65
toSpecificationMethod · 0.65
hashCodeMethod · 0.65
mkMessageMethod · 0.65
equalsMethod · 0.95
equalsMethod · 0.95
SpecialErrorMethod · 0.65
toSpecificationMethod · 0.65

Implementers 15

CustomRuntimeExceptionsrc/test/groovy/readme/ExecutionExampl
GraphqlErrorExceptionsrc/main/java/graphql/GraphqlErrorExce
UnresolvedTypeErrorsrc/main/java/graphql/UnresolvedTypeEr
ExceptionWhileDataFetchingsrc/main/java/graphql/ExceptionWhileDa
InvalidSyntaxErrorsrc/main/java/graphql/InvalidSyntaxErr
TypeMismatchErrorsrc/main/java/graphql/TypeMismatchErro
GraphqlErrorImplsrc/main/java/graphql/GraphqlErrorBuil
SerializationErrorsrc/main/java/graphql/SerializationErr
ValidationErrorsrc/main/java/graphql/validation/Valid
IntrospectionDisabledErrorsrc/main/java/graphql/introspection/In
BadFaithIntrospectionErrorsrc/main/java/graphql/introspection/Go
BaseErrorsrc/main/java/graphql/schema/idl/error

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…