You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library provides type combinators to create a GraphQL schema, and functions to parse and evaluate queries against the schema. It is inspired by[servant](http://haskell-servant.readthedocs.io/en/stable/) but the two projects don't share any code.
6
+
`graphql-api` helps you implement a robust [GraphQL](http://graphql.org/) API in Haskell. By the time a query makes it to your handler you are dealing with strong, static types that make sense for your problem domain. All your handlers are normal Haskell functions because we derive their type signature from the schema. If you have used[servant](http://haskell-servant.readthedocs.io/en/stable/), this will sound familiar.
7
7
8
-
More specifically, `graphql-api` helps with implementing a robust GraphQL API in Haskell. By the time a query makes it to your handler you are dealing with strong, static types. All handlers are normal Haskell functions because we derive their type signature from the schema.
8
+
The library provides type combinators to create a GraphQL schema, and functions to parse and evaluate queries against the schema.
9
9
10
10
You can find the latest release on [hackage](https://hackage.haskell.org/package/graphql-api).
11
11
12
-
Note that we're trying to implement the GraphQL standard as best as we can in Haskell. I.e. even if an alternative API or behaviour looks nicer we will defer to the standard.
12
+
We implement the [GraphQL specification](https://facebook.github.io/graphql/) 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.
13
13
14
-
## Hello world example
14
+
## Example
15
15
16
-
Below we define a `Hello` Schema that contains a single field, `greeting`, that takes a single, required argument `who`:
Wecandefinethisschema in Haskell and implement a simple handler like so:
17
27
18
28
```haskell
29
+
{-# LANGUAGE OverloadedStrings #-}
30
+
{-# LANGUAGE TypeApplications #-}
31
+
{-# LANGUAGE TypeOperators #-}
32
+
19
33
import Data.Text (Text)
20
34
importData.Monoid ((<>))
21
35
@@ -33,26 +47,42 @@ run :: Text -> IO Response
33
47
run = interpretAnonymousQuery @Hello hello
34
48
```
35
49
36
-
Note that we require GHC 8.0.2 or later for features like the `@Hello` type application, and for certain bug fixes.
50
+
We require GHC 8.0.2 or later for features like the `@Hello` type application, and for certain bug fixes.
37
51
38
52
With the code above we can now run a query:
39
53
40
54
```haskell
41
55
run"{ greeting(who: \"mort\") }"
42
56
```
43
57
44
-
## Current status
58
+
WhichwillproducethefollowingGraphQLresponse:
59
+
60
+
```json
61
+
{
62
+
data: {
63
+
greeting: "Hello mort"
64
+
}
65
+
}
66
+
```
67
+
68
+
## Status
69
+
70
+
Our 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](https://github.com/jml/graphql-api/issues/new) what you think. We won't mind if you file a bug telling us how good the library is.
45
71
46
-
This first release's goal is to gather feedback. We make **no** guarantees about API stability, or anything at all really.
72
+
Because we're still learning, we make **no** guarantees about API stability, or anything at all really.
47
73
48
-
We are tracking open problem, missing features & wishlist-items in [GitHub's issue tracker](https://github.com/jml/graphql-api/issues).
74
+
We are tracking open problems, missing features & wishlistitems in [GitHub's issue tracker](https://github.com/jml/graphql-api/issues).
49
75
50
76
## Roadmap
51
77
52
78
* Near future:
53
-
- Complete lose ends in current implementation & gather feedback.
79
+
- Better error messages (this is really important to us)
80
+
- Full support for recursive data types
81
+
- Close off lose ends in current implementation & gather feedback
54
82
* Medium future:
55
-
- Implement introspection
83
+
- Full schema validation
84
+
- Schema introspection
85
+
- Stabilize public API
56
86
* Long term:
57
87
- Derive client implementations from types
58
88
- Allow users to implement their own type combinators
0 commit comments