summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Validate.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/GraphQL/Validate.hs')
-rw-r--r--src/Language/GraphQL/Validate.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Language/GraphQL/Validate.hs b/src/Language/GraphQL/Validate.hs
index 1ffa514..7aafa64 100644
--- a/src/Language/GraphQL/Validate.hs
+++ b/src/Language/GraphQL/Validate.hs
@@ -85,8 +85,8 @@ selection :: forall m. Selection -> ValidateT m
selection selection'
| FragmentSpreadSelection fragmentSelection <- selection' =
visitChildSelections ruleFilter $ fragmentSpread fragmentSelection
- | Field _ _ _ _ selectionSet _ <- selection' =
- visitChildSelections ruleFilter $ traverseSelectionSet selectionSet
+ | FieldSelection fieldSelection <- selection' =
+ visitChildSelections ruleFilter $ field fieldSelection
| InlineFragmentSelection fragmentSelection <- selection' =
visitChildSelections ruleFilter $ inlineFragment fragmentSelection
where
@@ -94,6 +94,14 @@ selection selection'
mapReaderT (runRule accumulator) $ rule selection'
ruleFilter accumulator _ = pure accumulator
+field :: forall m. Field -> ValidateT m
+field field'@(Field _ _ _ _ selections _) =
+ visitChildSelections ruleFilter $ traverseSelectionSet selections
+ where
+ ruleFilter accumulator (FieldRule rule) =
+ mapReaderT (runRule accumulator) $ rule field'
+ ruleFilter accumulator _ = pure accumulator
+
inlineFragment :: forall m. InlineFragment -> ValidateT m
inlineFragment fragment@(InlineFragment _ _ selections _) =
visitChildSelections ruleFilter $ traverseSelectionSet selections