open:default-service

default-service

(defn default-service
  "Returns a default Pedestal service map, with subscriptions and GraphiQL enabled.
 
  The defaults put the GraphQL API at `/api` and the GraphiQL IDE at `/ide` (and subscriptions endpoint
  at `/ws`).
 
  Unlike earlier versions of lacinia-pedestal, only POST is supported, and the content type must
  be `application/json`.
 
  compiled-schema is either the compiled schema itself, or a function returning the compiled schema.
 
  options is a map combining options needed by [[graphiql-ide-route]], [[default-interceptors]],
  [[enable-subscriptions]], and [[listener-fn-factory]].
 
  It may also contain keys :app-context and :port (which defaults to 8888).
 
  You can also define an explicit :host address to your application. Useful when running inside Docker.
 
  This is useful for initial development and exploration, but applications with any more sophisticated needs
  should construct their service map directly."
  [compiled-schema options]
  (let [{:keys [api-path ide-path asset-path app-context port host]
         :or {api-path default-api-path
              ide-path "/ide"
              asset-path default-asset-path
              port 8888
              host default-host-address}} options
        interceptors (default-interceptors compiled-schema app-context options)
        routes (into #{[api-path :post interceptors :route-name ::graphql-api]
                       [ide-path :get (graphiql-ide-handler options) :route-name ::graphiql-ide]}
                     (graphiql-asset-routes asset-path))]
    (-> {:env :dev
         ::http/routes routes
         ::http/port port
         ::http/host host
         ::http/type :jetty
         ::http/join? false}
        enable-graphiql
        (enable-subscriptions compiled-schema options))))


  • open/default-service.txt
  • 마지막으로 수정됨: 2022/06/15 12:04
  • 저자 127.0.0.1