-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Option
in fields fails in the None
case
#967
Comments
The schema is not valid no? We cannot return
|
The field is mandatory, but in the Using the change you propose the result will be:
even though I was expecting this result:
|
The issue is not in |
A better way would be:
|
I get that, but isn't it weird though? And I wouldn't say that the non-null field returns null. It returns Is it intended to work like this? If it is I would expect it to fail at compile time. The work-a-round (or better way :) ) you provided works, and is also similar to what I ended up doing, but it just doesn't seem right to me. |
So you find an edge case where If we want to avoid this edge case, we could try to disallow using Personally, I won't take the time to try to avoid this. If you want to try, I can assist you. But I'm afraid it will add complexity the code base with no important value. |
What changes do you think are needed to disallow the use of |
I'm not sure. Maybe adding some implicit evidence, and not providing any evidence for |
If a field has an
Option
as it's value, eg:When this field is queried in the
Some
case it works, but in theNone
case it fails at runtime, when queried, with:The complete example can be found here https://github.com/anderslm/sangria-option/
I'm guessing this is why it happens:
sangria/modules/core/src/main/scala/sangria/execution/ValueCoercionHelper.scala
Line 130 in f49d860
The text was updated successfully, but these errors were encountered: