diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-05-21 10:20:59 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-05-21 10:20:59 +0200 |
| commit | c3ecfece0358d79dd1da6efbe6ab83e63bf50f88 (patch) | |
| tree | 1ff3de1ddd4bf2e04da57cd6d1c889520c263427 /tests/Test/RootOperationSpec.hs | |
| parent | a5c44f30facdaabd94ed25953a3bd88005efa868 (diff) | |
| download | graphql-c3ecfece0358d79dd1da6efbe6ab83e63bf50f88.tar.gz | |
Coerce variable values
Diffstat (limited to 'tests/Test/RootOperationSpec.hs')
| -rw-r--r-- | tests/Test/RootOperationSpec.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/Test/RootOperationSpec.hs b/tests/Test/RootOperationSpec.hs index fc86d04..08955f3 100644 --- a/tests/Test/RootOperationSpec.hs +++ b/tests/Test/RootOperationSpec.hs @@ -5,6 +5,7 @@ module Test.RootOperationSpec ) where import Data.Aeson ((.=), object) +import qualified Data.HashMap.Strict as HashMap import Data.List.NonEmpty (NonEmpty(..)) import Language.GraphQL import qualified Language.GraphQL.Schema as Schema @@ -13,10 +14,18 @@ import Text.RawString.QQ (r) import Language.GraphQL.Type.Definition import Language.GraphQL.Type.Schema +hatType :: ObjectType IO +hatType = ObjectType "Hat" + $ HashMap.singleton resolverName + $ Field Nothing (ScalarOutputType int) mempty resolve + where + (Schema.Resolver resolverName resolve) = + Schema.scalar "circumference" $ pure (60 :: Int) + schema :: Schema IO schema = Schema - (ObjectType "Query" queryResolvers) - (Just $ ObjectType "Mutation" mutationResolvers) + (ObjectType "Query" hatField) + (Just $ ObjectType "Mutation" incrementField) where queryResolvers = Schema.resolversToMap $ garment :| [] mutationResolvers = Schema.resolversToMap $ increment :| [] @@ -25,6 +34,10 @@ schema = Schema ] increment = Schema.scalar "incrementCircumference" $ pure (61 :: Int) + incrementField = Field Nothing (ScalarOutputType int) mempty + <$> mutationResolvers + hatField = Field Nothing (ObjectOutputType hatType) mempty + <$> queryResolvers spec :: Spec spec = |
