Release 0.9.0.0

This commit is contained in:
Eugen Wissner 2020-07-24 21:34:31 +02:00
parent 44d506d4b5
commit c60dd98fc5
6 changed files with 21 additions and 6 deletions

View File

@ -28,6 +28,7 @@ and this project adheres to
and event stream) resolvers to signalize an error. Other exceptions will and event stream) resolvers to signalize an error. Other exceptions will
escape. escape.
- `Test.Hspec.GraphQL` contains some test helpers. - `Test.Hspec.GraphQL` contains some test helpers.
- `Validate` contains the validator and standard rules.
## Changed ## Changed
- `Type.Out.Resolver`: Interface fields don't have resolvers, object fields - `Type.Out.Resolver`: Interface fields don't have resolvers, object fields

View File

@ -4,10 +4,10 @@ cabal-version: 1.12
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
-- --
-- hash: ba234bcfff46df053a3466359e32682c4592b88894911ecbe78bd00fa00929b5 -- hash: 5fa34f11ab1242b72c75c3c19b31ba310c24716a0eb2d134d2b17dd558280732
name: graphql name: graphql
version: 0.8.0.0 version: 0.9.0.0
synopsis: Haskell GraphQL implementation synopsis: Haskell GraphQL implementation
description: This package provides a rudimentary parser for the <https://graphql.github.io/graphql-spec/June2018/ GraphQL> language. description: This package provides a rudimentary parser for the <https://graphql.github.io/graphql-spec/June2018/ GraphQL> language.
category: Language category: Language

View File

@ -1,5 +1,5 @@
name: graphql name: graphql
version: 0.8.0.0 version: 0.9.0.0
synopsis: Haskell GraphQL implementation synopsis: Haskell GraphQL implementation
description: description:
This package provides a rudimentary parser for the This package provides a rudimentary parser for the

View File

@ -5,6 +5,7 @@
{-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-} {-# LANGUAGE LambdaCase #-}
-- | GraphQL validator.
module Language.GraphQL.Validate module Language.GraphQL.Validate
( Error(..) ( Error(..)
, Path(..) , Path(..)
@ -29,17 +30,24 @@ data Context m = Context
type ValidateT m = Reader (Context m) (Seq Error) type ValidateT m = Reader (Context m) (Seq Error)
-- | If an error can be associated to a particular field in the GraphQL result,
-- it must contain an entry with the key path that details the path of the
-- response field which experienced the error. This allows clients to identify
-- whether a null result is intentional or caused by a runtime error.
data Path data Path
= Segment Text = Segment Text -- ^ Field name.
| Index Int | Index Int -- ^ List index if a field returned a list.
deriving (Eq, Show) deriving (Eq, Show)
-- | Validation error.
data Error = Error data Error = Error
{ message :: String { message :: String
, locations :: [Location] , locations :: [Location]
, path :: [Path] , path :: [Path]
} deriving (Eq, Show) } deriving (Eq, Show)
-- | Validates a document and returns a list of found errors. If the returned
-- list is empty, the document is valid.
document :: forall m. Schema m -> [Rule] -> Document -> Seq Error document :: forall m. Schema m -> [Rule] -> Document -> Seq Error
document schema' rules' document' = document schema' rules' document' =
runReader (foldrM go Seq.empty document') context runReader (foldrM go Seq.empty document') context

View File

@ -2,6 +2,7 @@
v. 2.0. If a copy of the MPL was not distributed with this file, You can v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at https://mozilla.org/MPL/2.0/. -} obtain one at https://mozilla.org/MPL/2.0/. -}
-- | This module contains default rules defined in the GraphQL specification.
module Language.GraphQL.Validate.Rules module Language.GraphQL.Validate.Rules
( Rule(..) ( Rule(..)
, executableDefinitionsRule , executableDefinitionsRule
@ -10,14 +11,19 @@ module Language.GraphQL.Validate.Rules
import Language.GraphQL.AST.Document import Language.GraphQL.AST.Document
-- | 'Rule' assigns a function to each AST node that can be validated. If the
-- validation fails, the function should return an error message, or 'Nothing'
-- otherwise.
newtype Rule newtype Rule
= DefinitionRule (Definition -> Maybe String) = DefinitionRule (Definition -> Maybe String)
-- | Default reules given in the specification.
specifiedRules :: [Rule] specifiedRules :: [Rule]
specifiedRules = specifiedRules =
[ executableDefinitionsRule [ executableDefinitionsRule
] ]
-- | Definition must be OperationDefinition or FragmentDefinition.
executableDefinitionsRule :: Rule executableDefinitionsRule :: Rule
executableDefinitionsRule = DefinitionRule go executableDefinitionsRule = DefinitionRule go
where where

View File

@ -1,4 +1,4 @@
resolver: lts-16.5 resolver: lts-16.6
packages: packages:
- . - .