我定义了两种类型的食物和类型,其中1种类型有N种食物,我使用lazy
使recursive types起作用。
lazy val FoodType: ObjectType[Unit, FoodData] = ObjectType(
"Food",
"The details of a food",
interfaces[Unit, FoodData](nodeInterface),
idFields[FoodData] ++
fields[Unit, FoodData](
Field("name", StringType, resolve = _.value.name),
Field("image", OptionType(StringType),
description = Some("Image CDN URL"),
resolve = _.value.image),
Field("type", TypeType, resolve = c => types.defer(c.value.type_id))
))
lazy val TypeType: ObjectType[Unit, TypeData] = ObjectType(
"Type",
"The details of a type",
interfaces[Unit, TypeData](nodeInterface),
idFields[TypeData] ++
fields[Unit, TypeData](
Field("name", StringType, resolve = _.value.name),
Field("foods", ListType(FoodType), resolve = c => foods.deferRelSeq(byType, c.value.id))
))
但我收到以下错误。
Uncaught error from thread [application-akka.actor.default-dispatcher-32] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
java.lang.StackOverflowError
at java.util.regex.Pattern$5.isSatisfiedBy(Pattern.java:5251)
at java.util.regex.Pattern$5.isSatisfiedBy(Pattern.java:5251)
at java.util.regex.Pattern$5.isSatisfiedBy(Pattern.java:5251)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3776)
at java.util.regex.Pattern$Curly.match0(Pattern.java:4250)
at java.util.regex.Pattern$Curly.match(Pattern.java:4234)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)
at java.util.regex.Pattern$Begin.match(Pattern.java:3525)
at java.util.regex.Matcher.match(Matcher.java:1270)
at java.util.regex.Matcher.matches(Matcher.java:604)
at sangria.schema.Named$.checkName(Schema.scala:115)
at sangria.schema.Field$.apply(Schema.scala:339)
at sangria.relay.Node$.globalIdField(Node.scala:67)
at models.SchemaDefinition$.idFields(SchemaDefinition.scala:23)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:43)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)
at models.SchemaDefinition$.FoodType$lzycompute(SchemaDefinition.scala:49)
at models.SchemaDefinition$.FoodType(SchemaDefinition.scala:39)
at models.SchemaDefinition$.TypeType$lzycompute(SchemaDefinition.scala:59)
at models.SchemaDefinition$.TypeType(SchemaDefinition.scala:52)