summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Validate.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-09-05 10:00:58 +0200
committerEugen Wissner <belka@caraus.de>2020-09-05 10:00:58 +0200
commitd327d9d1ce9670e51b7eef7a4272aaf3b6290228 (patch)
treeca27d933d3fb60a1dacd29378beee51754a12825 /src/Language/GraphQL/Validate.hs
parent14ed2098285776690bd8fea4209560bf3dba9e74 (diff)
downloadgraphql-d327d9d1ce9670e51b7eef7a4272aaf3b6290228.tar.gz
Validate fragment spread type existence
Diffstat (limited to 'src/Language/GraphQL/Validate.hs')
-rw-r--r--src/Language/GraphQL/Validate.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Language/GraphQL/Validate.hs b/src/Language/GraphQL/Validate.hs
index 6ff1f57..7a25ce4 100644
--- a/src/Language/GraphQL/Validate.hs
+++ b/src/Language/GraphQL/Validate.hs
@@ -76,14 +76,17 @@ operationDefinition operation =
getSelectionSet (OperationDefinition _ _ _ _ selectionSet _) = selectionSet
selection :: forall m. Selection -> ValidateT m
-selection selection'@FragmentSpread{} =
- asks rules >>= foldM ruleFilter Seq.empty
+selection selection'
+ | FragmentSpread{} <- selection' =
+ asks rules >>= foldM ruleFilter Seq.empty
+ | Field _ _ _ _ selectionSet _ <- selection' =
+ visitChildSelections ruleFilter selectionSet
+ | InlineFragment _ _ selectionSet _ <- selection' =
+ visitChildSelections ruleFilter selectionSet
where
ruleFilter accumulator (SelectionRule rule) =
mapReaderT (runRule accumulator) $ rule selection'
ruleFilter accumulator _ = pure accumulator
-selection (Field _ _ _ _ selectionSet) = traverseSelectionSet selectionSet
-selection (InlineFragment _ _ selectionSet) = traverseSelectionSet selectionSet
traverseSelectionSet :: Traversable t => forall m. t Selection -> ValidateT m
traverseSelectionSet = fmap fold . traverse selection