Updated gql.go to use requesturi

graph-rework
noah metz 2023-06-18 21:34:02 -06:00
parent 001614189f
commit 97e2e50fd5
1 changed files with 67 additions and 67 deletions

@ -19,7 +19,8 @@ import (
)
func GraphiQLHandler() func(http.ResponseWriter, *http.Request) {
graphiql_string := `
return func(w http.ResponseWriter, r * http.Request) {
graphiql_string := fmt.Sprintf(`
<!--
* Copyright (c) 2021 GraphQL Contributors
* All rights reserved.
@ -33,9 +34,9 @@ func GraphiQLHandler() func(http.ResponseWriter, *http.Request) {
<title>GraphiQL</title>
<style>
body {
height: 100%;
height: 100%%;
margin: 0;
width: 100%;
width: 100%%;
overflow: hidden;
}
@ -79,7 +80,7 @@ func GraphiQLHandler() func(http.ResponseWriter, *http.Request) {
root.render(
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
url: 'http://localhost:8080/gql',
url: '%s/gql',
}),
defaultEditorToolsVisibility: true,
}),
@ -87,9 +88,8 @@ func GraphiQLHandler() func(http.ResponseWriter, *http.Request) {
</script>
</body>
</html>
`
`, r.RequestURI)
return func(w http.ResponseWriter, r * http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
io.WriteString(w, graphiql_string)