graphql-engine/server/src-test/Hasura/Backends/Postgres/RQLGenerator/GenAnnSelectG.hs
Solomon f3aac06dd2 Rewrite ir generators
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4094
GitOrigin-RevId: f592adbd686aa7cc78c094d5d4b88f4b62500d18
2022-04-05 22:09:40 +00:00

34 lines
1.2 KiB
Haskell

--
module Hasura.Backends.Postgres.RQLGenerator.GenAnnSelectG
( genAnnSelectG,
)
where
import Hasura.Backends.Postgres.RQLGenerator.GenSelectArgsG (genSelectArgsG)
import Hasura.Backends.Postgres.RQLGenerator.GenSelectFromG (genSelectFromG)
import Hasura.Backends.Postgres.RQLGenerator.GenTablePermG (genTablePermG)
import Hasura.Generator.Common (defaultRange)
import Hasura.Prelude hiding (bool)
import Hasura.RQL.IR.Generator (genFields)
import Hasura.RQL.IR.Select (AnnSelectG (AnnSelectG))
import Hasura.RQL.Types (BackendType (Postgres), PostgresKind (Vanilla), StringifyNumbers (..))
import Hedgehog (MonadGen)
import Hedgehog.Gen qualified as Gen
--------------------------------------------------------------------------------
genAnnSelectG :: forall m f a. MonadGen m => m a -> m (f a) -> m (AnnSelectG ('Postgres 'Vanilla) f a)
genAnnSelectG genA genFA =
AnnSelectG
<$> genFields genFA defaultRange defaultRange
<*> genSelectFromG genA
<*> genTablePermG genA
<*> genArgs
<*> genStringifyNumbers
where
genStringifyNumbers =
Gen.bool <&> \case
False -> LeaveNumbersAlone
True -> StringifyNumbers
genArgs = genSelectArgsG genA