我试图再次执行在Sangria中定义的本地graphql服务器的查询。我有这样的突变定义:
val Mutation = ObjectType(
"Mutation", fields[DAO, Unit](
Field("addMovie", IntType,
arguments = Title :: Genre :: IMDBLink :: Nil,
resolve = ctx => ctx.ctx.addMovie(ctx.arg(Title) , ctx.arg(Genre), ctx.arg(IMDBLink)))
)但是,当我试图对它执行查询时,我收到了这个查询的语法错误:mutation addMovieQuery {addMovie(title: "asd", genre: "asasdqw", IMDBLink: "$imdbLink") {}}
或在运行带有id的查询时,在括号内运行Field 'addMovie' of type 'Int' must not have a sub selection
发布于 2018-10-21 13:38:14
如果字段返回一个Int或任何其他标量,正如错误指出的那样,该字段不能有子选择。标量和枚举是查询的“牵头节点”,因此不能在它们上选择其他字段。试一试:
mutation addMovieQuery {
addMovie(title: "asd", genre: "asasdqw", IMDBLink: "$imdbLink")
}https://stackoverflow.com/questions/52915769
复制相似问题