Automapper on HotChocolate Optional types #3925
shidcordero
started this conversation in
NA
Replies: 1 comment 3 replies
-
A repro would help. Make a gist that we can execute and see fail. That means the only reference must be to the latest AM. Everything else must be part of the gist. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Source/destination types
Mapping configuration
Version:
Automapper: 8.1.1
Automapper.Collection: 7.0.1
HotChocolate: 12.6.1
EF6
Expected behavior
To be able to map Optional type to the destination. Right now it just keeps throwing this error on run:
Note that only Nullable does not work. The string type is working since I did not enable nullable reference types. Even nullable reference type was enabled, its still throwing the same error. I am not sure what's causing the error. I actually expect the above mapping code to work since the precondition will only map those if
.HasValue
(if.HasValue
is true of Optional, it means that the user pass a value on that field. Optional is used for partial updates). Once the precondition is valid, it will only map it to the value(for example if itsOptional<int?>
and.HasValue
is true, it will map from.Value
ofOptional<int?>
that means itsint?
).Actual behavior
It throws the error above.
Steps to reproduce
Not sure if this is the correct step to reproduce but the error was thrown when
new MapperConfiguration()
was called on Startup.csBeta Was this translation helpful? Give feedback.
All reactions