private def builder: ResolverBasedAstSchemaBuilder[UserContext] =
AstSchemaBuilder.resolverBased[UserContext](
riFieldResolver.resolvers :+ FieldResolver.defaultInput[UserContext, JsValue]: _*
)
private val schemaString = Source.fromResource("schema.graphql").mkString
private val schemaAst = QueryParser.parse(schemaString).get
val schema: Schema[UserContext, Any] = Schema.buildFromAst(schemaAst, builder.validateSchemaWithException(schemaAst))
private val riThreadResolver = FieldResolver[UserContext] {
case (TypeName("Subscription"), FieldName("fi_thread")) =>
Field.subs("allEvents", null, resolve = { _: Context[UserContext, _] =>
Source(1 to 10)
.map { _ =>
s"""{
"data": {
"fi_thread": "${LocalTime.now().toString}",
"fi_thread2": "${LocalTime.now().toString}"
}
}"""
}
.map(Action(_))
}).resolve
}
private[sangria] case class SubscriptionValue[Ctx, Val, S[_]](source: Val, stream: SubscriptionStream[S]) extends LeafAction[Ctx, Val] {
override def map[NewVal](fn: Val => NewVal)(implicit ec: ExecutionContext): SubscriptionValue[Ctx, NewVal, S] =
throw new IllegalStateException("`map` is not supported subscription actions. Action is only intended for internal use.")
}
this is probably useful implicit but it's private
A <: Null
type constraint, and that's deep in Tree
(part of the Ast code) That said... I am currently fully unqualified to fix any of this, but I would encourage you to fix it in user land at the moment (a small re-organization), but I'll see if I can get some failing test cases added and maybe someone could look deeper
projectUpdated(projectId: "someProjectId")
where only events with an id matching the subscribed projectId are returned to the subscriber.
But PartialFutureValue
won’t compile
val Food: Field[Context, Val] = {
Field(
name = “Food",
fieldType = OptionType(StringType),
resolve = _ => PartialFutureValue(Future.successful(PartialValue(Some("Waffles"), Vector(new Exception("Pancakes”)))))
)
}
There’s type mismatch, it’s looking for sangria.schema.Action[Any,Option[String]]
hey guys, need your advice:
switched sangria to 2.1.0
PR looks like this
"org.sangria-graphql" %% "sangria" % "1.4.2" => "2.1.0",
"org.sangria-graphql" %% "sangria-relay" % "1.4.2" => "2.1.0",
"org.sangria-graphql" %% "sangria-circe" % "1.2.1" => "1.3.1",
"org.sangria-graphql" %% "sangria-slowlog" % "0.1.8" => "2.0.1",
nothing else was changed.
And faced a memory leak 6 hours after the update (maybe related to traffic).
Maybe someone also faced mem leak at sangria 2.10 ?
Hi, I have a question about deferred resolution. Is there a way to run multiple deferred resolutions one by one? What I want to achieve in resolver function is:
for {
idsA <- deferredFetchA
idsB <- deferredFetchB
selectedItems <- do sth with idsA and idsB
} yield anotherDeferredFetch(selectedItems)
I was trying to play with DeferredValue(...)
but with no success
Deferred
.DeferredResolver
, you have access to all your accumulated Deferred
instances. Based on this input, you can choose how to resolve them. And this can be one by one if you want to.
Fetcher
, you might be interested in this change that allows setting the max concurrency: https://github.com/sangria-graphql/sangria/pull/454/files