Class GraphQlHttpHandler
java.lang.Object
org.springframework.graphql.server.webmvc.AbstractGraphQlHttpHandler
org.springframework.graphql.server.webmvc.GraphQlHttpHandler
GraphQL handler to expose as a WebMvc functional endpoint via
RouterFunctions
.- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Field Summary
Fields inherited from class org.springframework.graphql.server.webmvc.AbstractGraphQlHttpHandler
logger
-
Constructor Summary
ConstructorsConstructorDescriptionGraphQlHttpHandler
(WebGraphQlHandler graphQlHandler) Create a new instance.GraphQlHttpHandler
(WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter) Create a new instance with a custom message converter for GraphQL payloads. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return whether this HTTP handler should use HTTP 200 OK responses if an error occurs before the GraphQL request execution phase starts; for example, if JSON parsing, GraphQL document parsing, or GraphQL document validation fail.protected ServerResponse
prepareResponse
(ServerRequest request, reactor.core.publisher.Mono<WebGraphQlResponse> responseMono) Prepare theServerResponse
for the given GraphQL response.protected HttpStatus
selectResponseStatus
(WebGraphQlResponse response, MediaType responseMediaType) void
setHttpOkOnValidationErrors
(boolean httpOkOnValidationErrors) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class org.springframework.graphql.server.webmvc.AbstractGraphQlHttpHandler
getWriteFunction, handleRequest
-
Constructor Details
-
GraphQlHttpHandler
Create a new instance.- Parameters:
graphQlHandler
- common handler for GraphQL over HTTP requests
-
GraphQlHttpHandler
public GraphQlHttpHandler(WebGraphQlHandler graphQlHandler, @Nullable HttpMessageConverter<?> converter) Create a new instance with a custom message converter for GraphQL payloads.If no converter is provided, the handler will use
the one configured for web use
.- Parameters:
graphQlHandler
- common handler for GraphQL over HTTP requestsconverter
- the converter to use to read and write GraphQL payloads
-
-
Method Details
-
isHttpOkOnValidationErrors
public boolean isHttpOkOnValidationErrors()Return whether this HTTP handler should use HTTP 200 OK responses if an error occurs before the GraphQL request execution phase starts; for example, if JSON parsing, GraphQL document parsing, or GraphQL document validation fail.This option only applies to
MediaTypes.APPLICATION_GRAPHQL_RESPONSE
responses, as legacyMediaType.APPLICATION_JSON
responses always use HTTP 200 OK in such cases. Enabling this option means the server will not conform to the "GraphQL over HTTP specification".By default, this is set to
false
.- Since:
- 1.4.0
- See Also:
-
setHttpOkOnValidationErrors
@Deprecated(since="1.4.0", forRemoval=true) public void setHttpOkOnValidationErrors(boolean httpOkOnValidationErrors) Deprecated, for removal: This API element is subject to removal in a future version.since 1.4, will be madefalse
permanently in a future releaseSet whether this HTTP handler should use HTTP 200 OK responses if an error occurs before the GraphQL request execution phase starts.- Parameters:
httpOkOnValidationErrors
- whether "HTTP 200 OK" responses should always be used- Since:
- 1.4.0
- See Also:
-
prepareResponse
protected ServerResponse prepareResponse(ServerRequest request, reactor.core.publisher.Mono<WebGraphQlResponse> responseMono) Description copied from class:AbstractGraphQlHttpHandler
Prepare theServerResponse
for the given GraphQL response.- Specified by:
prepareResponse
in classAbstractGraphQlHttpHandler
- Parameters:
request
- the current requestresponseMono
- the GraphQL response- Returns:
- the server response
-
selectResponseStatus
-
false
permanently in a future release