Skip to content

Commit 225bf7f

Browse files
author
Federico Bevione
committed
parsing fix
1 parent cd680d5 commit 225bf7f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

client/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func parseResponse(body []byte, httpCode int, result interface{}) error {
136136
Code: httpCode,
137137
Message: fmt.Sprintf("Response body %s", string(body)),
138138
}
139-
} else if err := unmarshal(body, &result); err != nil {
139+
} else if err := unmarshal(body, result); err != nil {
140140
if gqlErr, ok := err.(*GqlErrorList); ok {
141141
errResponse.GqlErrors = &gqlErr.Errors
142142
} else {
@@ -159,7 +159,7 @@ type response struct {
159159

160160
func unmarshal(data []byte, res interface{}) error {
161161
resp := response{}
162-
if err := graphqljson.UnmarshalData(data, &resp); err != nil {
162+
if err := json.Unmarshal(data, &resp); err != nil {
163163
return xerrors.Errorf("failed to decode data %s: %w", string(data), err)
164164
}
165165

@@ -172,7 +172,7 @@ func unmarshal(data []byte, res interface{}) error {
172172
return errors
173173
}
174174

175-
if err := json.Unmarshal(resp.Data, &res); err != nil {
175+
if err := graphqljson.UnmarshalData(resp.Data, res); err != nil {
176176
return xerrors.Errorf("failed to decode data into response %s: %w", string(data), err)
177177
}
178178

client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestUnmarshal(t *testing.T) {
145145
t.Run("bad data format", func(t *testing.T) {
146146
r := &fakeRes{}
147147
err := unmarshal([]byte(withBadDataFormat), r)
148-
require.EqualError(t, err, "failed to decode data into response {\"data\": \"notAndObject\"}: json: cannot unmarshal string into Go value of type client.fakeRes")
148+
require.EqualError(t, err, "failed to decode data into response {\"data\": \"notAndObject\"}: : : : json: cannot unmarshal string into Go value of type client.fakeRes")
149149
})
150150

151151
t.Run("bad data format", func(t *testing.T) {

0 commit comments

Comments
 (0)