Skip to content

Commit

Permalink
Restrict content to application json
Browse files Browse the repository at this point in the history
  • Loading branch information
andimarek authored and bclozel committed Oct 13, 2020
1 parent d0324b8 commit d22d9c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.boot.graphql;

import java.util.Collections;

import graphql.GraphQL;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
Expand All @@ -25,11 +27,12 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.graphql.WebFluxGraphQLHandler;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

import java.util.Collections;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;

@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
Expand All @@ -46,7 +49,7 @@ public WebFluxGraphQLHandler graphQLHandler(GraphQL.Builder graphQLBuilder) {

@Bean
public RouterFunction<ServerResponse> graphQLQueryEndpoint(WebFluxGraphQLHandler handler, GraphQLProperties graphQLProperties) {
return RouterFunctions.route().POST(graphQLProperties.getUrl(), handler).build();
return RouterFunctions.route().POST(graphQLProperties.getUrl(), accept(MediaType.APPLICATION_JSON), handler).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.boot.graphql;

import java.util.Collections;

import graphql.GraphQL;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
Expand All @@ -30,8 +32,6 @@
import org.springframework.web.servlet.function.RouterFunctions;
import org.springframework.web.servlet.function.ServerResponse;

import java.util.Collections;

import static org.springframework.web.servlet.function.RequestPredicates.accept;

@Configuration
Expand Down

0 comments on commit d22d9c4

Please sign in to comment.