alumbra.pipeline
executor
(executor opts)
Create a function that takes a query string, as well as an optional map of :variables
, :operation-name
and :context
and produces the result of executing the query.
(def run-query
(alumbra.pipeline/executor opts))
(run-query "{ me { name } }")
;; => {:status :success, :data {"me" { ... }}, ...}
See alumbra.pipeline.steps/run for the necessary opts
and the expected result format.
handler
(handler {:keys [parser-fn validator-fn canonicalize-fn executor-fn context-fn]})
Generate a Ring Handler for handling GraphQL requests.
:parser-fn
: a parser function for GraphQL documents (producing a value conforming to either:alumbra/document
or:alumbra/parser-errors
),:validator-fn
: a function taking an:alumbra/document
and producing eithernil
or a value conforming to:alumbra/validation-errors
,:canonicalize-fn
: a function taking an:alumbra/document
and producing an:alumbra/canonical-document
,:context-fn
: a function taking an HTTP request and returning a value representing the context of the GraphQL query,:executor-fn
: an executor function, taking the request context, as well as a map conforming to:alumbra/canonical-operation
and returning the resolved result.
The resulting handler will expect queries to be sent using POST
, represented by a JSON map with the keys "operationName"
, "query"
and “variables”.