Fork me on GitHub
#graphql
<
2020-10-03
>
emccue15:10:35

How would I add some "auth required" to lacinia pedestal subscriptions?

emccue15:10:15

its pretty easy with routing, since I can just inject something

emccue15:10:40

but I am reloading the compiled schema on every request in dev

emccue15:10:57

(defn routes [{:keys [config] :as system}]
  (route/expand-routes
    (set/union
      #{["/api/v1/signup" :post `auth/sign-up :route-name ::sign-up-route]
        ["/api/v1/login" :post `auth/log-in :route-name ::log-in-route]
        ["/api/v1/logout" :post `auth/log-out :route-name ::log-out-route]
        ["/api/v1/photos/:name" :get [`auth/requires-auth-interceptor `photo-route] :route-name ::photo-route]
        ["/api/v1/graphql" :post
         (-> (lp/default-interceptors (graphql/compiled-schema) nil)

emccue15:10:18

::http/routes (if (config/production? config)
                         (routes system)
                         (fn [] (routes system)))

emccue15:10:39

but it seems like to add subscriptions i need to wrap the whole service map

emccue15:10:54

with (lp/enable-subscriptions)

emccue15:10:16

which won't reload, and would have a different compiled schema instance

emccue15:10:39

I can accept needing to reload the server to see changes in subscriptions

emccue15:10:51

but will having a different compiled schema break stuff (horribly)?