aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/handler/playground.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-14 12:40:31 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-14 12:41:59 +0200
commitb478cd1bcb4756b20f7f4b15fcf81f23e1a60a02 (patch)
tree8ce232dcab3dd00708f8ba66c334472457e5980d /vendor/github.com/99designs/gqlgen/handler/playground.go
parenta3fc9abb921f5ce7084d6ab7473442d0b72b1d78 (diff)
downloadgit-bug-b478cd1bcb4756b20f7f4b15fcf81f23e1a60a02.tar.gz
graphql: update gqlgen to 0.5.1
fix #6
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/handler/playground.go')
-rw-r--r--vendor/github.com/99designs/gqlgen/handler/playground.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/99designs/gqlgen/handler/playground.go b/vendor/github.com/99designs/gqlgen/handler/playground.go
new file mode 100644
index 00000000..d0ada8ca
--- /dev/null
+++ b/vendor/github.com/99designs/gqlgen/handler/playground.go
@@ -0,0 +1,54 @@
+package handler
+
+import (
+ "html/template"
+ "net/http"
+)
+
+var page = template.Must(template.New("graphiql").Parse(`<!DOCTYPE html>
+<html>
+<head>
+ <meta charset=utf-8/>
+ <meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
+ <link rel="shortcut icon" href="https://graphcool-playground.netlify.com/favicon.png">
+ <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/graphql-playground-react@{{ .version }}/build/static/css/index.css"/>
+ <link rel="shortcut icon" href="//cdn.jsdelivr.net/npm/graphql-playground-react@{{ .version }}/build/favicon.png"/>
+ <script src="//cdn.jsdelivr.net/npm/graphql-playground-react@{{ .version }}/build/static/js/middleware.js"></script>
+ <title>{{.title}}</title>
+</head>
+<body>
+<style type="text/css">
+ html { font-family: "Open Sans", sans-serif; overflow: hidden; }
+ body { margin: 0; background: #172a3a; }
+</style>
+<div id="root"/>
+<script type="text/javascript">
+ window.addEventListener('load', function (event) {
+ const root = document.getElementById('root');
+ root.classList.add('playgroundIn');
+ const wsProto = location.protocol == 'https:' ? 'wss:' : 'ws:'
+ GraphQLPlayground.init(root, {
+ endpoint: location.protocol + '//' + location.host + '{{.endpoint}}',
+ subscriptionsEndpoint: wsProto + '//' + location.host + '{{.endpoint }}',
+ settings: {
+ 'request.credentials': 'same-origin'
+ }
+ })
+ })
+</script>
+</body>
+</html>
+`))
+
+func Playground(title string, endpoint string) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ err := page.Execute(w, map[string]string{
+ "title": title,
+ "endpoint": endpoint,
+ "version": "1.6.2",
+ })
+ if err != nil {
+ panic(err)
+ }
+ }
+}