Skip to content

Commit f05ad6a

Browse files
committed
Add GraphQL Clojure library and code example
1 parent f4b1323 commit f05ad6a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

site/code/index.html.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,34 @@ public class HelloWorld {
262262
263263
See [the graphql-java docs](https://github.com/graphql-java/graphql-java) for more information on setup.
264264
265+
### Clojure
266+
267+
#### [graphql-clj](https://github.com/tendant/graphql-clj)
268+
269+
A Clojure library designed to provide GraphQL implementation.
270+
271+
Code that executes a hello world GraphQL query with \`graphql-clj\`:
272+
273+
\`\`\`clojure
274+
(require '[graphql-clj.parser :as parser])
275+
(require '[graphql-clj.type :as type])
276+
277+
(def parsed-schema (parser/parse "type Query {
278+
hello: String
279+
}"))
280+
281+
(def type-schema (type/create-schema parsed-schema))
282+
283+
(defn resolver-fn [type-name field-name]
284+
(cond
285+
(and (= "Query" type-name) (= "hello" field-name)) (fn [context parent & rest]
286+
"Hello world!")))
287+
288+
(require '[graphql-clj.executor :as executor])
289+
290+
(executor/execute nil type-schema resolver-fn "{ hello }")
291+
\`\`\`
292+
265293
### Go
266294
267295
- [graphql-go](https://github.com/graphql-go/graphql): An implementation of GraphQL for Go / Golang.

0 commit comments

Comments
 (0)