我想知道是否有可能从
Authentication
中包含的onField
函数中获得SchemaDirectiveWiring
。
我研究过使用
ReactiveSecurityContextHolder
和 SecurityContextHolder.getContext().getAuthentication()
和 ReactiveSecurityContextHolder.getContext().block().getAuthentication()
,但两者都返回 null(这确实有意义,因为它是从异步线程中调用的)。
因此,我研究了使用
[ReactiveDgsContext][1]
,这在调试代码时看起来很有前途,我可以在 reactorContext 中看到有一个 SecurityContext 键/值,但我不知道如何访问它/正确检索它。
目前,我的代码如下所示:
DataFetcher<?> authDataFetcher = DataFetcherFactories
.wrapDataFetcher(originalFetcher, ((dataFetchingEnvironment, value) -> {
ReactiveDgsContext context = ReactiveDgsContext.from(dataFetchingEnvironment);
if(context != null){
ContextView reactiveContext = context.getReactorContext();
...
}
任何帮助将不胜感激!