Skip to content

Commit ce8e677

Browse files
author
Tobias Fuhrimann
committed
Account for empty request
1 parent 70ee617 commit ce8e677

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

graphiql.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ func renderGraphiQL(w http.ResponseWriter, params graphql.Params) {
3838
}
3939

4040
// Create result string
41-
result, err := json.MarshalIndent(graphql.Do(params), "", " ")
42-
if err != nil {
43-
http.Error(w, err.Error(), http.StatusInternalServerError)
44-
return
41+
var resString string
42+
if params.RequestString == "" {
43+
resString = ""
44+
} else {
45+
result, err := json.MarshalIndent(graphql.Do(params), "", " ")
46+
if err != nil {
47+
http.Error(w, err.Error(), http.StatusInternalServerError)
48+
return
49+
}
50+
resString = string(result)
4551
}
46-
resString := string(result)
4752

4853
p := graphiqlPage{
4954
GraphiqlVersion: graphiqlVersion,

0 commit comments

Comments
 (0)