Use Seq as base monad in the validator
It is more natural to implement the logic: try to apply each rule to each node.
This commit is contained in:
@ -49,7 +49,7 @@ import Data.Int (Int32)
|
||||
import Data.List.NonEmpty (NonEmpty)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import Language.GraphQL.AST.DirectiveLocation
|
||||
import Language.GraphQL.AST.DirectiveLocation (DirectiveLocation)
|
||||
|
||||
-- * Language
|
||||
|
||||
@ -126,7 +126,7 @@ data Selection
|
||||
| InlineFragmentSelection InlineFragment
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- The only required property of a field is its name. Optionally it can also
|
||||
-- | The only required property of a field is its name. Optionally it can also
|
||||
-- have an alias, arguments, directives and a list of subfields.
|
||||
--
|
||||
-- In the following query "user" is a field with two subfields, "id" and "name":
|
||||
@ -143,7 +143,7 @@ data Field =
|
||||
Field (Maybe Name) Name [Argument] [Directive] SelectionSetOpt Location
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- Inline fragments don't have any name and the type condition ("on UserType")
|
||||
-- | Inline fragments don't have any name and the type condition ("on UserType")
|
||||
-- is optional.
|
||||
--
|
||||
-- @
|
||||
@ -159,7 +159,7 @@ data InlineFragment = InlineFragment
|
||||
(Maybe TypeCondition) [Directive] SelectionSet Location
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- A fragment spread refers to a fragment defined outside the operation and is
|
||||
-- | A fragment spread refers to a fragment defined outside the operation and is
|
||||
-- expanded at the execution time.
|
||||
--
|
||||
-- @
|
||||
@ -190,7 +190,7 @@ data FragmentSpread = FragmentSpread Name [Directive] Location
|
||||
-- @
|
||||
--
|
||||
-- Here "id" is an argument for the field "user" and its value is 4.
|
||||
data Argument = Argument Name Value deriving (Eq,Show)
|
||||
data Argument = Argument Name Value Location deriving (Eq,Show)
|
||||
|
||||
-- ** Fragments
|
||||
|
||||
|
@ -159,7 +159,7 @@ arguments :: Formatter -> [Argument] -> Lazy.Text
|
||||
arguments formatter = parensCommas formatter $ argument formatter
|
||||
|
||||
argument :: Formatter -> Argument -> Lazy.Text
|
||||
argument formatter (Argument name value')
|
||||
argument formatter (Argument name value' _)
|
||||
= Lazy.Text.fromStrict name
|
||||
<> colon formatter
|
||||
<> value formatter value'
|
||||
|
@ -100,8 +100,8 @@ amp :: Parser T.Text
|
||||
amp = symbol "&"
|
||||
|
||||
-- | Parser for ":".
|
||||
colon :: Parser T.Text
|
||||
colon = symbol ":"
|
||||
colon :: Parser ()
|
||||
colon = symbol ":" >> pure ()
|
||||
|
||||
-- | Parser for "=".
|
||||
equals :: Parser T.Text
|
||||
|
@ -398,7 +398,12 @@ arguments :: Parser [Argument]
|
||||
arguments = listOptIn parens argument <?> "Arguments"
|
||||
|
||||
argument :: Parser Argument
|
||||
argument = Argument <$> name <* colon <*> value <?> "Argument"
|
||||
argument = label "Argument" $ do
|
||||
location <- getLocation
|
||||
name' <- name
|
||||
colon
|
||||
value' <- value
|
||||
pure $ Argument name' value' location
|
||||
|
||||
fragmentSpread :: Parser FragmentSpread
|
||||
fragmentSpread = label "FragmentSpread" $ do
|
||||
|
Reference in New Issue
Block a user