summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Validate/Rules.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-07-20 21:29:12 +0200
committerEugen Wissner <belka@caraus.de>2020-07-20 21:29:12 +0200
commit44d506d4b57e450480cf9c476bd927a43ad9c25d (patch)
tree192ac32226efb7e5cf9976c612d3e0663419b4bd /src/Language/GraphQL/Validate/Rules.hs
parentb9d5b1fb1bdf634137f463186585bc51e540353b (diff)
downloadgraphql-44d506d4b57e450480cf9c476bd927a43ad9c25d.tar.gz
Draft the Validation API
Diffstat (limited to 'src/Language/GraphQL/Validate/Rules.hs')
-rw-r--r--src/Language/GraphQL/Validate/Rules.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Language/GraphQL/Validate/Rules.hs b/src/Language/GraphQL/Validate/Rules.hs
new file mode 100644
index 0000000..bc754c2
--- /dev/null
+++ b/src/Language/GraphQL/Validate/Rules.hs
@@ -0,0 +1,25 @@
+{- This Source Code Form is subject to the terms of the Mozilla Public License,
+ v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ obtain one at https://mozilla.org/MPL/2.0/. -}
+
+module Language.GraphQL.Validate.Rules
+ ( Rule(..)
+ , executableDefinitionsRule
+ , specifiedRules
+ ) where
+
+import Language.GraphQL.AST.Document
+
+newtype Rule
+ = DefinitionRule (Definition -> Maybe String)
+
+specifiedRules :: [Rule]
+specifiedRules =
+ [ executableDefinitionsRule
+ ]
+
+executableDefinitionsRule :: Rule
+executableDefinitionsRule = DefinitionRule go
+ where
+ go (ExecutableDefinition _definition _) = Nothing
+ go _ = Just "Definition must be OperationDefinition or FragmentDefinition."