Class DefaultExecutionGraphQlRequest
java.lang.Object
org.springframework.graphql.support.DefaultGraphQlRequest
org.springframework.graphql.support.DefaultExecutionGraphQlRequest
- All Implemented Interfaces:
ExecutionGraphQlRequest
,GraphQlRequest
- Direct Known Subclasses:
RSocketGraphQlRequest
,WebGraphQlRequest
public class DefaultExecutionGraphQlRequest
extends DefaultGraphQlRequest
implements ExecutionGraphQlRequest
GraphQlRequest
for server side handling, adding the transport (e.g. HTTP
or WebSocket handler) assigned id
and locale
in the addition to the GraphQlRequest
inputs.
Supports the initialization of ExecutionInput
that is passed to
GraphQL
. You can customize that via
configureExecutionInput(BiFunction)
.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configureExecutionInput
(BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput> configurer) void
executionId
(ExecutionId executionId) Configure theExecutionId
to set onExecutionInput.getExecutionId()
, overriding the transport assignedid
.Return the configuredexecutionId
.getId()
Return the transport assigned id for the request that in turn setsexecutionId
.Return the transport assigned locale value, if any.Create theExecutionInput
to pass toGraphQL
.toString()
Methods inherited from class org.springframework.graphql.support.DefaultGraphQlRequest
equals, getDocument, getExtensions, getOperationName, getVariables, hashCode, toMap
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.graphql.GraphQlRequest
getDocument, getExtensions, getOperationName, getVariables, toMap
-
Constructor Details
-
DefaultExecutionGraphQlRequest
public DefaultExecutionGraphQlRequest(String document, @Nullable String operationName, @Nullable Map<String, Object> variables, @Nullable Map<String, Object> extensions, String id, @Nullable Locale locale) Create an instance.- Parameters:
document
- textual representation of the operation(s)operationName
- optionally, the name of the operation to executevariables
- variables by which the query is parameterizedextensions
- implementor specific, protocol extensionsid
- the request id, to be used as theExecutionId
locale
- the locale associated with the request
-
-
Method Details
-
getId
Description copied from interface:ExecutionGraphQlRequest
Return the transport assigned id for the request that in turn setsexecutionId
.By default, the id is initialized as follows:
- On WebFlux, this is the
ServerHttpRequest
id which correlates to WebFlux log messages. For Reactor Netty, it also correlates to server log messages. - On Spring MVC, the id is generated via
AlternativeJdkIdGenerator
, which does not correlate to anything, but is more efficient than the defaultExecutionIdProvider
which relies onUUID.randomUUID()
. - On WebSocket, the id is set to the message id of the
"subscribe"
message from the GraphQL over WebSocket protocol that is used to correlate request and response messages on the the WebSocket.
To override this id, use
ExecutionGraphQlRequest.executionId(ExecutionId)
or configureGraphQL
with anExecutionIdProvider
.- Specified by:
getId
in interfaceExecutionGraphQlRequest
- Returns:
- the request id
- On WebFlux, this is the
-
executionId
Description copied from interface:ExecutionGraphQlRequest
Configure theExecutionId
to set onExecutionInput.getExecutionId()
, overriding the transport assignedid
.- Specified by:
executionId
in interfaceExecutionGraphQlRequest
- Parameters:
executionId
- the id to use
-
getExecutionId
Description copied from interface:ExecutionGraphQlRequest
Return the configuredexecutionId
.- Specified by:
getExecutionId
in interfaceExecutionGraphQlRequest
-
getLocale
Description copied from interface:ExecutionGraphQlRequest
Return the transport assigned locale value, if any.- Specified by:
getLocale
in interfaceExecutionGraphQlRequest
-
configureExecutionInput
public void configureExecutionInput(BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput> configurer) Description copied from interface:ExecutionGraphQlRequest
Provide aBiFunction
to help initialize theExecutionInput
passed toGraphQL
. TheExecutionInput
is first pre-populated with values from "this"ExecutionGraphQlRequest
, and is then customized with the functions provided here.- Specified by:
configureExecutionInput
in interfaceExecutionGraphQlRequest
- Parameters:
configurer
- aBiFunction
that accepts theExecutionInput
initialized so far, and a builder to customize it.
-
toExecutionInput
Description copied from interface:ExecutionGraphQlRequest
Create theExecutionInput
to pass toGraphQL
. passed toGraphQL
. TheExecutionInput
is populated with values from "this"ExecutionGraphQlRequest
, and then customized with functions provided viaExecutionGraphQlRequest.configureExecutionInput(BiFunction)
.- Specified by:
toExecutionInput
in interfaceExecutionGraphQlRequest
- Returns:
- the resulting
ExecutionInput
-
toString
- Overrides:
toString
in classDefaultGraphQlRequest
-