File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed
Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 88 [metosin/ring-http-response " 0.9.0" ]
99 [ring/ring-core " 1.6.0" ]
1010 [threatgrid/ring-graphiql " 0.1.1" ]
11- [threatgrid/ring-graphql-voyager " 0.1.2" ]]
11+ [threatgrid/ring-graphql-voyager " 0.1.2" ]
12+ [viebel/ring-graphql-playground " 0.1.1" ]]
1213 :profiles {:test {:dependencies [[ring/ring-mock " 0.3.0" ]]}})
Original file line number Diff line number Diff line change 9494
9595(defn voyager
9696 " Returns a Ring handler which can be used to serve GraphQL Voyager"
97- ([] (graphiql {}))
97+ ([] (voyager {}))
9898 ([options]
9999 (serve-ui {:path " /voyager"
100100 :root " graphql-voyager" }
107107 (wrap-ui handler voyager))
108108 ([handler options]
109109 (wrap-ui handler voyager options)))
110+
111+ ; ;-------- GraphQL Playground
112+
113+ (defn playground
114+ " Returns a Ring handler which can be used to serve GraphQL Playground https://github.com/prisma-labs/graphql-playground#as-html-page"
115+ ([] (playground {}))
116+ ([options]
117+ (serve-ui {:path " /playground"
118+ :root " graphql-playground" }
119+ options
120+ " GRAPHQL_PLAYGROUND_CONF" )))
121+
122+ (defn wrap-playground
123+ " Middleware to serve GraphQL Playground."
124+ ([handler]
125+ (wrap-ui handler playground))
126+ ([handler options]
127+ (wrap-ui handler playground options)))
Original file line number Diff line number Diff line change 9999 :endpoint " ctia/graphql" }))]
100100 (is (html? (http-get handler " /voyager/index.html" )))
101101 (is (nil? (http-get handler " unknown" )))))
102+
103+ (deftest playground-test
104+ (let [handler (sut/playground {:path " /playground"
105+ :endpoint " ctia/graphql" })]
106+ (testing " index.html"
107+ (is (redirect? (http-get handler " /playground" )))
108+ (is (html? (http-get handler " /playground/index.html" ))))
109+ (testing " conf.js"
110+ (let [conf-response (http-get handler " /playground/conf.js" )]
111+ (is (javascript? conf-response))
112+ (is (= {:endpoint " ctia/graphql" }
113+ (read-js (:body conf-response)
114+ " GRAPHQL_PLAYGROUND_CONF" )))))))
115+
116+ (deftest wrap-playground-test
117+ (let [handler (-> (constantly nil )
118+ (sut/wrap-graphiql {:path " /playground"
119+ :endpoint " ctia/graphql" }))]
120+ (is (html? (http-get handler " /playground/index.html" )))
121+ (is (nil? (http-get handler " unknown" )))))
You can’t perform that action at this time.
0 commit comments