Validate fragment spread type existence
This commit is contained in:
@ -162,9 +162,9 @@ type SelectionSetOpt = [Selection]
|
||||
-- }
|
||||
-- @
|
||||
data Selection
|
||||
= Field (Maybe Alias) Name [Argument] [Directive] SelectionSetOpt
|
||||
= Field (Maybe Alias) Name [Argument] [Directive] SelectionSetOpt Location
|
||||
| FragmentSpread Name [Directive] Location
|
||||
| InlineFragment (Maybe TypeCondition) [Directive] SelectionSet
|
||||
| InlineFragment (Maybe TypeCondition) [Directive] SelectionSet Location
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Arguments
|
||||
|
@ -126,9 +126,9 @@ indent indentation = Lazy.Text.replicate (fromIntegral indentation) indentSymbol
|
||||
selection :: Formatter -> Selection -> Lazy.Text
|
||||
selection formatter = Lazy.Text.append indent' . encodeSelection
|
||||
where
|
||||
encodeSelection (Field alias name args directives' selections) =
|
||||
encodeSelection (Field alias name args directives' selections _) =
|
||||
field incrementIndent alias name args directives' selections
|
||||
encodeSelection (InlineFragment typeCondition directives' selections) =
|
||||
encodeSelection (InlineFragment typeCondition directives' selections _) =
|
||||
inlineFragment incrementIndent typeCondition directives' selections
|
||||
encodeSelection (FragmentSpread name directives' _) =
|
||||
fragmentSpread incrementIndent name directives'
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user