Skip to content

Upgrade GraphiQL to 0.11.11 #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions graphiql.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"github.com/graphql-go/graphql"
)

// page is the page data structure of the rendered GraphiQL page
type graphiqlPage struct {
// graphiqlData is the page data structure of the rendered GraphiQL page
type graphiqlData struct {
GraphiqlVersion string
QueryString string
ResultString string
VariablesString string
OperationName string
ResultString string
}

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

p := graphiqlPage{
d := graphiqlData{
GraphiqlVersion: graphiqlVersion,
QueryString: params.RequestString,
ResultString: resString,
VariablesString: varsString,
OperationName: params.OperationName,
}

err = t.ExecuteTemplate(w, "index", p)
err = t.ExecuteTemplate(w, "index", d)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}

return
}

// graphiqlVersion is the current version of GraphiQL
const graphiqlVersion = "0.11.10"
const graphiqlVersion = "0.11.11"

// tmpl is the page template to render GraphiQL
const graphiqlTemplate = `
Expand All @@ -85,21 +85,27 @@ add "&raw" to the end of the URL within a browser.
<meta charset="utf-8" />
<title>GraphiQL</title>
<meta name="robots" content="noindex" />
<meta name="referrer" content="origin">
<style>
html, body {
body {
height: 100%;
margin: 0;
overflow: hidden;
width: 100%;
}
#graphiql {
height: 100vh;
}
</style>
<link href="//cdn.jsdelivr.net/npm/graphiql@{{ .GraphiqlVersion }}/graphiql.css" rel="stylesheet" />
<script src="//cdn.jsdelivr.net/es6-promise/4.0.5/es6-promise.auto.min.js"></script>
<script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>
<script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>
<script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/graphiql@{{ .GraphiqlVersion }}/graphiql.min.js"></script>
</head>
<body>
<div id="graphiql">Loading...</div>
<script>
// Collect the URL parameters
var parameters = {};
Expand Down Expand Up @@ -190,7 +196,7 @@ add "&raw" to the end of the URL within a browser.
variables: {{ .VariablesString }},
operationName: {{ .OperationName }},
}),
document.body
document.getElementById('graphiql')
);
</script>
</body>
Expand Down