Skip to content

Commit 16cf681

Browse files
committed
Update graphql-clj Clojure example
1 parent 7f92cfb commit 16cf681

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

site/code/index.html.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,19 @@ A Clojure library that provides a GraphQL implementation.
306306
Code that executes a hello world GraphQL query with \`graphql-clj\`:
307307
308308
\`\`\`clojure
309-
(require '[graphql-clj.parser :as parser])
310-
(require '[graphql-clj.type :as type])
311309
312-
(def parsed-schema (parser/parse "type Query {
310+
(def schema "type QueryRoot {
313311
hello: String
314-
}"))
315-
316-
(def type-schema (type/create-schema parsed-schema))
312+
}")
317313
318314
(defn resolver-fn [type-name field-name]
319-
(cond
320-
(and (= "Query" type-name) (= "hello" field-name)) (fn [context parent & rest]
321-
"Hello world!")))
315+
(get-in {"QueryRoot" {"hello" (fn [context parent & rest]
316+
"Hello world!")}}
317+
[type-name field-name]))
322318
323319
(require '[graphql-clj.executor :as executor])
324320
325-
(executor/execute nil type-schema resolver-fn "{ hello }")
321+
(executor/execute nil schema resolver-fn "{ hello }")
326322
\`\`\`
327323
328324
- [lacinia](https://github.com/walmartlabs/lacinia): A full implementation of the GraphQL specification that aims to maintain external compliance with the specification.

0 commit comments

Comments
 (0)