graphql-engine/server/lib/dc-api/test/Test/Specs/ErrorSpec.hs
David Overton a9f77acb32 Remove builtin scalar types from Data Connector backend
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7167
Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com>
GitOrigin-RevId: 926e7282b908e3a9669ac39d625aa54971e11c37
2023-01-11 02:37:26 +00:00

32 lines
1.4 KiB
Haskell

module Test.Specs.ErrorSpec (spec) where
import Control.Lens ((&), (?~))
import Data.Aeson (Value (..))
import Hasura.Backends.DataConnector.API
import Test.AgentClient (queryExpectError)
import Test.Data (TestData (..))
import Test.Data qualified as Data
import Test.Sandwich (describe, shouldBe)
import Test.TestHelpers (AgentTestSpec, it)
spec :: TestData -> SourceName -> Config -> a -> AgentTestSpec
spec TestData {..} sourceName config _capabilities = describe "Error Protocol" do
it "returns a structured error when sending an invalid query" do
receivedArtistsError <- queryExpectError sourceName config brokenQueryRequest
_crType receivedArtistsError `shouldBe` UncaughtError
where
brokenQueryRequest :: QueryRequest
brokenQueryRequest =
let fields = Data.mkFieldsMap [("ArtistId", _tdColumnField _tdArtistsTableName "ArtistId"), ("Name", _tdColumnField _tdArtistsTableName "Name")]
query =
Data.emptyQuery
& qFields ?~ fields
& qWhere
?~ ApplyBinaryComparisonOperator
(CustomBinaryComparisonOperator "FOOBAR")
(_tdCurrentComparisonColumn "ArtistId" artistIdScalarType)
(ScalarValue (Number 1) $ artistIdScalarType)
in QueryRequest _tdArtistsTableName [] query
artistIdScalarType = _tdFindColumnScalarType _tdArtistsTableName "ArtistId"