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
I'd expect that argOpt returns Option[Option[String]]. The compiler also thinks so, however at runtime I get Option[String].
valt1:Option[Option[String]] = ctx.argOpt(OptionalStringArg)
valt2:Option[String] = ctx.argOpt(OptionalStringArg) // Does not compile
println(t1) // prints "Some(foobar)", instead of the expected "Some(Some(foobar))"
Right, it looks a little strange without context 😉 I wanted to use this inside a middleware. The middleware is called for any field, including fields that don't have this argument declared in the schema. Therefore:
None - the field does not have the argument
Some(None) - the field has the argument, but it was not set
I don't really need that distinction, but I can't call arg() instead of argOpt() because it will throw an exception in the first case.
My workaround is to first check if the field has the argument at all, and only if so, call arg().
Given an argument like this:
I'd expect that argOpt returns
Option[Option[String]]
. The compiler also thinks so, however at runtime I getOption[String]
.I believe this
instanceOf
is to blame: https://github.com/sangria-graphql/sangria/blob/master/src/main/scala/sangria/schema/Context.scala#L301The text was updated successfully, but these errors were encountered: