summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2022-12-25 16:38:00 +0100
committerEugen Wissner <belka@caraus.de>2022-12-25 16:38:00 +0100
commit3ce6e7da461030d7d6f4b356096492c072ce16e2 (patch)
treec2317e5470571f8e6437666473c22e807203f8f5 /tests
parenta5cf0a32e82dbf6e093ebca47917a84276332b63 (diff)
downloadgraphql-3ce6e7da461030d7d6f4b356096492c072ce16e2.tar.gz
Encode schema definitions
Diffstat (limited to 'tests')
-rw-r--r--tests/Language/GraphQL/AST/EncoderSpec.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/Language/GraphQL/AST/EncoderSpec.hs b/tests/Language/GraphQL/AST/EncoderSpec.hs
index febd6fd..c654c0b 100644
--- a/tests/Language/GraphQL/AST/EncoderSpec.hs
+++ b/tests/Language/GraphQL/AST/EncoderSpec.hs
@@ -4,6 +4,7 @@ module Language.GraphQL.AST.EncoderSpec
( spec
) where
+import Data.List.NonEmpty (NonEmpty(..))
import qualified Language.GraphQL.AST.Document as Full
import Language.GraphQL.AST.Encoder
import Language.GraphQL.TH
@@ -178,3 +179,18 @@ spec = do
it "produces lowercase mutation operation type" $
let actual = operationType pretty Full.Mutation
in actual `shouldBe` "mutation"
+
+ describe "typeSystemDefinition" $
+ it "produces a schema with an indented operation type definition" $
+ let queryType = Full.OperationTypeDefinition Full.Query "QueryRootType"
+ mutationType = Full.OperationTypeDefinition Full.Mutation "MutationType"
+ operations = queryType :| pure mutationType
+ definition' = Full.SchemaDefinition [] operations
+ expected = Text.Lazy.snoc [gql|
+ schema {
+ query: QueryRootType
+ mutation: MutationType
+ }
+ |] '\n'
+ actual = typeSystemDefinition pretty definition'
+ in actual `shouldBe` expected