diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-10-07 05:24:51 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-10-07 05:24:51 +0200 |
| commit | 7c0b0ace4dacbb581669f88b83b9643a83fc797a (patch) | |
| tree | ec9e5a55764c63203f09fc5c9b60990cd4b2aac7 /tests | |
| parent | a91bc7f2d218ea2df308d3968587b60351625150 (diff) | |
| download | graphql-7c0b0ace4dacbb581669f88b83b9643a83fc797a.tar.gz | |
Collect types once the schema is created
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Language/GraphQL/ExecuteSpec.hs | 7 | ||||
| -rw-r--r-- | tests/Language/GraphQL/ValidateSpec.hs | 7 | ||||
| -rw-r--r-- | tests/Test/DirectiveSpec.hs | 2 | ||||
| -rw-r--r-- | tests/Test/FragmentSpec.hs | 2 | ||||
| -rw-r--r-- | tests/Test/RootOperationSpec.hs | 9 | ||||
| -rw-r--r-- | tests/Test/StarWars/Schema.hs | 2 |
6 files changed, 8 insertions, 21 deletions
diff --git a/tests/Language/GraphQL/ExecuteSpec.hs b/tests/Language/GraphQL/ExecuteSpec.hs index e6dd8d9..f6e3e6f 100644 --- a/tests/Language/GraphQL/ExecuteSpec.hs +++ b/tests/Language/GraphQL/ExecuteSpec.hs @@ -26,12 +26,7 @@ import Text.Megaparsec (parse) import Text.RawString.QQ (r) philosopherSchema :: Schema (Either SomeException) -philosopherSchema = Schema - { query = queryType - , mutation = Nothing - , subscription = Just subscriptionType - , directives = HashMap.empty - } +philosopherSchema = schema queryType Nothing (Just subscriptionType) mempty queryType :: Out.ObjectType (Either SomeException) queryType = Out.ObjectType "Query" Nothing [] diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index 92b3001..3bfa018 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -22,12 +22,7 @@ import Text.Megaparsec (parse) import Text.RawString.QQ (r) petSchema :: Schema IO -petSchema = Schema - { query = queryType - , mutation = Nothing - , subscription = Just subscriptionType - , directives = HashMap.empty - } +petSchema = schema queryType Nothing (Just subscriptionType) mempty queryType :: ObjectType IO queryType = ObjectType "Query" Nothing [] $ HashMap.fromList diff --git a/tests/Test/DirectiveSpec.hs b/tests/Test/DirectiveSpec.hs index c115163..2d586f6 100644 --- a/tests/Test/DirectiveSpec.hs +++ b/tests/Test/DirectiveSpec.hs @@ -19,7 +19,7 @@ import Test.Hspec.GraphQL import Text.RawString.QQ (r) experimentalResolver :: Schema IO -experimentalResolver = schema queryType +experimentalResolver = schema queryType Nothing Nothing mempty where queryType = Out.ObjectType "Query" Nothing [] $ HashMap.singleton "experimentalField" diff --git a/tests/Test/FragmentSpec.hs b/tests/Test/FragmentSpec.hs index 4fecad8..f426e2c 100644 --- a/tests/Test/FragmentSpec.hs +++ b/tests/Test/FragmentSpec.hs @@ -67,7 +67,7 @@ sizeFieldType $ pure $ snd size toSchema :: Text -> (Text, Value) -> Schema IO -toSchema t (_, resolve) = schema queryType +toSchema t (_, resolve) = schema queryType Nothing Nothing mempty where garmentType = Out.UnionType "Garment" Nothing [hatType, shirtType] typeNameField = Out.Field Nothing (Out.NamedScalarType string) mempty diff --git a/tests/Test/RootOperationSpec.hs b/tests/Test/RootOperationSpec.hs index 33b5d3b..1921ec9 100644 --- a/tests/Test/RootOperationSpec.hs +++ b/tests/Test/RootOperationSpec.hs @@ -24,13 +24,10 @@ hatType = Out.ObjectType "Hat" Nothing [] $ pure $ Int 60 garmentSchema :: Schema IO -garmentSchema = Schema - { query = Out.ObjectType "Query" Nothing [] hatFieldResolver - , mutation = Just $ Out.ObjectType "Mutation" Nothing [] incrementFieldResolver - , subscription = Nothing - , directives = HashMap.empty - } +garmentSchema = schema queryType (Just mutationType) Nothing mempty where + queryType = Out.ObjectType "Query" Nothing [] hatFieldResolver + mutationType = Out.ObjectType "Mutation" Nothing [] incrementFieldResolver garment = pure $ Object $ HashMap.fromList [ ("circumference", Int 60) ] diff --git a/tests/Test/StarWars/Schema.hs b/tests/Test/StarWars/Schema.hs index 706d9b3..90ce9fc 100644 --- a/tests/Test/StarWars/Schema.hs +++ b/tests/Test/StarWars/Schema.hs @@ -18,7 +18,7 @@ import Prelude hiding (id) -- See https://github.com/graphql/graphql-js/blob/master/src/__tests__/starWarsSchema.js starWarsSchema :: Schema (Either SomeException) -starWarsSchema = schema queryType +starWarsSchema = schema queryType Nothing Nothing mempty where queryType = Out.ObjectType "Query" Nothing [] $ HashMap.fromList [ ("hero", heroFieldResolver) |
