summaryrefslogtreecommitdiff
path: root/tests/Test/FragmentSpec.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-06-29 13:14:23 +0200
committerEugen Wissner <belka@caraus.de>2020-06-29 13:14:23 +0200
commit705e506c13b6c0f67ddf0195fa0d3256e7e4f9c3 (patch)
tree58e41bdbd246fc5b947a848283d6688c7ddf636b /tests/Test/FragmentSpec.hs
parent9798b08b4c25685e92a7f537f68f35994a5a4899 (diff)
downloadgraphql-705e506c13b6c0f67ddf0195fa0d3256e7e4f9c3.tar.gz
Combine Resolver and ActionT in ResolverT
Diffstat (limited to 'tests/Test/FragmentSpec.hs')
-rw-r--r--tests/Test/FragmentSpec.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/Test/FragmentSpec.hs b/tests/Test/FragmentSpec.hs
index 2924e63..94cc76c 100644
--- a/tests/Test/FragmentSpec.hs
+++ b/tests/Test/FragmentSpec.hs
@@ -53,22 +53,24 @@ hasErrors _ = True
shirtType :: Out.ObjectType IO
shirtType = Out.ObjectType "Shirt" Nothing []
$ HashMap.fromList
- [ ("size", Out.Resolver sizeFieldType $ pure $ snd size)
- , ("circumference", Out.Resolver circumferenceFieldType $ pure $ snd circumference)
+ [ ("size", sizeFieldType)
+ , ("circumference", circumferenceFieldType)
]
hatType :: Out.ObjectType IO
hatType = Out.ObjectType "Hat" Nothing []
$ HashMap.fromList
- [ ("size", Out.Resolver sizeFieldType $ pure $ snd size)
- , ("circumference", Out.Resolver circumferenceFieldType $ pure $ snd circumference)
+ [ ("size", sizeFieldType)
+ , ("circumference", circumferenceFieldType)
]
circumferenceFieldType :: Out.Field IO
circumferenceFieldType = Out.Field Nothing (Out.NamedScalarType int) mempty
+ $ pure $ snd circumference
sizeFieldType :: Out.Field IO
sizeFieldType = Out.Field Nothing (Out.NamedScalarType string) mempty
+ $ pure $ snd size
toSchema :: Text -> (Text, Value) -> Schema IO
toSchema t (_, resolve) = Schema
@@ -76,15 +78,17 @@ toSchema t (_, resolve) = Schema
where
unionMember = if t == "Hat" then hatType else shirtType
typeNameField = Out.Field Nothing (Out.NamedScalarType string) mempty
+ $ pure $ String "Shirt"
garmentField = Out.Field Nothing (Out.NamedObjectType unionMember) mempty
+ $ pure resolve
queryType =
case t of
"circumference" -> hatType
"size" -> shirtType
_ -> Out.ObjectType "Query" Nothing []
$ HashMap.fromList
- [ ("garment", Out.Resolver garmentField $ pure resolve)
- , ("__typename", Out.Resolver typeNameField $ pure $ String "Shirt")
+ [ ("garment", garmentField)
+ , ("__typename", typeNameField)
]
spec :: Spec