在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):alumbra/alumbra开源软件地址(OpenSource Url):https://github.com/alumbra/alumbra开源编程语言(OpenSource Language):Clojure 100.0%开源软件介绍(OpenSource Introduction):alumbraalumbra is a set of reusable GraphQL components for Clojure conforming to the data structures given in alumbra.spec. It also uses these components to provide an easy-to-use GraphQL infrastructure, allowing you to get started with minimal effort. Features
Quickstart
(require '[alumbra.core :as alumbra]
'[claro.data :as data]) First, we declare our GraphQL schema and implement a (def schema
"type Person { name: String!, friends: [Person!]! }
type QueryRoot { person(id: ID!): Person, me: Person! }
schema { query: QueryRoot }")
(defrecord Person [id]
data/Resolvable
(resolve! [_ _]
{:name (str "Person #" id)
:friends (map ->Person (range (inc id) (+ id 3)))})) Then we declare our (def QueryRoot
{:person (map->Person {})
:me (map->Person {:id 0})})
(def app
(alumbra/handler
{:schema schema
:query QueryRoot})) And this we pass to a Ring-compatible HTTP server of our choice: (defonce my-graphql-server
(aleph.http/start-server #'app {:port 3000})) Check out our GraphQL endpoint! $ curl -XPOST "http://0:3000" -H'Content-Type: application/json' -d'{
"query": "{ me { name, friends { name } } }"
}'
{"data":{"me":{"name":"Person #0","friends":[{"name":"Person #1"},{"name":"Person #2"}]}}} DocumentationContributingContributions are always welcome. Please take a look at the Contribution Guidelines for a quick overview of how your changes can best make it to master. Note that issues for alumbra are tracked centrally within the alumbra issue tracker with single issues being mirrored to the respective repositories. License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论