@@ -0,0 +1,59 @@
1+# purescript-graphql-fundeps
2+
3+Type-safe graphql queries using functional dependencies.
4+
5+Use the `GraphQLReqRes` class to define expected input and output.
6+Then, create a `client` and use it to interact with your API.
7+
8+```purescript
9+endpoint = "https://api.react-finland.fi/graphql" :: String
10+
11+foreign import data ReactFinlandConferences :: GraphQL
12+
13+instance graphqlReactFinlandConferences ::
14+ GraphQLReqRes ReactFinlandConferences """query {
15+ conferences {
16+ name
17+ id
18+ }
19+}
20+""" () ( conferences :: Array { name :: String, id :: String } )
21+
22+foreign import data ReactFinlandConference :: GraphQL
23+
24+instance graphqlReactFinlandConference ::
25+ GraphQLReqRes ReactFinlandConference """query($id:ID!) {
26+ conference(id:$id) {
27+ year
28+ websiteUrl
29+ speakers {
30+ firstName
31+ lastName
32+ }
33+ }
34+}
35+""" ( id :: String ) ( conference ::
36+ { year :: String
37+ , websiteUrl :: String
38+ , speakers ::
39+ Array
40+ { firstName :: String
41+ , lastName :: String
42+ }
43+ }
44+ )
45+
46+client :: GraphQLClient
47+client = graphQL "https://api.react-finland.fi/graphql" []
48+
49+main ∷ Effect Unit
50+main =
51+ launchAff_ do
52+ { conferences } <- client (Gql :: Gql ReactFinlandConferences) {}
53+ for_ conferences \{ id } -> do
54+ { conference: { websiteUrl, speakers } } <- client (Gql :: Gql ReactFinlandConference) { id }
55+ Log.info websiteUrl
56+ Log.info $ show speakers
57+```
58+
59+You can check out the [test](./test/Main.purs) for a full example.