You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an @SchemaMapping annotated controller method has a parameter that is annotated with @ContextValue and whose type is Mono, it will be called with null when the corresponding value in the GraphQLContext is an empty Mono.
When the GraphQLContext contains a mapping from value to Mono.empty(), the below code will throw an NPE:
I believe the cause is in InvocableHandlerMethodSupport.toArgsMono(Object[] args). This code replaces empty Mono instances in the generated arguments list with null if they are empty. This works fine for unwrapping Mono values stored in the GraphQLContext for an annotated controller with a @ContextValue parameter whose type is the Mono's element type, such as a Mono<String> value in the context to a String (or null) parameter value, but is an issue with a Mono parameter type since it gets invoked with null.
Edit:
This is the code that replaced the empty Mono with null regardless of the @ContextValue parameter type:
rstoyanchev
changed the title
Annotated controller method @ContextValue parameter called with null for empty Mono in GraphQLContext despite parameter type being Mono
@ContextValue does not work for Mono argument
May 5, 2022
When an
@SchemaMapping
annotated controller method has a parameter that is annotated with@ContextValue
and whose type isMono
, it will be called withnull
when the corresponding value in theGraphQLContext
is an emptyMono
.When the GraphQLContext contains a mapping from
value
toMono.empty()
, the below code will throw an NPE:I believe the cause is in
InvocableHandlerMethodSupport.toArgsMono(Object[] args)
. This code replaces emptyMono
instances in the generated arguments list withnull
if they are empty. This works fine for unwrappingMono
values stored in theGraphQLContext
for an annotated controller with a@ContextValue
parameter whose type is theMono
's element type, such as aMono<String>
value in the context to aString
(or null) parameter value, but is an issue with aMono
parameter type since it gets invoked withnull
.Edit:
This is the code that replaced the empty
Mono
withnull
regardless of the@ContextValue
parameter type:The text was updated successfully, but these errors were encountered: