Class ContextPropagationHelper
java.lang.Object
org.springframework.graphql.execution.ContextPropagationHelper
- Direct Known Subclasses:
- ContextSnapshotFactoryHelper
Helper for propagating context values from and to Reactor and GraphQL contexts.
- Since:
- 1.3.5
- Author:
- Rossen Stoyanchev, Brian Clozel
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Flux<T> bindCancelFrom(reactor.core.publisher.Flux<T> source, graphql.GraphQLContext context) Bind the sourceFluxto the publisher from the givenGraphQLContext.static io.micrometer.context.ContextSnapshotcaptureFrom(graphql.GraphQLContext context) Shortcut to obtain theContextSnapshotFactoryinstance, and to capture from the givenGraphQLContext.static io.micrometer.context.ContextSnapshotcaptureFrom(reactor.util.context.ContextView contextView) Shortcut to obtain theContextSnapshotFactoryinstance, and to capture from the givenContextView.static RunnablecreateCancelSignal(graphql.GraphQLContext context) Create an atomic boolean and store it into the givenGraphQLContext.static io.micrometer.context.ContextSnapshotFactorygetInstance(graphql.GraphQLContext context) Access theContextSnapshotFactoryfrom the givenGraphQLContextor return a shared, static instance.static io.micrometer.context.ContextSnapshotFactorygetInstance(reactor.util.context.ContextView contextView) Access theContextSnapshotFactoryfrom the givenContextViewor return a shared, static instance.static booleanisCancelled(graphql.GraphQLContext context) Returntrueif the current request has been cancelled,falseotherwise.static voidsaveInstance(io.micrometer.context.ContextSnapshotFactory factory, graphql.GraphQLContext context) Save theContextSnapshotFactoryin the givenContext.static reactor.util.context.ContextsaveInstance(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context) Save theContextSnapshotFactoryin the givenContext.static io.micrometer.context.ContextSnapshotFactoryselectInstance(@Nullable io.micrometer.context.ContextSnapshotFactory factory) Select aContextSnapshotFactoryinstance to use, either the one passed in if it is notnull, or a shared, static instance.
- 
Constructor Details- 
ContextPropagationHelperpublic ContextPropagationHelper()
 
- 
- 
Method Details- 
selectInstancepublic static io.micrometer.context.ContextSnapshotFactory selectInstance(@Nullable io.micrometer.context.ContextSnapshotFactory factory) Select aContextSnapshotFactoryinstance to use, either the one passed in if it is notnull, or a shared, static instance.- Parameters:
- factory- the candidate factory instance to use if not- null
- Returns:
- the instance to use
 
- 
saveInstancepublic static reactor.util.context.Context saveInstance(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context) Save theContextSnapshotFactoryin the givenContext.- Parameters:
- factory- the instance to save
- context- the context to save the instance to
- Returns:
- a new context with the saved instance
 
- 
saveInstancepublic static void saveInstance(io.micrometer.context.ContextSnapshotFactory factory, graphql.GraphQLContext context) Save theContextSnapshotFactoryin the givenContext.- Parameters:
- factory- the instance to save
- context- the context to save the instance to
 
- 
getInstancepublic static io.micrometer.context.ContextSnapshotFactory getInstance(reactor.util.context.ContextView contextView) Access theContextSnapshotFactoryfrom the givenContextViewor return a shared, static instance.- Parameters:
- contextView- the context where the instance is saved
- Returns:
- the instance to use
 
- 
getInstancepublic static io.micrometer.context.ContextSnapshotFactory getInstance(graphql.GraphQLContext context) Access theContextSnapshotFactoryfrom the givenGraphQLContextor return a shared, static instance.- Parameters:
- context- the context where the instance is saved
- Returns:
- the instance to use
 
- 
captureFrompublic static io.micrometer.context.ContextSnapshot captureFrom(reactor.util.context.ContextView contextView) Shortcut to obtain theContextSnapshotFactoryinstance, and to capture from the givenContextView.- Parameters:
- contextView- the context to capture from
- Returns:
- a snapshot from the capture
 
- 
captureFrompublic static io.micrometer.context.ContextSnapshot captureFrom(graphql.GraphQLContext context) Shortcut to obtain theContextSnapshotFactoryinstance, and to capture from the givenGraphQLContext.- Parameters:
- context- the context to capture from
- Returns:
- a snapshot from the capture
 
- 
createCancelSignalCreate an atomic boolean and store it into the givenGraphQLContext. This boolean value can then be checked by upstream publishers to know whether the request is canceled.- Parameters:
- context- the current GraphQL context
- Since:
- 1.3.6
 
- 
isCancelledpublic static boolean isCancelled(graphql.GraphQLContext context) Returntrueif the current request has been cancelled,falseotherwise. This checks whether acancellation publisher is presentin the given context and the cancel signal has fired already.- Parameters:
- context- the current GraphQL context
- Since:
- 1.4.0
 
- 
bindCancelFrompublic static <T> reactor.core.publisher.Flux<T> bindCancelFrom(reactor.core.publisher.Flux<T> source, graphql.GraphQLContext context) Bind the sourceFluxto the publisher from the givenGraphQLContext. The returnedFluxwill be cancelled when this publisher completes. Subscribers must use the returnedMonoinstance.- Type Parameters:
- T- the type of published elements
- Parameters:
- source- the source- Mono
- context- the current GraphQL context
- Returns:
- the new Monothat will be cancelled when notified
- Since:
- 1.3.5
 
 
-