Regarding the above mentioned bug involving Argument()
I'm think that this is a Sangria-related issue, as opposed to simply a Scala issue.
When I get rid of all the Sangria code (instead just constructing a list containing some case class), the null
disappears.
import org.scalatest.funsuite.AnyFunSuite
import sangria.schema.{Argument, EnumType, EnumValue, OptionInputType}
object SchemaInitTest {
sealed trait Episode
object Episode {
final case object EPISODE_1 extends Episode
}
case class Test(string: String)
val EpisodeEnum = EnumType(
"Episode",
Some("One of the films in the Star Wars Trilogy"),
List(EnumValue("NEWHOPE", value = Episode.EPISODE_1, description = Some("Released in 1977.")))
)
object EpisodeArgs {
// val arg = Test("test") // test passes when we don't use Sangria code at all!
val arg = Argument("activityRef", OptionInputType(EpisodeEnum)) // but this fails!
}
val episodeArgs = EpisodeArgs.arg :: Nil
}
class SchemaInitTest extends AnyFunSuite {
import SchemaInitTest._
test("A list of args should be the same, regardless of where it is initialised") {
// assert(episodeArgs == EpisodeArgs.arg :: Nil) // this passes for some reason!
assert(EpisodeArgs.arg :: Nil == episodeArgs) // but this fails!
}
}
Another thing I noticed is that changing the order we compare for equality in the assert also makes the problem go away.
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]]
@GraphQLField
which takes a sealed trait as a Parameter. Now I want to create an InputObject which has every implementation of the sealed trait as a property and then create an alias which fails if not exactly one property is Some
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 ?