Skip to content

Commit 36f8ba8

Browse files
committed
fix introspection of default value
Fixes graph-gophers#65
1 parent e06f585 commit 36f8ba8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

introspection/introspection.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package introspection
22

33
import (
4-
"fmt"
4+
"encoding/json"
55
"sort"
66

77
"github.com/neelance/graphql-go/internal/common"
@@ -259,7 +259,11 @@ func (r *InputValue) DefaultValue() *string {
259259
if r.value.Default == nil {
260260
return nil
261261
}
262-
s := fmt.Sprint(r.value.Default)
262+
b, err := json.Marshal(r.value.Default)
263+
if err != nil {
264+
panic("could not marshal default value: " + err.Error())
265+
}
266+
s := string(b)
263267
return &s
264268
}
265269

0 commit comments

Comments
 (0)