Reactor - Flux and Mono can't get them to work at all
See original GitHub issueSo I’ve been hammering away at this for a day and I can’t seem to get even basic queries to work with mono or flux.
Below is an example of a query to a user profile from the identity store. If I convert this into a future it works out of the box, but the moment I use a mono i get all my fields as null
{"data":{"currentUserProfile":{"firstname":null,"lastname":null,"username":null,"emailAddress":null}}}
And the query code:
@PreAuthorize("isAuthenticated()")
fun currentUserProfile(context: GraphQLSecurityContext): Mono<UserProfile> {
return context.securityContext.flatMap { sc ->
val details = sc.authentication.details as UserCredential
userIdentityService.findById(details.id).map { UserProfile.fromUserIdentity(it) }
}
I don’t seem to have a problem generating schema with mono. I have registered a monad hook, but it seems to do nothing.
Is there something I’m doing wrong? I know it does call the query method, but I can’t seem to figure out I get a null response.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:32 (5 by maintainers)
Top Results From Across the Web
Reactor 3 Reference Guide
It offers composable asynchronous sequence APIs — Flux (for [N] elements) and Mono (for [0|1] elements) — and extensively implements the ...
Read more >[Reactor Java #4] How to take control over the execution of ...
Reactor is a Java library for creating reactive non-blocking ... Mono and Flux have two methods to configure the scheduler to use.
Read more >project reactor - How to combine a Mono and a Flux?
While Kevin Hussey's solution is a correct one, I think it is better to have it another way around: Mono<String> mono1 = Mono....
Read more >Intro To Reactor Core - Baeldung
We'll take small steps through Reactor until we've built a picture of how to compose reactive code, laying the foundation for more advanced ......
Read more >The 5 basic topics you should know about project reactor
For example, wrapping every external service call into an ... To convert a Mono into a Flux that repeats that value we can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Anyway, thanks for the help.
Here is the code for anyone that wants it. Obviously a todo will be to add expression support:
Edit: Forgot the annotation
Example:
Hi, thanks for providing the examples, it is indeed very helpful. Regarding the code from @thunderbird do I understand correctly, the
@Authorised
annotation only works on top-level object like query or mutation?This works for me:
Now I annotated a field on the type the query returns, like follows:
Expected behaviour would be that a user without the role ‘Manager’ could not retrieve the field ‘secret’.
Any ideas how to achieve this?
EDIT: One approach that works for me is to go the same way on the PropertyDataFetcherFactory: