summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/Execute
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-09-07 22:01:49 +0200
committerEugen Wissner <belka@caraus.de>2020-09-07 22:01:49 +0200
commitf6ff0ab9c785273e3ceeac6b9d636c5ec519a008 (patch)
tree4c77603d176d9d1383cf0a3ea3891648ed075b8c /src/Language/GraphQL/Execute
parentd327d9d1ce9670e51b7eef7a4272aaf3b6290228 (diff)
downloadgraphql-f6ff0ab9c785273e3ceeac6b9d636c5ec519a008.tar.gz
Validate fragments on composite types
Diffstat (limited to 'src/Language/GraphQL/Execute')
-rw-r--r--src/Language/GraphQL/Execute/Transform.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Language/GraphQL/Execute/Transform.hs b/src/Language/GraphQL/Execute/Transform.hs
index b438bdf..e36db55 100644
--- a/src/Language/GraphQL/Execute/Transform.hs
+++ b/src/Language/GraphQL/Execute/Transform.hs
@@ -298,8 +298,15 @@ selection (Full.Field alias name arguments' directives' selections _) =
where
go arguments (Full.Argument name' value') =
inputField arguments name' value'
+selection (Full.FragmentSpreadSelection fragmentSelection) =
+ fragmentSpread fragmentSelection
+selection (Full.InlineFragmentSelection fragmentSelection) =
+ inlineFragment fragmentSelection
-selection (Full.FragmentSpread name directives' _) =
+fragmentSpread
+ :: Full.FragmentSpread
+ -> State (Replacement m) (Either (Seq (Selection m)) (Selection m))
+fragmentSpread (Full.FragmentSpread name directives' _) =
maybe (Left mempty) (Right . SelectionFragment) <$> do
spreadDirectives <- Definition.selection <$> directives directives'
fragments' <- gets fragments
@@ -314,7 +321,11 @@ selection (Full.FragmentSpread name directives' _) =
Just fragment -> lift $ pure $ fragment <$ spreadDirectives
_ -> lift $ pure Nothing
| otherwise -> lift $ pure Nothing
-selection (Full.InlineFragment type' directives' selections _) = do
+
+inlineFragment
+ :: Full.InlineFragment
+ -> State (Replacement m) (Either (Seq (Selection m)) (Selection m))
+inlineFragment (Full.InlineFragment type' directives' selections _) = do
fragmentDirectives <- Definition.selection <$> directives directives'
case fragmentDirectives of
Nothing -> pure $ Left mempty