This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Port 3030 hardcoded in /graphiql/bundle.js #226
Comments
I found that the Graphiql side had a few problems - it returns junk on larger schemas. However, if you ignore that and use an Insomnia client pointed at the standard web entry route, you get the same functionality. |
I came up with a wrapper to workaround the issue: package graphiql
import (
"bytes"
"github.com/samsarahq/thunder/graphql/graphiql"
"net/http"
"net/http/httptest"
)
func NewHandler(addr string) http.Handler {
h := http.StripPrefix("/graphiql/", graphiql.Handler())
rw := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/graphiql/bundle.js", nil)
if err != nil {
panic(err)
}
h.ServeHTTP(rw, req)
bundleJS := bytes.Replace(rw.Body.Bytes(), []byte("ws://localhost:3030/graphql"), []byte("ws://"+addr+"/graphql"), 1)
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if req.URL.Path == "/graphiql/bundle.js" {
rw.Header().Add("Content-Type", "application/javascript")
_, err = rw.Write(bundleJS)
if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
}
return
}
h.ServeHTTP(rw, req)
})
} |
Just hit this too, I'm guessing bundle.js is statically baked into this file? https://github.com/samsarahq/thunder/blob/master/graphql/graphiql/statik/statik.go |
using thunder in gin:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Using browser tools you can see that /graphiql/bundle.js has port 3030 hardcoded in
new u.Connection("ws://localhost:3030/graphql")
.The readme doesn't specify this and it took me a while to figure out why graphiql's auto-complete wasn't working as I was using a port other than 3030 for my HTTP server.
The text was updated successfully, but these errors were encountered: