summaryrefslogtreecommitdiff
path: root/tests/Test/StarWars
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-05-25 07:41:21 +0200
committerEugen Wissner <belka@caraus.de>2020-05-25 07:41:21 +0200
commit61dbe6c7280a899b485146aa8557948417e78360 (patch)
tree2b3bb2ea7144dd57a44076ab8f5af3321d5a95f1 /tests/Test/StarWars
parenteb90a4091c1f2586640ee49d6f91fc83c05239f6 (diff)
downloadgraphql-61dbe6c7280a899b485146aa8557948417e78360.tar.gz
Split input/output types and values into 2 modules
Diffstat (limited to 'tests/Test/StarWars')
-rw-r--r--tests/Test/StarWars/Data.hs6
-rw-r--r--tests/Test/StarWars/Schema.hs12
2 files changed, 9 insertions, 9 deletions
diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs
index 30a4cef..67a74cd 100644
--- a/tests/Test/StarWars/Data.hs
+++ b/tests/Test/StarWars/Data.hs
@@ -184,7 +184,7 @@ getFriends :: Character -> [Character]
getFriends char = catMaybes $ liftA2 (<|>) getDroid getHuman <$> friends char
getEpisode :: Int -> Maybe Text
-getEpisode 4 = pure $ "NEWHOPE"
-getEpisode 5 = pure $ "EMPIRE"
-getEpisode 6 = pure $ "JEDI"
+getEpisode 4 = pure "NEWHOPE"
+getEpisode 5 = pure "EMPIRE"
+getEpisode 6 = pure "JEDI"
getEpisode _ = empty
diff --git a/tests/Test/StarWars/Schema.hs b/tests/Test/StarWars/Schema.hs
index 993672c..f32c031 100644
--- a/tests/Test/StarWars/Schema.hs
+++ b/tests/Test/StarWars/Schema.hs
@@ -25,10 +25,10 @@ import Test.StarWars.Data
schema :: Schema Identity
schema = Schema { query = queryType, mutation = Nothing }
where
- queryType = ObjectType "Query" Nothing $ HashMap.fromList
- [ ("hero", Field Nothing (ScalarOutputType string) mempty hero)
- , ("human", Field Nothing (ScalarOutputType string) mempty human)
- , ("droid", Field Nothing (ScalarOutputType string) mempty droid)
+ queryType = Out.ObjectType "Query" Nothing $ HashMap.fromList
+ [ ("hero", Out.Field Nothing (Out.NamedScalarType string) mempty hero)
+ , ("human", Out.Field Nothing (Out.NamedScalarType string) mempty human)
+ , ("droid", Out.Field Nothing (Out.NamedScalarType string) mempty droid)
]
hero :: ActionT Identity (Out.Value Identity)
@@ -55,7 +55,7 @@ droid :: ActionT Identity (Out.Value Identity)
droid = do
id' <- argument "id"
case id' of
- In.String i -> getDroid i >>= pure . character
+ In.String i -> character <$> getDroid i
_ -> ActionT $ throwE "Invalid arguments."
character :: Character -> Out.Value Identity
@@ -63,7 +63,7 @@ character char = Schema.object
[ Schema.Resolver "id" $ pure $ Out.String $ id_ char
, Schema.Resolver "name" $ pure $ Out.String $ name_ char
, Schema.Resolver "friends"
- $ pure $ Out.List $ fmap character $ getFriends char
+ $ pure $ Out.List $ character <$> getFriends char
, Schema.Resolver "appearsIn" $ pure
$ Out.List $ Out.Enum <$> catMaybes (getEpisode <$> appearsIn char)
, Schema.Resolver "secretBackstory" $ Out.String