From d327d9d1ce9670e51b7eef7a4272aaf3b6290228 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 5 Sep 2020 10:00:58 +0200 Subject: Validate fragment spread type existence --- src/Language/GraphQL/Validate.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Language/GraphQL/Validate.hs') 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 -- cgit v1.2.3