在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):haskell-graphql/graphql-api开源软件地址(OpenSource Url):https://github.com/haskell-graphql/graphql-api开源编程语言(OpenSource Language):Haskell 97.6%开源软件介绍(OpenSource Introduction):graphql-api
The library provides type combinators to create a GraphQL schema, and functions to parse and evaluate queries against the schema. You can find the latest release on hackage. We implement the GraphQL specification as best as we can in Haskell. We figure they know what they're doing. Even if an alternative API or behaviour looks nicer, we will defer to the spec. TutorialA simple graphql-api tutorial can be read at readthedocs.io. To follow along and get your hands dirty, clone this repository, enter the
ExampleSay we have a simple GraphQL schema like: type Hello {
greeting(who: String!): String!
} which defines a single top-level type We can define this schema in Haskell and implement a simple handler like so: {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
import Data.Text (Text)
import Data.Monoid ((<>))
import GraphQL
import GraphQL.API
import GraphQL.Resolver (Handler, returns)
type Hello = Object "Hello" '[]
'[ Argument "who" Text :> Field "greeting" Text ]
hello :: Handler IO Hello
hello = pure (\who -> returns ("Hello " <> who))
run :: Text -> IO Response
run = interpretAnonymousQuery @Hello hello We require GHC 8.0.2 or later for features like the With the code above we can now run a query: run "{ greeting(who: \"mort\") }" Which will produce the following GraphQL response: {
"data": {
"greeting": "Hello mort"
}
} StatusOur current goal is to gather feedback. We have learned a lot about GraphQL in the course of making this library, but we don't know what a good GraphQL library looks like in Haskell. Please let us know what you think. We won't mind if you file a bug telling us how good the library is. Because we're still learning, we make no guarantees about API stability, or anything at all really. We are tracking open problems, missing features & wishlist items in GitHub's issue tracker. Roadmap
ReferencesCopyrightAll files Copyright (c) 2016-2017 Thomas E. Hunger & Jonathan M. Lange, except:
for which see LICENSE.BSD3 in this repository. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论