-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathserver.clj
27 lines (21 loc) · 885 Bytes
/
server.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns nl.openweb.graphql-endpoint.server
(:require [com.stuartsierra.component :as component]
[com.walmartlabs.lacinia.pedestal :as lp]
[io.pedestal.http :as http]))
(defrecord Server [schema-provider server]
component/Lifecycle
(start [this]
(assoc this :server (-> schema-provider
:schema
(lp/service-map {:graphiql true
:subscriptions true})
(assoc :io.pedestal.http/allowed-origins ["http://localhost:4200", "http://localhost:8888"])
http/create-server
http/start)))
(stop [this]
(http/stop server)
(assoc this :server nil)))
(defn new-server
[]
{:server (component/using (map->Server {})
[:schema-provider])})