diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-09-05 10:00:58 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-09-05 10:00:58 +0200 |
| commit | d327d9d1ce9670e51b7eef7a4272aaf3b6290228 (patch) | |
| tree | ca27d933d3fb60a1dacd29378beee51754a12825 /src/Language/GraphQL/Validate.hs | |
| parent | 14ed2098285776690bd8fea4209560bf3dba9e74 (diff) | |
| download | graphql-d327d9d1ce9670e51b7eef7a4272aaf3b6290228.tar.gz | |
Validate fragment spread type existence
Diffstat (limited to 'src/Language/GraphQL/Validate.hs')
| -rw-r--r-- | src/Language/GraphQL/Validate.hs | 11 |
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 |
