Ah, I had seen the macro usage a long time ago but hadn't used them since everything I'm doing is dynamically constructed.
Ended up just using the QueryParser and I've now found my problem. The original code is rather complicated but ultimately there is an error on my side caused by having some debug code in the middle of the resolve call which caused resolve to return both the expected result or Unit. The misleading issue is that this works fine for the case where you are returning Option[OutputType[Any]] but fails for the case where one returns Seq[OutputType[Any]] Ultimately, the reason it worked at all is because of the implicit for ValidOption
Not sure if there is any way to make this kind of error easier to spot. After a bunch of experimentation I've reduced the problem to the rather artificial code snippets that follow:
def buildSchema: Schema[Any, Any] = {
Schema( ObjectType("Query", queryFields()) )
}
def queryFields(): List[Field[Any,Any]] = {
val flds = new ListBuffer[Field[Any, Any]]
flds.append(Field("vertex",OptionType(qtype), arguments = List( Argument( "id", StringType, "id")), resolve = ctx => ctx.ctx match {
case r: Repo => r.queryGraph() // returns Option[Vertex]
case other => println( "Context for queryFields is " + other ) // match is not returning Any
}))
flds.append(Field("vertices", ListType(qtype), resolve = ctx => ctx.ctx match {
case r: Repo => r.queryAllGraph() // returns Seq[Vertex]
case other => println( "Context for queryFields is " + other ) // match is now returning Any
}))
flds.toList
}
I'm adding in the Repo at execute time as the user context:
Executor.execute(buildSchema, query, new Repo())
The first Field definition compiles fine, the second one will not find a matching implicit. Really, you don't want the first case to work either. Not sure what to do about that?