简体   繁体   中英

sangria query returning IntType

I'm trying to perform query agains my local graphql server defined in Sangria. I have mutation defined like this:

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)))
)

But when I'm trying to perform query against it, I'm receiving either Syntax error with this query: mutation addMovieQuery {addMovie(title: "asd", genre: "asasdqw", IMDBLink: "$imdbLink") {}}

Or Field 'addMovie' of type 'Int' must not have a sub selection when running query with id inside brackets

If a field returns an Int or any other scalar, as the error says that field cannot have a subselection. Scalars and enums are the "lead nodes" of a query, so you cannot select additional fields on them. Try this instead:

mutation addMovieQuery {
  addMovie(title: "asd", genre: "asasdqw", IMDBLink: "$imdbLink")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM