diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-08-27 10:51:01 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-08-27 10:51:01 +0200 |
| commit | b40d8a7e1ef03e6ccbe990572add58cfaa6d8ed9 (patch) | |
| tree | f803e634f92953b457c8418747d67678754e77c3 /src/Language/GraphQL | |
| parent | 4b5e25a4d84e992910ad4bdf92b0f8a2213493a8 (diff) | |
| download | graphql-b40d8a7e1ef03e6ccbe990572add58cfaa6d8ed9.tar.gz | |
Parse repeatable directive definitions
Diffstat (limited to 'src/Language/GraphQL')
| -rw-r--r-- | src/Language/GraphQL/AST/Document.hs | 2 | ||||
| -rw-r--r-- | src/Language/GraphQL/AST/Encoder.hs | 3 | ||||
| -rw-r--r-- | src/Language/GraphQL/AST/Parser.hs | 2 | ||||
| -rw-r--r-- | src/Language/GraphQL/Validate.hs | 2 |
4 files changed, 6 insertions, 3 deletions
diff --git a/src/Language/GraphQL/AST/Document.hs b/src/Language/GraphQL/AST/Document.hs index 66fc246..f695495 100644 --- a/src/Language/GraphQL/AST/Document.hs +++ b/src/Language/GraphQL/AST/Document.hs @@ -405,7 +405,7 @@ data TypeSystemDefinition = SchemaDefinition [Directive] (NonEmpty OperationTypeDefinition) | TypeDefinition TypeDefinition | DirectiveDefinition - Description Name ArgumentsDefinition (NonEmpty DirectiveLocation) + Description Name ArgumentsDefinition Bool (NonEmpty DirectiveLocation) deriving (Eq, Show) -- ** Type System Extensions diff --git a/src/Language/GraphQL/AST/Encoder.hs b/src/Language/GraphQL/AST/Encoder.hs index 120fb64..afa30de 100644 --- a/src/Language/GraphQL/AST/Encoder.hs +++ b/src/Language/GraphQL/AST/Encoder.hs @@ -159,11 +159,12 @@ typeSystemDefinition formatter = \case <> optempty (directives formatter) operationDirectives <> bracesList formatter (operationTypeDefinition formatter) (NonEmpty.toList operationTypeDefinitions') Full.TypeDefinition typeDefinition' -> typeDefinition formatter typeDefinition' - Full.DirectiveDefinition description' name' arguments' locations + Full.DirectiveDefinition description' name' arguments' repeatable locations -> description formatter description' <> "@" <> Lazy.Text.fromStrict name' <> argumentsDefinition formatter arguments' + <> (if repeatable then " repeatable" else mempty) <> " on" <> pipeList formatter (directiveLocation <$> locations) diff --git a/src/Language/GraphQL/AST/Parser.hs b/src/Language/GraphQL/AST/Parser.hs index 049876e..f325ee7 100644 --- a/src/Language/GraphQL/AST/Parser.hs +++ b/src/Language/GraphQL/AST/Parser.hs @@ -27,6 +27,7 @@ import Text.Megaparsec , unPos , (<?>) ) +import Data.Maybe (isJust) -- | Parser for the GraphQL documents. document :: Parser Full.Document @@ -82,6 +83,7 @@ directiveDefinition description' = Full.DirectiveDefinition description' <* at <*> name <*> argumentsDefinition + <*> (isJust <$> optional (symbol "repeatable")) <* symbol "on" <*> directiveLocations <?> "DirectiveDefinition" diff --git a/src/Language/GraphQL/Validate.hs b/src/Language/GraphQL/Validate.hs index f6f8788..ba00594 100644 --- a/src/Language/GraphQL/Validate.hs +++ b/src/Language/GraphQL/Validate.hs @@ -200,7 +200,7 @@ typeSystemDefinition context rule = \case directives context rule schemaLocation directives' Full.TypeDefinition typeDefinition' -> typeDefinition context rule typeDefinition' - Full.DirectiveDefinition _ _ arguments' _ -> + Full.DirectiveDefinition _ _ arguments' _ _ -> argumentsDefinition context rule arguments' typeDefinition :: forall m. Validation m -> ApplyRule m Full.TypeDefinition |
