This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-26
Channels
- # announcements (2)
- # beginners (46)
- # calva (16)
- # cider (5)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (4)
- # clojure (42)
- # clojure-dev (2)
- # clojure-spec (6)
- # clojure-uk (1)
- # clojurescript (18)
- # cursive (7)
- # datomic (18)
- # duct (1)
- # fulcro (11)
- # graalvm (1)
- # hoplon (9)
- # leiningen (1)
- # off-topic (8)
- # shadow-cljs (16)
- # spacemacs (9)
- # specter (3)
- # sql (33)
- # vim (3)
- # xtdb (8)
Hi! I am trying to use lacinia-pedestal
as an Lambda function datomic ion. Does anyone have any suggestions on how to do this? Here's some example code:
(defn web-handler*
[]
(-> (load-schema)
(service-map {:graphiql false})
http/create-server
http/start))
(def web-handler
(apigw/ionize web-handler*))
The error message I get is:
Wrong number of args (1) passed to: stackz.graphql/web-handler*
This is because web-handler*
is being passed the request
argument.I know nothing about lancia-pedestal but I would guess that you don’t need to start any http server but just go straight to the web handler. Maybe that means to skip the last two threaded function calls so what you ionize is (service-map …)
And I guess web-handler* should not be a fn but something like (def web-handler* (service-map (load-schema) {:graphical false})
You’ll need to do some work to map the Lacinia service-map to the ions req/res format
There is code in the pedestal/pedestal
github repo for AWS Lambda functions with API Gateway…
Actually, I'm following this: https://github.com/pedestal/pedestal.ions
@hadilsabbagh18 You’re going to want something like this for your ion, then you’ll need a dev namespace so that in dev you create a local jetty server.
(def the-schema
(-> (io/resource "graphql/schema.edn")
slurp
edn/read-string
(util/attach-resolvers {
:query/Moments moments ;;a resolver function
:mutation/create-moment create-moment ;; another resolver that does mutations
})
schema/compile))
(def service (-> the-schema
(lacinia/service-map {:graphiql true})
(assoc ::http/chain-provider provider/ion-provider
::http/resource-path "/public"
::http/allowed-origins {:creds true})))
(defn handler
"Ion handler"
[service-map]
(-> service-map
http/default-interceptors
http/create-provider))
(def app (apigw/ionize (handler service)))