mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 21:12:09 +03:00
dc83352863
[GDC-487]: https://hasurahq.atlassian.net/browse/GDC-487?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [GDC-488]: https://hasurahq.atlassian.net/browse/GDC-488?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8182 GitOrigin-RevId: 712953666e1a5ea07500f1e1aed669f27650f7a4
30 lines
1.2 KiB
Haskell
30 lines
1.2 KiB
Haskell
module Test.Specs.ExplainSpec (spec) where
|
|
|
|
import Control.Lens ((&), (?~))
|
|
import Hasura.Backends.DataConnector.API (Capabilities (..), ExplainResponse (..), QueryRequest (..), qFields)
|
|
import Test.AgentAPI (explain)
|
|
import Test.Data (TestData (..))
|
|
import Test.Data qualified as Data
|
|
import Test.Sandwich (describe, shouldNotBe)
|
|
import Test.TestHelpers (AgentDatasetTestSpec, it)
|
|
import Prelude
|
|
|
|
-- Note:
|
|
-- We currently simply check that for a basic query the explain plan is not empty.
|
|
-- There may be additional tests for explain-plans in HGE that we can leverage.
|
|
--
|
|
spec :: TestData -> Capabilities -> AgentDatasetTestSpec
|
|
spec TestData {..} _ = do
|
|
describe "Explain API" do
|
|
it "can generate an explain plan a query for a list of artists" $ do
|
|
let query = artistsQueryRequest
|
|
ExplainResponse {..} <- explain query
|
|
_erQuery `shouldNotBe` ""
|
|
_erLines `shouldNotBe` []
|
|
where
|
|
artistsQueryRequest :: QueryRequest
|
|
artistsQueryRequest =
|
|
let fields = Data.mkFieldsMap [("ArtistId", _tdColumnField _tdArtistsTableName "ArtistId"), ("Name", _tdColumnField _tdArtistsTableName "Name")]
|
|
query = Data.emptyQuery & qFields ?~ fields
|
|
in QueryRequest _tdArtistsTableName [] query Nothing
|