@@ -21,7 +21,7 @@ public class GraphqlErrorBuilder {
2121 private String message ;
2222 private List <Object > path ;
2323 private List <SourceLocation > locations = new ArrayList <>();
24- private ErrorType errorType = ErrorType .DataFetchingException ;
24+ private ErrorTypeClassification errorType = ErrorType .DataFetchingException ;
2525 private Map <String , Object > extensions = null ;
2626
2727
@@ -74,7 +74,7 @@ public GraphqlErrorBuilder path(List<Object> path) {
7474 return this ;
7575 }
7676
77- public GraphqlErrorBuilder errorType (ErrorType errorType ) {
77+ public GraphqlErrorBuilder errorType (ErrorTypeClassification errorType ) {
7878 this .errorType = assertNotNull (errorType );
7979 return this ;
8080 }
@@ -89,32 +89,48 @@ public GraphqlErrorBuilder extensions(Map<String, Object> extensions) {
8989 */
9090 public GraphQLError build () {
9191 assertNotNull (message , "You must provide error message" );
92- return new GraphQLError () {
93- @ Override
94- public String getMessage () {
95- return message ;
96- }
97-
98- @ Override
99- public List <SourceLocation > getLocations () {
100- return locations ;
101- }
102-
103- @ Override
104- public ErrorType getErrorType () {
105- return errorType ;
106- }
107-
108- @ Override
109- public List <Object > getPath () {
110- return path ;
111- }
112-
113- @ Override
114- public Map <String , Object > getExtensions () {
115- return extensions ;
116- }
117- };
92+ return new GraphqlErrorImpl (message , locations , errorType , path , extensions );
93+ }
94+
95+ private static class GraphqlErrorImpl implements GraphQLError {
96+ private final String message ;
97+ private final List <SourceLocation > locations ;
98+ private final ErrorTypeClassification errorType ;
99+ private final List <Object > path ;
100+ private final Map <String , Object > extensions ;
101+
102+ public GraphqlErrorImpl (String message , List <SourceLocation > locations , ErrorTypeClassification errorType , List <Object > path , Map <String , Object > extensions ) {
103+ this .message = message ;
104+ this .locations = locations ;
105+ this .errorType = errorType ;
106+ this .path = path ;
107+ this .extensions = extensions ;
108+ }
109+
110+ @ Override
111+ public String getMessage () {
112+ return message ;
113+ }
114+
115+ @ Override
116+ public List <SourceLocation > getLocations () {
117+ return locations ;
118+ }
119+
120+ @ Override
121+ public ErrorTypeClassification getErrorType () {
122+ return errorType ;
123+ }
124+
125+ @ Override
126+ public List <Object > getPath () {
127+ return path ;
128+ }
129+
130+ @ Override
131+ public Map <String , Object > getExtensions () {
132+ return extensions ;
133+ }
118134 }
119135
120136 /**
0 commit comments