@@ -40,7 +40,7 @@ impl<'a> OperationVisitor<'a, ValidationErrorContext> for LoneAnonymousOperation
4040 match definition {
4141 Definition :: Operation ( OperationDefinition :: SelectionSet ( _) ) => {
4242 if operations_count > 1 {
43- user_context. report_error ( ValidationError {
43+ user_context. report_error ( ValidationError { error_code : self . error_code ( ) ,
4444 message : "This anonymous operation must be the only defined operation."
4545 . to_string ( ) ,
4646 locations : vec ! [ ] ,
@@ -49,7 +49,7 @@ impl<'a> OperationVisitor<'a, ValidationErrorContext> for LoneAnonymousOperation
4949 }
5050 Definition :: Operation ( OperationDefinition :: Query ( query) ) => {
5151 if query. name == None && operations_count > 1 {
52- user_context. report_error ( ValidationError {
52+ user_context. report_error ( ValidationError { error_code : self . error_code ( ) ,
5353 message : "This anonymous operation must be the only defined operation."
5454 . to_string ( ) ,
5555 locations : vec ! [ query. position. clone( ) ] ,
@@ -58,7 +58,7 @@ impl<'a> OperationVisitor<'a, ValidationErrorContext> for LoneAnonymousOperation
5858 }
5959 Definition :: Operation ( OperationDefinition :: Mutation ( mutation) ) => {
6060 if mutation. name == None && operations_count > 1 {
61- user_context. report_error ( ValidationError {
61+ user_context. report_error ( ValidationError { error_code : self . error_code ( ) ,
6262 message : "This anonymous operation must be the only defined operation."
6363 . to_string ( ) ,
6464 locations : vec ! [ mutation. position. clone( ) ] ,
@@ -67,7 +67,7 @@ impl<'a> OperationVisitor<'a, ValidationErrorContext> for LoneAnonymousOperation
6767 }
6868 Definition :: Operation ( OperationDefinition :: Subscription ( subscription) ) => {
6969 if subscription. name == None && operations_count > 1 {
70- user_context. report_error ( ValidationError {
70+ user_context. report_error ( ValidationError { error_code : self . error_code ( ) ,
7171 message : "This anonymous operation must be the only defined operation."
7272 . to_string ( ) ,
7373 locations : vec ! [ subscription. position. clone( ) ] ,
@@ -81,6 +81,10 @@ impl<'a> OperationVisitor<'a, ValidationErrorContext> for LoneAnonymousOperation
8181}
8282
8383impl ValidationRule for LoneAnonymousOperation {
84+ fn error_code < ' a > ( & self ) -> & ' a str {
85+ "LoneAnonymousOperation"
86+ }
87+
8488 fn validate < ' a > (
8589 & self ,
8690 ctx : & ' a mut OperationVisitorContext ,
0 commit comments