We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ebb1e19 commit ad3c589Copy full SHA for ad3c589
boilergql/scaler_json.go
@@ -0,0 +1,26 @@
1
+package boilergql
2
+
3
+import (
4
+ "encoding/json"
5
+ "fmt"
6
+ "io"
7
+)
8
9
+type JSON map[string]interface{}
10
11
+func (b *JSON) UnmarshalGQL(v interface{}) error {
12
+ bytes, err := json.Marshal(v)
13
+ if err != nil {
14
+ return err
15
+ }
16
+ return json.Unmarshal(bytes, b)
17
+}
18
19
+func (b JSON) MarshalGQL(w io.Writer) {
20
+ bytes, err := json.Marshal(b)
21
22
+ fmt.Fprintf(w, `"%s"`, err.Error())
23
+ return
24
25
+ _, _ = w.Write(bytes)
26
0 commit comments