diff --git a/handler/graphiql.go b/handler/graphiql.go
deleted file mode 100644
index 9531f85c08e..00000000000
--- a/handler/graphiql.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package handler
-
-import (
- "html/template"
- "net/http"
-)
-
-var page = template.Must(template.New("graphiql").Parse(`
-
-
-
- {{.title}}
-
-
-
-
-
-
-
- Loading...
-
-
-
-`))
-
-func GraphiQL(title string, endpoint string) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- err := page.Execute(w, map[string]string{
- "title": title,
- "endpoint": endpoint,
- })
- if err != nil {
- panic(err)
- }
- }
-}
diff --git a/handler/graphql.go b/handler/graphql.go
index 4214e901695..0e7716b8720 100644
--- a/handler/graphql.go
+++ b/handler/graphql.go
@@ -41,7 +41,7 @@ func GraphQL(exec graphql.ExecutableSchema) http.HandlerFunc {
}
} else {
if err := json.NewDecoder(r.Body).Decode(¶ms); err != nil {
- sendErrorf(w, http.StatusBadRequest, "json body could not be decoded")
+ sendErrorf(w, http.StatusBadRequest, "json body could not be decoded: "+err.Error())
return
}
}
diff --git a/handler/playground.go b/handler/playground.go
new file mode 100644
index 00000000000..44533590483
--- /dev/null
+++ b/handler/playground.go
@@ -0,0 +1,51 @@
+package handler
+
+import (
+ "html/template"
+ "net/http"
+)
+
+var page = template.Must(template.New("graphiql").Parse(`
+
+
+
+
+
+
+
+
+ {{.title}}
+
+
+
+
+
+
+
+`))
+
+func Playground(title string, endpoint string) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ err := page.Execute(w, map[string]string{
+ "title": title,
+ "endpoint": endpoint,
+ "version": "1.4.3",
+ })
+ if err != nil {
+ panic(err)
+ }
+ }
+}
diff --git a/handler/websocket.go b/handler/websocket.go
index 05cde5e1566..c11883f52d9 100644
--- a/handler/websocket.go
+++ b/handler/websocket.go
@@ -19,7 +19,7 @@ import (
const (
connectionInitMsg = "connection_init" // Client -> Server
connectionTerminateMsg = "connection_terminate" // Client -> Server
- startMsg = "run" // Client -> Server
+ startMsg = "start" // Client -> Server
stopMsg = "stop" // Client -> Server
connectionAckMsg = "connection_ack" // Server -> Client
connectionErrorMsg = "connection_error" // Server -> Client
@@ -52,7 +52,9 @@ type wsConnection struct {
}
func connectWs(exec graphql.ExecutableSchema, w http.ResponseWriter, r *http.Request) {
- ws, err := upgrader.Upgrade(w, r, nil)
+ ws, err := upgrader.Upgrade(w, r, http.Header{
+ "Sec-Websocket-Protocol": []string{"graphql-ws"},
+ })
if err != nil {
log.Printf("unable to upgrade connection to websocket %s: ", err.Error())
sendErrorf(w, http.StatusBadRequest, "unable to upgrade")