From c2b8eabb4e863ffc1c81a49e711c7eb4689b6bea Mon Sep 17 00:00:00 2001 From: yk-eukarya <81808708+yk-eukarya@users.noreply.github.com> Date: Tue, 20 Dec 2022 22:54:31 +0300 Subject: [PATCH] feat: support Altair playground (#2437) * feat: support Altair playground * fix method params --- graphql/playground/altair_playground.go | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 graphql/playground/altair_playground.go diff --git a/graphql/playground/altair_playground.go b/graphql/playground/altair_playground.go new file mode 100644 index 00000000000..6928828cdf0 --- /dev/null +++ b/graphql/playground/altair_playground.go @@ -0,0 +1,84 @@ +package playground + +import ( + "html/template" + "net/http" +) + +var altairPage = template.Must(template.New("altair").Parse(` + + + + + {{.title}} + + + + + + + + + +
+
+
+ Altair +
+
+ + + +
+
+
+
+ + + + + + + + +`)) + +// AltairHandler responsible for setting up the altair playground +func AltairHandler(title, endpoint string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + err := altairPage.Execute(w, map[string]interface{}{ + "title": title, + "endpoint": endpoint, + "endpointIsAbsolute": endpointHasScheme(endpoint), + "subscriptionEndpoint": getSubscriptionEndpoint(endpoint), + "version": "5.0.5", + "cssSRI": "sha256-kZ35e5mdMYN5ALEbnsrA2CLn85Oe4hBodfsih9BqNxs=", + "mainSRI": "sha256-nWdVTcGTlBDV1L04UQnqod+AJedzBCnKHv6Ct65liHE=", + "polyfillsSRI": "sha256-1aVEg2sROcCQ/RxU3AlcPaRZhZdIWA92q2M+mdd/R4c=", + "runtimeSRI": "sha256-cK2XhXqQr0WS1Z5eKNdac0rJxTD6miC3ubd+aEVMQDk=", + }) + if err != nil { + panic(err) + } + } +}