Skip to content

Commit c78124c

Browse files
committed
Change GraphQL error message to be non-nullable
1 parent f8920d8 commit c78124c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/graphql/GraphQLError.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ public interface GraphQLError extends Serializable {
2727

2828
/**
2929
* @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.
3034
*/
31-
@Nullable String getMessage();
35+
String getMessage();
3236

3337
/**
3438
* @return the location(s) within the GraphQL document at which the error occurred. Each {@link SourceLocation}

src/main/java/graphql/validation/ValidationError.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class ValidationError implements GraphQLError {
2323

2424
private final List<SourceLocation> locations = new ArrayList<>();
25-
private final @Nullable String description;
25+
private final String description;
2626
private final @Nullable ValidationErrorClassification validationErrorType;
2727
private final List<String> queryPath = new ArrayList<>();
2828
private final ImmutableMap<String, Object> extensions;
@@ -46,11 +46,11 @@ private ValidationError(Builder builder) {
4646
}
4747

4848
@Override
49-
public @Nullable String getMessage() {
49+
public String getMessage() {
5050
return description;
5151
}
5252

53-
public @Nullable String getDescription() {
53+
public String getDescription() {
5454
return description;
5555
}
5656

0 commit comments

Comments
 (0)