mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-21 06:21:39 +03:00
d54bb30d3b
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6061 Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com> GitOrigin-RevId: 855d96378030f4e01b0c74b00e20e592e51e7a49
31 lines
1.3 KiB
Haskell
31 lines
1.3 KiB
Haskell
module Test.ErrorSpec (spec) where
|
|
|
|
import Control.Lens ((&), (?~))
|
|
import Hasura.Backends.DataConnector.API
|
|
import Servant.API (NamedRoutes)
|
|
import Servant.Client (Client)
|
|
import Test.Data (TestData (..), errorQuery)
|
|
import Test.Data qualified as Data
|
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
|
import Prelude
|
|
|
|
spec :: TestData -> Client IO (NamedRoutes Routes) -> SourceName -> Config -> a -> Spec
|
|
spec TestData {..} api sourceName config _capabilities = describe "Basic Queries" do
|
|
describe "Error Protocol" do
|
|
it "returns a structured error when sending an invalid query" do
|
|
receivedArtistsError <- errorQuery api sourceName config brokenQueryRequest
|
|
_crType receivedArtistsError `shouldBe` UncaughtError
|
|
where
|
|
brokenQueryRequest :: QueryRequest
|
|
brokenQueryRequest =
|
|
let fields = Data.mkFieldsMap [("ArtistId", _tdColumnField "ArtistId"), ("Name", _tdColumnField "Name")]
|
|
query =
|
|
Data.emptyQuery
|
|
& qFields ?~ fields
|
|
& qWhere
|
|
?~ ApplyBinaryComparisonOperator
|
|
(CustomBinaryComparisonOperator "FOOBAR")
|
|
(ComparisonColumn CurrentTable (ColumnName "ArtistId"))
|
|
(ScalarValue "1")
|
|
in QueryRequest _tdArtistsTableName [] query
|