Closed bclozel closed 9 months ago
@bclozel Is it possible to customize this behavior? I see that GraphQlRequestPredicates
is enforcing "application/json" or "application/graphl" content types on requests, which is fine as this is indicated as a must in the graphql spec. In our case, we're migrating from another graphql library to spring now, and we realize that out previous implementation was also allowing requests which do not contain any content-type header. In order to keep our application behaving the same, we would like to be able to use a custom RequestPredicate. I couldn't find any instructions on how to do so.
@fdulger you can implement a custom request predicate, similar to the ones in GraphQlRequestPredicates
and use it in your standalone setup.
@fdulger Another idea: you could configure a Servlet Filter that wraps the request and manually sets a Content-Type if it is empty and path targets the graphql endpoint. You could then even track the lagging clients at this stage. This is probably less complex and would not require undoing Spring Boot auto-configuration.
Thanks a lot for the suggestions! Servlet filter indeed does the work.
Right now, the Spring Boot auto-configuration composes several
RequestPredicate
instances to handle GraphQL requests. Composing there can incur some overhead and no practical advantage in our case. Spring for GraphQL should instead provide customRequestPredicate
implementations that are optimized for optimal performance.They should be then leveraged in the Spring Boot auto-configuration.