Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to integrate graphql-java-extended-validation into DGS? #74

Open
epiphyllum opened this issue May 22, 2022 · 1 comment
Open

how to integrate graphql-java-extended-validation into DGS? #74

epiphyllum opened this issue May 22, 2022 · 1 comment

Comments

@epiphyllum
Copy link

Can dgs be integrated with implementation("com.graphql-java:graphql-java-extended-validation:2022-04-27T05-15-47-b3d9bc3") ?

and how to do it?

    implementation("com.graphql-java:graphql-java-extended-validation:2022-04-27T05-15-47-b3d9bc3")
    implementation("org.hibernate.validator:hibernate-validator:7.0.4.Final")
type Query {
    shows(titleFilter: String @NotBlank): [Show]
}

@DgsComponent
class ValidationConfig {

    @DgsRuntimeWiring
    fun addValidationDirective(builder: RuntimeWiring.Builder): RuntimeWiring.Builder {
        val validationRules = ValidationRules.newValidationRules()
            .onValidationErrorStrategy(OnValidationErrorStrategy.RETURN_NULL)
            .build()
        val wiring = ValidationSchemaWiring(validationRules)  // SchemaDirectiveWiring
        return builder.directiveWiring(wiring)
    }
    
}
2022-05-22 17:57:10.242  WARN 60792 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dgsQueryExecutor' defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'dgsQueryExecutor' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schema' defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'schema' threw exception; nested exception is SchemaProblem{errors=['titleFilter' [@2:11] tried to use an undeclared directive 'NotBlank']}
2022-05-22 17:57:10.244  INFO 60792 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-05-22 17:57:10.254  INFO 60792 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-05-22 17:57:10.271 ERROR 60792 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

There are problems with the GraphQL Schema:
	 * 'titleFilter' [@2:11] tried to use an undeclared directive 'NotBlank'

@springmonster
Copy link

Hi @epiphyllum , you can refer to this commit to see if it is what you want.
springmonster@9b2fa75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants