graphql-java-kickstart / graphql-spring-boot

GraphQL and GraphiQL Spring Framework Boot Starters - Forked from oembedler/graphql-spring-boot due to inactivity.
https://www.graphql-java-kickstart.com/spring-boot/
MIT License
1.5k stars 325 forks source link

Customize SimpleDataFetcherExceptionHandler to avoid logException for certain errors #897

Open williamwjs opened 2 years ago

williamwjs commented 2 years ago

Is your feature request related to a problem? Please describe. In our app, it is normal and expected to have non-login users accessing the pages, where we will return as auth error for some queries. It is annoying to always log the stacktrace for such cases.

Graphql-Java made that a protected method so that we could override it with our own logic: https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/SimpleDataFetcherExceptionHandler.java#L40-L48

However, it is not easy to embed it with kickstart library right now.

Describe the solution you'd like Expecting a non-required bean for DataFetcherExceptionHandler, so that it could be passed into the below places when building Execution strategy: https://github.com/graphql-java-kickstart/graphql-spring-boot/blob/13cd484f913fe7885ff5d5bc5883b1e9544d4ca6/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java#L177-L178

Describe alternatives you've considered As a workaround, I have to provide my own bean for executionStrategies, which I feel is too much layer above: https://github.com/graphql-java-kickstart/graphql-spring-boot/blob/13cd484f913fe7885ff5d5bc5883b1e9544d4ca6/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java#L113

williamwjs commented 1 year ago

A related question: May I also ask why line 177 gives null for mutationExecutionStrategy? https://github.com/graphql-java-kickstart/graphql-spring-boot/blob/13cd484f913fe7885ff5d5bc5883b1e9544d4ca6/graphql-spring-boot-autoconfigure/src/main/java/graphql/kickstart/spring/web/boot/GraphQLWebAutoConfiguration.java#L177-L178