Batch Query implementation

46 views
Skip to first unread message

Mandeep Shrestha

unread,
Aug 30, 2018, 1:47:34 AM8/30/18
to sangria-graphql
First of all thanks Sangria for making it easier to get into graphql, it has helped a lot.

I have been trying to implement Sangria Batch query, but running into some issues. I had asked similar questions, on the gitter chat, but this seems to be a better way to explain the problem, I am facing.

Took a fork of, Sangria Playground, and added batch query features as explained in the "Learn" page

https://github.com/mandeeeep/sangria-playground/tree/develop

Added a new controller with batch specific updates,
https://github.com/mandeeeep/sangria-playground/blob/develop/app/controllers/BatchApplication.scala

Schema objects with directives, 
https://github.com/mandeeeep/sangria-playground/blob/develop/app/models/SchemaDefinition.scala

val StarWarsBatchSchema = Schema(Query, directives = BuiltinDirectives :+ BatchExecutor.ExportDirective)

Now, on the appropriate route,
/graphql-batch

Request:
{
"operationNames":["SomeQuery","SomeQueryTwo"],
"query":"query SomeQuery{human_1000:human(id: \"1000\"){id,name}} query SomeQueryTwo{human_1001:human(id: \"1001\"){id,name}}"
}

Response:
{
   
"data": {
       
"human_1001": {
           
"id": "1001",
           
"name": "Darth Vader"
       
}
   
}
}

Is the query sent not batch query specific, or am I doing something wrong with the batch features implementation.
Any tips would help.

Thanks,
Reply all
Reply to author
Forward
0 new messages