-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.purs
71 lines (62 loc) · 1.89 KB
/
Main.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module Test.Main where
import Prelude
import Affjax.Node as AffjaxNode
import Data.Foldable (for_)
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Aff (Milliseconds(..), launchAff_)
import Effect.Class.Console as Log
import GraphQL.FunDeps (class GraphQLReqRes, Gql(..), GraphQL, GraphQLClientAff, graphQL)
import Test.Spec (describe, it)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (defaultConfig, runSpec')
endpoint = "https://api.react-finland.fi/graphql" :: String
foreign import data ReactFinlandConferences :: GraphQL
instance graphqlReactFinlandConferences ::
GraphQLReqRes ReactFinlandConferences """query {
conferences {
name
id
}
}
""" () ( conferences :: Array { name :: String, id :: String } )
foreign import data ReactFinlandConference :: GraphQL
instance graphqlReactFinlandConference ::
GraphQLReqRes ReactFinlandConference """query($id:ID!) {
conference(id:$id) {
year
websiteUrl
speakers {
firstName
lastName
}
}
}
""" ( id :: String ) ( conference ::
{ year :: String
, websiteUrl :: String
, speakers ::
Array
{ firstName :: String
, lastName :: String
}
}
)
client :: GraphQLClientAff
client = graphQL "https://api.react-finland.fi/graphql" [] AffjaxNode.driver
main ∷ Effect Unit
main =
launchAff_
$ runSpec'
( defaultConfig
{ timeout = Just (Milliseconds 10000.0)
}
)
[ consoleReporter ] do
describe "GraphQL Fundeps" do
it "Works" do
{ conferences } <- client (Gql :: Gql ReactFinlandConferences) {}
for_ conferences \{ id } -> do
{ conference: { websiteUrl, speakers } } <- client (Gql :: Gql ReactFinlandConference) { id }
Log.info websiteUrl
Log.info $ show speakers