0

I could use some help figuring out how to handle a batch request in gqlgen. The request is coming from an apollo client using apollo's query batching, so the request body is a json array like so:

[
   {
      "operationName":"UpdateDocument",
      "variables":{
         "input":{
            "document_id":"123"
         }
      },
      "query":"mutation UpdateDocument($input: UpdateDocumentInput!) { 
                updateDocument(input: $input) { 
                    document { 
                        id 
                        __typename
                    } 
                    __typename 
                }
               }"
   },
   {
      "operationName":"UpdateDocument",
      "variables":{
         "input":{
            "document_id":"124"
         }
      },
      "query":"mutation UpdateDocument($input: UpdateDocumentInput!) { 
                updateDocument(input: $input) {
                    document { 
                        id 
                        __typename
                    } 
                    __typename
                }
               }"
   }
]

and in the gqlgen side, I have a resolver that handles a single UpdateDocument query.

When I am making the batch request I get an error: "json body could not be decoded: json: cannot unmarshal array into Go value of type graphql.RawParams"

Alex K
  • 1
  • 2

0 Answers0