Implement loading query from URL in GQL playground #66

Merged
nikugogoi merged 2 commits from ng-gql-url-query into console 2022-12-12 08:21:53 +00:00
Showing only changes of commit e06686e0ba - Show all commits

View File

@ -25,7 +25,7 @@ func errorJSON(msg string) []byte {
return buf.Bytes()
}
func PlaygroundHandler(apiUrl string) http.HandlerFunc {
func PlaygroundHandler(apiURL string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
respond(w, errorJSON("only GET requests are supported"), http.StatusMethodNotAllowed)
@ -33,7 +33,7 @@ func PlaygroundHandler(apiUrl string) http.HandlerFunc {
}
w.Header().Set("Content-Type", "text/html")
err := page.Execute(w, map[string]interface{}{
"apiUrl": apiUrl,
"apiUrl": apiURL,
})
if err != nil {
panic(err)
@ -159,7 +159,7 @@ var page = template.Must(template.New("graphiql").Parse(`
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
// subscriptionUrl: 'ws://localhost:8081/subscriptions',
url: {{.apiUrl}}
url: {{.apiURL}}
}),
query: parameters.query,
variables: parameters.variables,