Deprecate internal error generation functions

The functions generating errors in the executor should be changed anyway
when we provide better error messages from the executor, with the error
location and response path. So public definitions of these functions are
deprecated now and they are replaced by more generic functions in the
executor code.
This commit is contained in:
2021-05-10 09:43:39 +02:00
parent 0d23df3da2
commit 1af95345d2
7 changed files with 57 additions and 30 deletions

View File

@ -8,17 +8,29 @@ module Language.GraphQL.ErrorSpec
) where
import qualified Data.Aeson as Aeson
import qualified Data.Sequence as Seq
import Data.List.NonEmpty (NonEmpty (..))
import Language.GraphQL.Error
import Test.Hspec ( Spec
, describe
, it
, shouldBe
)
import Test.Hspec
( Spec
, describe
, it
, shouldBe
)
import Text.Megaparsec (PosState(..))
import Text.Megaparsec.Error (ParseError(..), ParseErrorBundle(..))
import Text.Megaparsec.Pos (SourcePos(..), mkPos)
spec :: Spec
spec = describe "singleError" $
it "constructs an error with the given message" $
let errors'' = Seq.singleton $ Error "Message." [] []
expected = Response Aeson.Null errors''
in singleError "Message." `shouldBe` expected
spec = describe "parseError" $
it "generates response with a single error" $ do
let parseErrors = TrivialError 0 Nothing mempty :| []
posState = PosState
{ pstateInput = ""
, pstateOffset = 0
, pstateSourcePos = SourcePos "" (mkPos 1) (mkPos 1)
, pstateTabWidth = mkPos 1
, pstateLinePrefix = ""
}
Response Aeson.Null actual <-
parseError (ParseErrorBundle parseErrors posState)
length actual `shouldBe` 1