public interface ThreadLocalAccessor
ExecutionInput
and restored later
around the invocation of data fetchers and exception resolvers which may be
in a different thread.
Implementations of this interface are typically declared as beans in
Spring configuration and are invoked in order as defined in
ObjectProvider.orderedStream()
.
Currently supported for GraphQL requests over HTTP and WebSocket in Spring MVC applications.
WebGraphQlHandler.Builder.threadLocalAccessor(ThreadLocalAccessor...)
Modifier and Type | Method and Description |
---|---|
static ThreadLocalAccessor |
composite(List<ThreadLocalAccessor> accessors)
Create a composite accessor that applies all of the given ThreadLocal accessors.
|
void |
extractValues(Map<String,Object> container)
Extract ThreadLocal values and add them to the given Map, so they can be
saved and subsequently
restored around the
invocation of data fetchers and exception resolvers. |
void |
resetValues(Map<String,Object> values)
|
void |
restoreValues(Map<String,Object> values)
Restore ThreadLocal context by looking up previously
extracted values. |
void extractValues(Map<String,Object> container)
restored
around the
invocation of data fetchers and exception resolvers.container
- to add extracted ThreadLocal values tovoid restoreValues(Map<String,Object> values)
extracted
values.values
- previously extracted saved ThreadLocal valuesvoid resetValues(Map<String,Object> values)
values
- previously extracted saved ThreadLocal valuesstatic ThreadLocalAccessor composite(List<ThreadLocalAccessor> accessors)
accessors
- the accessors to apply