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,23 +19,24 @@ 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.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
-->
<!DOCTYPE html>
<html lang="en">
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>GraphiQL</title>
<style>
body {
height: 100%;
height: 100%%;
margin: 0;
width: 100%;
width: 100%%;
overflow: hidden;
}
@ -79,17 +80,16 @@ 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,
}),
);
</script>
</body>
</html>
`
</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)