Skip to content

Commit df71746

Browse files
authored
Merge pull request #35 from mastertinner/master
Upgrade GraphiQL to 0.11.11
2 parents cc93f95 + 8319d29 commit df71746

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

graphiql.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
"github.com/graphql-go/graphql"
99
)
1010

11-
// page is the page data structure of the rendered GraphiQL page
12-
type graphiqlPage struct {
11+
// graphiqlData is the page data structure of the rendered GraphiQL page
12+
type graphiqlData struct {
1313
GraphiqlVersion string
1414
QueryString string
15-
ResultString string
1615
VariablesString string
1716
OperationName string
17+
ResultString string
1818
}
1919

2020
// renderGraphiQL renders the GraphiQL GUI
@@ -50,23 +50,23 @@ func renderGraphiQL(w http.ResponseWriter, params graphql.Params) {
5050
resString = string(result)
5151
}
5252

53-
p := graphiqlPage{
53+
d := graphiqlData{
5454
GraphiqlVersion: graphiqlVersion,
5555
QueryString: params.RequestString,
5656
ResultString: resString,
5757
VariablesString: varsString,
5858
OperationName: params.OperationName,
5959
}
60-
61-
err = t.ExecuteTemplate(w, "index", p)
60+
err = t.ExecuteTemplate(w, "index", d)
6261
if err != nil {
6362
http.Error(w, err.Error(), http.StatusInternalServerError)
6463
}
64+
6565
return
6666
}
6767

6868
// graphiqlVersion is the current version of GraphiQL
69-
const graphiqlVersion = "0.11.10"
69+
const graphiqlVersion = "0.11.11"
7070

7171
// tmpl is the page template to render GraphiQL
7272
const graphiqlTemplate = `
@@ -85,21 +85,27 @@ add "&raw" to the end of the URL within a browser.
8585
<meta charset="utf-8" />
8686
<title>GraphiQL</title>
8787
<meta name="robots" content="noindex" />
88+
<meta name="referrer" content="origin">
8889
<style>
89-
html, body {
90+
body {
9091
height: 100%;
9192
margin: 0;
9293
overflow: hidden;
9394
width: 100%;
9495
}
96+
#graphiql {
97+
height: 100vh;
98+
}
9599
</style>
96100
<link href="//cdn.jsdelivr.net/npm/graphiql@{{ .GraphiqlVersion }}/graphiql.css" rel="stylesheet" />
101+
<script src="//cdn.jsdelivr.net/es6-promise/4.0.5/es6-promise.auto.min.js"></script>
97102
<script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>
98103
<script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>
99104
<script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>
100105
<script src="//cdn.jsdelivr.net/npm/graphiql@{{ .GraphiqlVersion }}/graphiql.min.js"></script>
101106
</head>
102107
<body>
108+
<div id="graphiql">Loading...</div>
103109
<script>
104110
// Collect the URL parameters
105111
var parameters = {};
@@ -190,7 +196,7 @@ add "&raw" to the end of the URL within a browser.
190196
variables: {{ .VariablesString }},
191197
operationName: {{ .OperationName }},
192198
}),
193-
document.body
199+
document.getElementById('graphiql')
194200
);
195201
</script>
196202
</body>

0 commit comments

Comments
 (0)