summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/AST/Parser.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/AST/Parser.hs
parent14ed2098285776690bd8fea4209560bf3dba9e74 (diff)
downloadgraphql-d327d9d1ce9670e51b7eef7a4272aaf3b6290228.tar.gz
Validate fragment spread type existence
Diffstat (limited to 'src/Language/GraphQL/AST/Parser.hs')
-rw-r--r--src/Language/GraphQL/AST/Parser.hs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Language/GraphQL/AST/Parser.hs b/src/Language/GraphQL/AST/Parser.hs
index e97f306..af82a9e 100644
--- a/src/Language/GraphQL/AST/Parser.hs
+++ b/src/Language/GraphQL/AST/Parser.hs
@@ -382,13 +382,14 @@ selection = field
<?> "Selection"
field :: Parser Selection
-field = Field
- <$> optional alias
- <*> name
- <*> arguments
- <*> directives
- <*> selectionSetOpt
- <?> "Field"
+field = label "Field" $ do
+ location <- getLocation
+ alias' <- optional alias
+ name' <- name
+ arguments' <- arguments
+ directives' <- directives
+ selectionSetOpt' <- selectionSetOpt
+ pure $ Field alias' name' arguments' directives' selectionSetOpt' location
alias :: Parser Alias
alias = try (name <* colon) <?> "Alias"
@@ -408,12 +409,13 @@ fragmentSpread = label "FragmentSpread" $ do
pure $ FragmentSpread fragmentName' directives' location
inlineFragment :: Parser Selection
-inlineFragment = InlineFragment
- <$ spread
- <*> optional typeCondition
- <*> directives
- <*> selectionSet
- <?> "InlineFragment"
+inlineFragment = label "InlineFragment" $ do
+ location <- getLocation
+ _ <- spread
+ typeCondition' <- optional typeCondition
+ directives' <- directives
+ selectionSet' <- selectionSet
+ pure $ InlineFragment typeCondition' directives' selectionSet' location
fragmentDefinition :: Parser FragmentDefinition
fragmentDefinition = label "FragmentDefinition" $ do