The newer com.walmartlabs.lacinia.pedestal2 namespace is recommended over the now-deprecated com.walmartlabs.lacinia.pedestal namespace. The new namespace was introduced to maintain backwards compatibility, but be aware of which you use, as the default URLs served differ with each namespace. This guide assumes you are using the latest pedestal2 namespace and its defaults.

You start with a schema file, resources/hello-world-schema.edn, in this example:

  {:type String}}}

From there there are three steps:

  • Load and compile the schema
  • Create a Pedestal service around the schema
  • Start the Pedestal service
(ns demo.server
    [clojure.edn :as edn]
    [clojure.java.io :as io]
    [com.walmartlabs.lacinia.pedestal2 :as p2]
    [com.walmartlabs.lacinia.schema :as schema]
    [com.walmartlabs.lacinia.util :as util]
    [io.pedestal.http :as http]))

(defn ^:private resolve-hello
  [context args value]
  "Hello, Clojurians!")

(defn ^:private hello-schema
  (-> (io/resource "hello-world-schema.edn")
      (util/inject-resolvers {:queries/hello resolve-hello})

(def service (-> (hello-schema)
                 (p2/default-service nil)

At the end of this, an instance of Jetty is launched on port 8888.

The GraphQL endpoint will be at http://localhost:8888/api and the GraphIQL client will be at http://localhost:8888/ide.

The options map provided to default-service allow a number of features of Lacinia-Pedestal to be configured or customized, though the intent of default-service is to just be initial scaffolding - it should be replaced with application-specific code.