From 7cd48217187911855cd2ad473e58d11df0c69d48 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 23 May 2020 06:46:21 +0200 Subject: Don't fail on invalid fragments and variables --- tests/Test/RootOperationSpec.hs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'tests/Test/RootOperationSpec.hs') diff --git a/tests/Test/RootOperationSpec.hs b/tests/Test/RootOperationSpec.hs index 08955f3..935b96d 100644 --- a/tests/Test/RootOperationSpec.hs +++ b/tests/Test/RootOperationSpec.hs @@ -6,38 +6,36 @@ module Test.RootOperationSpec 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 import Test.Hspec (Spec, describe, it, shouldBe) import Text.RawString.QQ (r) import Language.GraphQL.Type.Definition import Language.GraphQL.Type.Schema +import qualified Language.GraphQL.Type as Type hatType :: ObjectType IO -hatType = ObjectType "Hat" +hatType = ObjectType "Hat" Nothing $ HashMap.singleton resolverName $ Field Nothing (ScalarOutputType int) mempty resolve where (Schema.Resolver resolverName resolve) = - Schema.scalar "circumference" $ pure (60 :: Int) + Schema.wrappedObject "circumference" $ pure $ Type.I 60 schema :: Schema IO schema = Schema - (ObjectType "Query" hatField) - (Just $ ObjectType "Mutation" incrementField) + (ObjectType "Query" Nothing hatField) + (Just $ ObjectType "Mutation" Nothing incrementField) where - queryResolvers = Schema.resolversToMap $ garment :| [] - mutationResolvers = Schema.resolversToMap $ increment :| [] - garment = Schema.object "garment" $ pure - [ Schema.scalar "circumference" $ pure (60 :: Int) + garment = NestingResolver + $ pure $ Schema.object + [ Schema.wrappedObject "circumference" $ pure $ Type.I 60 ] - increment = Schema.scalar "incrementCircumference" - $ pure (61 :: Int) - incrementField = Field Nothing (ScalarOutputType int) mempty - <$> mutationResolvers - hatField = Field Nothing (ObjectOutputType hatType) mempty - <$> queryResolvers + incrementField = HashMap.singleton "incrementCircumference" + $ Field Nothing (ScalarOutputType int) mempty + $ NestingResolver $ pure $ Type.I 61 + hatField = HashMap.singleton "garment" + $ Field Nothing (ObjectOutputType hatType) mempty garment spec :: Spec spec = -- cgit v1.2.3