I want to write a test around a resolver that returns a ResolverResultPromise. Is there a convenient way to wait and get the resolved value after it's been delivered? Or do I have to register a callback via on-deliver and if so how do you get a value (or more accurately some kind of error data structure/something you can assert on) out of a lacinia.resolve$with_error$reify if that makes sense.
Is it actually a clojure promise? Can you deref it?
the most straightforward way is to do something like (let [p (promise)] (on-deliver rr-promise p) @p)
that will let you block your normal code on the async-sih/callback-ish code
ResolverResultPromise is not a clojure.core/promise
it doesn't define a way to block on a result, only a way to register a callback to receive a result
The use of a Clojure promise is how I generally do it in testing myself. Sometimes, I also have an on-deliver! fn convey the value to a core.async channel.
BTW, being able to treat a Clojure promise as a callback function is a stable but only psuedo-documented behavior of Clojure's promise. It ends up being quick concise here.
I would consider making a ResolverResultPromise implement the IBlockingDeref interface (and perhaps IDeref and IPending). I'm hesitant to introduce code that should only be used for testing into production code.
These were my planned approaches, thanks for confirming :) unless im mistaken the on-deliver callback gets a value if a value was delivered, but if an error was delivered (the 3 arity form of deliver!) I seem to get a with_error type. Is there a way to get some data out of that type?