summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/AST/Parser.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-09-18 07:32:58 +0200
committerEugen Wissner <belka@caraus.de>2020-09-18 07:32:58 +0200
commit9a08aa5de73e225a9a76017aee4886ce7f6eccec (patch)
tree6cdeadc16c994bcb3bd13764c1a7104c2cb56c09 /src/Language/GraphQL/AST/Parser.hs
parent497b93c41b2534ec2b92b49e93267178417bef56 (diff)
downloadgraphql-9a08aa5de73e225a9a76017aee4886ce7f6eccec.tar.gz
Validate directives are unique per location
Diffstat (limited to 'src/Language/GraphQL/AST/Parser.hs')
-rw-r--r--src/Language/GraphQL/AST/Parser.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Language/GraphQL/AST/Parser.hs b/src/Language/GraphQL/AST/Parser.hs
index f6d1539..62a247d 100644
--- a/src/Language/GraphQL/AST/Parser.hs
+++ b/src/Language/GraphQL/AST/Parser.hs
@@ -520,11 +520,12 @@ directives :: Parser [Directive]
directives = many directive <?> "Directives"
directive :: Parser Directive
-directive = Directive
- <$ at
- <*> name
- <*> arguments
- <?> "Directive"
+directive = label "Directive" $ do
+ location <- getLocation
+ at
+ directiveName <- name
+ directiveArguments <- arguments
+ pure $ Directive directiveName directiveArguments location
listOptIn :: (Parser [a] -> Parser [a]) -> Parser a -> Parser [a]
listOptIn surround = option [] . surround . some