Class GraphQlHttpHandler
java.lang.Object
org.springframework.graphql.server.webflux.AbstractGraphQlHttpHandler
org.springframework.graphql.server.webflux.GraphQlHttpHandler
WebFlux.fn Handler for GraphQL over HTTP requests.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.springframework.graphql.server.webflux.AbstractGraphQlHttpHandler
logger -
Constructor Summary
ConstructorsConstructorDescriptionGraphQlHttpHandler(WebGraphQlHandler graphQlHandler) Deprecated, for removal: This API element is subject to removal in a future version.GraphQlHttpHandler(WebGraphQlHandler graphQlHandler, CodecConfigurer codecConfigurer) Deprecated, for removal: This API element is subject to removal in a future version.since 2.1.0 in favor ofbuilder(WebGraphQlHandler) -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphQlHttpHandler.Builderbuilder(WebGraphQlHandler graphQlHandler) Return a builder to create aGraphQlHttpHandler, e.g.Return the HTTP methods this handler is configured to support.protected Set<graphql.language.OperationDefinition.Operation> Return the GraphQL operation types that this handler supports, regardless of the semantics of any particular request.booleanReturn 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 reactor.core.publisher.Mono<ServerResponse> prepareResponse(ServerRequest request, WebGraphQlResponse response) Prepare theServerResponsefor the given GraphQL response.protected HttpStatusselectResponseStatus(ServerRequest request, WebGraphQlResponse response, MediaType responseMediaType) Select the HTTP response status, taking into account any rejection of the request's operation type based on the semantics of the current HTTP method.Methods inherited from class org.springframework.graphql.server.webflux.AbstractGraphQlHttpHandler
bodyInserter, findRejection, handleRequest
-
Constructor Details
-
GraphQlHttpHandler
@Deprecated(since="2.1.0", forRemoval=true) public GraphQlHttpHandler(WebGraphQlHandler graphQlHandler) Deprecated, for removal: This API element is subject to removal in a future version.since 2.1.0 in favor ofbuilder(WebGraphQlHandler)Create a new instance.- Parameters:
graphQlHandler- common handler for GraphQL over HTTP requests
-
GraphQlHttpHandler
@Deprecated(since="2.1.0", forRemoval=true) public GraphQlHttpHandler(WebGraphQlHandler graphQlHandler, CodecConfigurer codecConfigurer) Deprecated, for removal: This API element is subject to removal in a future version.since 2.1.0 in favor ofbuilder(WebGraphQlHandler)Create a new instance.- Parameters:
graphQlHandler- common handler for GraphQL over HTTP requestscodecConfigurer- codec configurer for JSON encoding and decoding
-
-
Method Details
-
builder
Return a builder to create aGraphQlHttpHandler, e.g. to configure which HTTP methods it should support.- Parameters:
graphQlHandler- common handler for GraphQL over HTTP requests- Since:
- 2.1.0
-
getHttpMethods
Return the HTTP methods this handler is configured to support.Applications should use this value when configuring the matching
RequestPredicate, so that both stay in sync.- Since:
- 2.1.0
-
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_RESPONSEresponses, as legacyMediaType.APPLICATION_JSONresponses 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:
-
prepareResponse
protected reactor.core.publisher.Mono<ServerResponse> prepareResponse(ServerRequest request, WebGraphQlResponse response) Description copied from class:AbstractGraphQlHttpHandlerPrepare theServerResponsefor the given GraphQL response.- Specified by:
prepareResponsein classAbstractGraphQlHttpHandler- Parameters:
request- the current requestresponse- the GraphQL response- Returns:
- the server response
-
selectResponseStatus
protected HttpStatus selectResponseStatus(ServerRequest request, WebGraphQlResponse response, MediaType responseMediaType) Select the HTTP response status, taking into account any rejection of the request's operation type based on the semantics of the current HTTP method.- Parameters:
request- the HTTP requestresponse- the GraphQL responseresponseMediaType- the HTTP response media type
-
getSupportedOperations
Description copied from class:AbstractGraphQlHttpHandlerReturn the GraphQL operation types that this handler supports, regardless of the semantics of any particular request.- Specified by:
getSupportedOperationsin classAbstractGraphQlHttpHandler
-
builder(WebGraphQlHandler)