summaryrefslogtreecommitdiff
path: root/tests/Test/RootOperationSpec.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-05-27 23:18:35 +0200
committerEugen Wissner <belka@caraus.de>2020-05-29 13:53:51 +0200
commitd12577ae717512979c7654191ca65f25fc877907 (patch)
tree17eda8d92d92ef2773c439d614f00ea0e74ea969 /tests/Test/RootOperationSpec.hs
parentc06d0b8e95ea4b87eab69da085cb32dbd052c1f0 (diff)
downloadgraphql-d12577ae717512979c7654191ca65f25fc877907.tar.gz
Define resolvers on type fields
Returning resolvers from other resolvers isn't supported anymore. Since we have a type system now, we define the resolvers in the object type fields and pass an object with the previous result to them.
Diffstat (limited to 'tests/Test/RootOperationSpec.hs')
-rw-r--r--tests/Test/RootOperationSpec.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/Test/RootOperationSpec.hs b/tests/Test/RootOperationSpec.hs
index 291b5f2..3b21788 100644
--- a/tests/Test/RootOperationSpec.hs
+++ b/tests/Test/RootOperationSpec.hs
@@ -7,7 +7,6 @@ module Test.RootOperationSpec
import Data.Aeson ((.=), object)
import qualified Data.HashMap.Strict as HashMap
import Language.GraphQL
-import qualified Language.GraphQL.Schema as Schema
import Test.Hspec (Spec, describe, it, shouldBe)
import Text.RawString.QQ (r)
import Language.GraphQL.Type.Definition
@@ -16,23 +15,21 @@ import Language.GraphQL.Type.Schema
hatType :: Out.ObjectType IO
hatType = Out.ObjectType "Hat" Nothing []
- $ HashMap.singleton resolverName
- $ Out.Field Nothing (Out.NamedScalarType int) mempty resolve
- where
- (Schema.Resolver resolverName resolve) =
- Schema.Resolver "circumference" $ pure $ Out.Int 60
+ $ HashMap.singleton "circumference"
+ $ Out.Field Nothing (Out.NamedScalarType int) mempty
+ $ pure $ Int 60
schema :: Schema IO
schema = Schema
(Out.ObjectType "Query" Nothing [] hatField)
(Just $ Out.ObjectType "Mutation" Nothing [] incrementField)
where
- garment = pure $ Schema.object
- [ Schema.Resolver "circumference" $ pure $ Out.Int 60
+ garment = pure $ Object $ HashMap.fromList
+ [ ("circumference", Int 60)
]
incrementField = HashMap.singleton "incrementCircumference"
$ Out.Field Nothing (Out.NamedScalarType int) mempty
- $ pure $ Out.Int 61
+ $ pure $ Int 61
hatField = HashMap.singleton "garment"
$ Out.Field Nothing (Out.NamedObjectType hatType) mempty garment