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 the FutureResolver tries to resolve the birthday value, it fail with ClassCastException because the Scalar coerceOutput expects a LocalData, however, under the hood our model is Json.
privatedefextractScalar[In](t: ScalarType[_], value: In)(implicitiu: InputUnmarshaller[In]) = {
valcoerced= iu.getScalarValue(value)
t match {
caseBooleanType=>
coerced match {
casev: Boolean=> v
casev: String=> safe(v.toBoolean, "Boolean", value)
case _ => invalidType("Boolean", value)
}
caseStringType=>
coerced.toString
caseIDType=>
coerced match {
cases: String=> s
case _ => invalidType("ID", value)
}
// ...case _ => coerced
}
}
That in my opinion should use coerceInput or coerceUserInput of the scalar before returning the coerced (that is not really coerced). As this is what it does with the other built-in types: it returns Long, BigInt, BigDecimal and so on, while in case of a custom scalar, returns the value taken from the InputUnmarshaller as-is
I have tried changing the last case like this:
case _ => t.coerceUserInput(coerced).fold(v =>thrownewException(v.errorMessage), identity)
And does the trick, however, I am not sure if it should really use coerceInput instead
Making the above change, all the tests are green 🟢
The text was updated successfully, but these errors were encountered:
I'll be totally honest with you: I'm not very familiar with this part of the code.
What you mention makes sense for me.
Would you be ready to making a PR for that? If possible, it'd be great to cover that with some tests.
I can then make a new RC release to test that on several internal applications.
Hello, I am playing with the custom scalars, and I have found something weird. Assuming I have a scalar like this one:
And a schema like so:
When the
FutureResolver
tries to resolve the birthday value, it fail with ClassCastException because the Scalar coerceOutput expects a LocalData, however, under the hood our model is Json.Then I notice the
extractScalar
function isResolverBasedAstSchemaBuilder
:That in my opinion should use
coerceInput
orcoerceUserInput
of the scalar before returning the coerced (that is not really coerced). As this is what it does with the other built-in types: it returns Long, BigInt, BigDecimal and so on, while in case of a custom scalar, returns the value taken from theInputUnmarshaller
as-isI have tried changing the last case like this:
And does the trick, however, I am not sure if it should really use
coerceInput
insteadMaking the above change, all the tests are green 🟢
The text was updated successfully, but these errors were encountered: