File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 4
4
"encoding/json"
5
5
"github.com/99designs/gqlgen/graphql"
6
6
"reflect"
7
+ "bytes"
7
8
)
8
9
9
10
type GraphqlRawParamsCollection []* graphql.RawParams
@@ -19,17 +20,24 @@ func (c GraphqlRawParamsCollection) Len() int {
19
20
20
21
// UnmarshalJSON could unmarshal slice or single query
21
22
func (c * GraphqlRawParamsCollection ) UnmarshalJSON (b []byte ) error {
22
- err := json .Unmarshal (b , (* []* graphql.RawParams )(c ))
23
- if err == nil {
23
+ r := bytes .NewReader (b )
24
+
25
+ d := json .NewDecoder (r )
26
+ d .UseNumber ()
27
+
28
+ if err := d .Decode ((* []* graphql.RawParams )(c )); err == nil {
24
29
return nil
25
30
}
26
31
32
+ if _ , err := r .Seek (0 , 0 ); err != nil {
33
+ return err
34
+ }
35
+
27
36
var n graphql.RawParams
28
- err = json .Unmarshal (b , & n )
29
- if err == nil {
30
- * c = []* graphql.RawParams {& n }
37
+ if err := d .Decode (& n ); err != nil {
31
38
return nil
32
39
}
33
40
41
+ * c = []* graphql.RawParams {& n }
34
42
return nil
35
43
}
You can’t perform that action at this time.
0 commit comments