@@ -187,12 +187,14 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab
187187func (c * Client ) unmarshalGraphQLResult (responseBody io.Reader ) (graphQLStdOut , error ) {
188188 // Try unmarshal into default format
189189 var output graphQLStdOut
190- err := json .NewDecoder (responseBody ).Decode (& output )
190+ buf := & bytes.Buffer {}
191+ tee := io .TeeReader (responseBody , buf )
192+ err := json .NewDecoder (tee ).Decode (& output )
191193 if err != nil {
192194 // TODO: Consider including response body in returned error, if deemed helpful.
193195 // TODO: Add Warning message somehow that default is not working
194196 var extFormat graphQLExtOut
195- err := json .NewDecoder (responseBody ).Decode (& extFormat )
197+ err := json .NewDecoder (buf ).Decode (& extFormat )
196198 if err != nil {
197199 // Output too weird or query error
198200 return output , err
@@ -238,7 +240,11 @@ func (e errors) Error() string {
238240 if len (e ) == 0 {
239241 return ""
240242 }
241- return e [0 ].Message
243+ var stringOutput = make ([]string , len (e ))
244+ for i := range e {
245+ stringOutput [i ] = fmt .Sprintf ("%v" , e [i ].Message )
246+ }
247+ return strings .Join (stringOutput , "," )
242248}
243249
244250// errorsExt represents the "errors" array in a response from a GraphQL server.
@@ -263,7 +269,7 @@ func (e errorsExt) Error() string {
263269 for i := range e [0 ].Message {
264270 stringOutput [i ] = fmt .Sprintf ("%v" , e [0 ].Message [i ])
265271 }
266- return strings .Join (stringOutput , "; " )
272+ return strings .Join (stringOutput , ", " )
267273}
268274
269275// ConvertToStandard translates extended error structs into structs matching the GraphQL Standard
@@ -272,7 +278,7 @@ func (e errorsExt) ConvertToStandard() errors {
272278 return nil
273279 }
274280
275- standardError := make (errors , len (e ))
281+ standardError := make (errors , len (e [ 0 ]. Message ))
276282 for i := range e [0 ].Message {
277283 standardError [i ] = errorStruct {
278284 Message : fmt .Sprintf ("%v" , e [0 ].Message [i ]),
0 commit comments