summaryrefslogtreecommitdiff
path: root/tests/Test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Test')
-rw-r--r--tests/Test/DirectiveSpec.hs4
-rw-r--r--tests/Test/FragmentSpec.hs25
2 files changed, 12 insertions, 17 deletions
diff --git a/tests/Test/DirectiveSpec.hs b/tests/Test/DirectiveSpec.hs
index e6b6cea..800189e 100644
--- a/tests/Test/DirectiveSpec.hs
+++ b/tests/Test/DirectiveSpec.hs
@@ -72,7 +72,7 @@ spec =
...experimentalFragment @skip(if: true)
}
- fragment experimentalFragment on ExperimentalType {
+ fragment experimentalFragment on Query {
experimentalField
}
|]
@@ -83,7 +83,7 @@ spec =
it "should be able to @skip an inline fragment" $ do
let sourceQuery = [r|
{
- ... on ExperimentalType @skip(if: true) {
+ ... on Query @skip(if: true) {
experimentalField
}
}
diff --git a/tests/Test/FragmentSpec.hs b/tests/Test/FragmentSpec.hs
index 089b721..216ae21 100644
--- a/tests/Test/FragmentSpec.hs
+++ b/tests/Test/FragmentSpec.hs
@@ -46,18 +46,15 @@ inlineQuery = [r|{
}|]
shirtType :: Out.ObjectType IO
-shirtType = Out.ObjectType "Shirt" Nothing []
- $ HashMap.fromList
- [ ("size", sizeFieldType)
- , ("circumference", circumferenceFieldType)
- ]
+shirtType = Out.ObjectType "Shirt" Nothing [] $ HashMap.fromList
+ [ ("size", sizeFieldType)
+ ]
hatType :: Out.ObjectType IO
-hatType = Out.ObjectType "Hat" Nothing []
- $ HashMap.fromList
- [ ("size", sizeFieldType)
- , ("circumference", circumferenceFieldType)
- ]
+hatType = Out.ObjectType "Hat" Nothing [] $ HashMap.fromList
+ [ ("size", sizeFieldType)
+ , ("circumference", circumferenceFieldType)
+ ]
circumferenceFieldType :: Out.Resolver IO
circumferenceFieldType
@@ -73,9 +70,9 @@ toSchema :: Text -> (Text, Value) -> Schema IO
toSchema t (_, resolve) = Schema
{ query = queryType, mutation = Nothing, subscription = Nothing }
where
- unionMember = if t == "Hat" then hatType else shirtType
+ garmentType = Out.UnionType "Garment" Nothing [hatType, shirtType]
typeNameField = Out.Field Nothing (Out.NamedScalarType string) mempty
- garmentField = Out.Field Nothing (Out.NamedObjectType unionMember) mempty
+ garmentField = Out.Field Nothing (Out.NamedUnionType garmentType) mempty
queryType =
case t of
"circumference" -> hatType
@@ -118,9 +115,7 @@ spec = do
}
}
}|]
- resolvers = ("garment", Object $ HashMap.fromList [circumference, size])
-
- actual <- graphql (toSchema "garment" resolvers) sourceQuery
+ actual <- graphql (toSchema "garment" $ garment "Hat") sourceQuery
let expected = HashMap.singleton "data"
$ Aeson.object
[ "garment" .= Aeson.object