This is a go binding of Prisma's GraphQL PlayGround with setting configuration support.
I like using GraphQL, especially, GQLGen is awesome. However, the playground provided by GQLGen has some small-issues. i.e. I cam't set configuration to handle CSRF. So, I decided to re-invent the wheel that can set the configuration.
package main
import "log"
import (
"github.com/hiroaki-yamamoto/gqlplay"
"github.com/go-chi/chi"
)
func main() {
player := gqlplay.Ground(gqlplay.Option{
Settings: goplay.Settings{
PollingEnabled: false,
Credentials: SameOriginCredentials,
HideTraceResponse: true,
},
Headers: map[string]string{
"X-CSRF-TOKEN": "blablablabla...",
}
})
r := chi.NewRouter()
//...Other code...
r.Get("/playground", player)
svr := http.Server{
Addr: fmt.Sprintf("%s:%d", setting.Host, setting.Port),
Handler: chi.ServerBaseContext(ctx, r),
}
log.Fatal(svr.ListenAndServe())
}
It must be easy.
Sending Issues / PR is welcome. PR is more appreciated. However, if you changed the behavior, the corresponding changes, additions, and/or deletions of the test code is mandatory, if you changed only the doc, the test code is not needed.