-
Notifications
You must be signed in to change notification settings - Fork 329
Closed as not planned
Closed as not planned
Copy link
Description
I'm having trouble combining DataLoaders with Spring Security;
My scenario;
typealias MerchantDataLoader = DataLoader<UUID, Merchant?>
// MerchantDataLoader
registry.forTypePair(UUID::class.java, Merchant::class.java).registerMappedBatchLoader { merchantIds, _ ->
Mono.just(merchantService.getMerchants(merchantIds).associateBy { it.id })
}
// ...
@SchemaMapping
@PreAuthorize("@permissionEvaluator.hasPermission(authentication, #merchant.id, 'Merchant', 'read')")
fun dashboardForDate(
merchant: Merchant,
@Argument date: LocalDate?,
merchantLoader: MerchantDataLoader
): CompletableFuture<Dashboard> = merchantLoader.load(merchant.id).thenApply {
if (it == null) throw EntityNotFoundException()
Dashboard(date, it)
}For GraphQL Java being able to dispatch the dataloader the method has to return the CompletableFuture, but for the @PreAuthorize annotation it "must return an instance of org.reactivestreams.Publisher (i.e. Mono / Flux) or the function must be a Kotlin coroutine function".
I've also tried making it a suspend fun, while still returning the CompletableFuture, but then I get an error like does not match the type of the source Object 'class java.util.concurrent.CompletableFuture', which makes sense because my controller is not expecting the CompletableFuture.
Is my assumption correct, or is there a way around this that I don't know about?
Metadata
Metadata
Assignees
Labels
No labels