forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnresolvedTypeError.java
More file actions
78 lines (62 loc) · 2.14 KB
/
UnresolvedTypeError.java
File metadata and controls
78 lines (62 loc) · 2.14 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package graphql;
import graphql.execution.ExecutionPath;
import graphql.execution.ExecutionTypeInfo;
import graphql.execution.UnresolvedTypeException;
import graphql.language.SourceLocation;
import java.util.List;
import static graphql.Assert.assertNotNull;
import static java.lang.String.format;
@PublicApi
public class UnresolvedTypeError implements GraphQLError {
private final String message;
private final List<Object> path;
private final UnresolvedTypeException exception;
public UnresolvedTypeError(ExecutionPath path, ExecutionTypeInfo info,
UnresolvedTypeException exception) {
this.path = assertNotNull(path).toList();
this.exception = assertNotNull(exception);
this.message = mkMessage(path, exception, assertNotNull(info));
}
private String mkMessage(ExecutionPath path, UnresolvedTypeException exception, ExecutionTypeInfo info) {
return format("Can't resolve '%s'. Abstract type '%s' must resolve to an Object type at runtime for field '%s.%s'. %s",
path,
exception.getInterfaceOrUnionType().getName(),
info.getParentTypeInfo().getType().getName(),
info.getFieldDefinition().getName(),
exception.getMessage());
}
public UnresolvedTypeException getException() {
return exception;
}
@Override
public String getMessage() {
return message;
}
@Override
public List<SourceLocation> getLocations() {
return null;
}
@Override
public ErrorType getErrorType() {
return ErrorType.DataFetchingException;
}
public List<Object> getPath() {
return path;
}
@Override
public String toString() {
return "UnresolvedTypeError{" +
"path=" + path +
"exception=" + exception +
'}';
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return GraphqlErrorHelper.equals(this, o);
}
@Override
public int hashCode() {
return GraphqlErrorHelper.hashCode(this);
}
}