Parse repeatable directive definitions
This commit is contained in:
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user