agrosner
02/27/2023, 7:22 PMDon't know how to instantiate leaf URL
We have a set of scalar adapters which are correctly fed into the databuilders. in the fakeResolver
the order of operations is such:
val leafValue = resolver.resolveLeaf(FakeResolverContext(path, id, mergedField))
if (type is CustomScalarType) {
the resolver
itself seems to run without any knowledge of scalars in the `DefaultFakeResolver`:
else -> {
val type = enumTypes.find { it.name == name } ?: error("Don't know how to instantiate leaf $name")
is this expected? I could not find anything in the docs for data buildersjava.lang.String cannot be cast to ApiURL
"URL" -> faker.internet().url()
seems that the resolveLeaf method also requires we return the correct scalar types from the method. otherwise we get an exceptionmbonnin
02/27/2023, 9:04 PMim resorting to creating our own. which we will have to feed into all data builder instances.That's the way to go, albeit you have to do it at every callsite for now. @Eduard Boloș opened this issue to make it configurable globally
this seems like a bug?There's no way the DefaultFakeResolver knows how to create a random custom scalar. For an example
Date
or GeoPoint
or whatnot, this has to be supplied to the lib somehowhe resolveLeaf method also requires we return the correct scalar types from the method. otherwise we get an exceptionIndeed, you can use
_context.mergedField.type.rawType()_
to get the type to instantiateagrosner
02/27/2023, 11:38 PMmbonnin
02/28/2023, 8:57 AM