Fork me on GitHub
#graphql
<
2018-07-06
>
kvlt04:07:20

In case anyone was wondering, here is how one could define REST routes along with a custom interceptor with the graphql routes using lacinia pedestal:

(defn healthz
  [params]
  (hash-map :body "OK" :status 200))

(defrecord Server [schema-provider server]
  component/Lifecycle
  (start [this]
    (assoc this :server
           (let [schema (:schema schema-provider)
                 options {:graphiql true
                          :interceptors (-> (lp/default-interceptors schema {})
                                            (lp/inject interceptors/authenticate-token :before ::lp/query-executor))}]
             (-> schema
                 (lp/service-map options)
                 (update ::http/routes conj ["/healthz" :get healthz :route-name :healthz])
                 http/create-server
                 http/start))))
  (stop [this]
    (http/stop server)
    (assoc this :server nil)))

🙏 1