- 
        Couldn't load subscription status. 
- Fork 35
Open
Description
Describe the bug
I'm trying to connect kotlin, spring for graphql, and the validation feature, but when I add the directive wiring, the exceptions thrown in the service layer are not being displayed correctly.
Config:
@Configuration
class GraphQLConfig {
    @Bean
    fun runtimeWiringConfigurer(): RuntimeWiringConfigurer {
        val validationRules = ValidationRules.newValidationRules()
            .onValidationErrorStrategy(OnValidationErrorStrategy.RETURN_NULL)
            .build()
        val schemaWiring = ValidationSchemaWiring(validationRules)
        return RuntimeWiringConfigurer { builder: RuntimeWiring.Builder ->
            builder.directiveWiring(schemaWiring).build()
        }
    }
}
Controller:
 @MutationMapping
  fun createCourse(
      @Arguments createCourseDto: CreateCourseDto
  ): CourseDto {
      throw RuntimeException("exception from controller")
  }
Graphql:
directive @NotBlank(message : String! = "graphql.validation.NotBlank.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
createCourse(
     name: String! @NotBlank
 ): Course
type Course {
 id: ID
 name: String
}
When I call this endpoint, the result is an empty object, in the background, an exception is being thrown (check the controller snippet above)
{
  "data": {
    "createCourse": {
      "id": null,
      "name": null
    }
  }
}
But If I remove the directive wiring config:
//@Configuration
//class GraphQLConfig {
//
//    @Bean
//    fun runtimeWiringConfigurer(): RuntimeWiringConfigurer {
//        val validationRules = ValidationRules.newValidationRules()
//            .onValidationErrorStrategy(OnValidationErrorStrategy.RETURN_NULL)
//            .build()
//        val schemaWiring = ValidationSchemaWiring(validationRules)
//
//        return RuntimeWiringConfigurer { builder: RuntimeWiring.Builder ->
//            builder.directiveWiring(schemaWiring).build()
//        }
//    }
//}
I do get the exception as usual:
{
  "errors": [
    {
      "message": "INTERNAL_ERROR for a9883b45-f615-258a-4f7a-bda5b432d485",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createCourse"
      ],
      "extensions": {
        "classification": "INTERNAL_ERROR"
      }
    }
  ],
  "data": {
    "createCourse": null
  }
}
Is it something wrong with the code, or could this be a bug?
Metadata
Metadata
Assignees
Labels
No labels