mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-22 23:11:41 +03:00
67b4e1cc5b
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2403 Co-authored-by: Kali Vara Purushotham Santhati <72007599+purush7@users.noreply.github.com> Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com> Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com> Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com> Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com> GitOrigin-RevId: deaad7afa9df5d3e542cf699e57957de9254f347
48 lines
1.1 KiB
Haskell
48 lines
1.1 KiB
Haskell
-- | A module collecting common HTTP requests to graphql-engine for testing.
|
|
module Hasura.Test.Requests
|
|
( replaceMetadata,
|
|
postgresRunSql,
|
|
v1graphql,
|
|
)
|
|
where
|
|
|
|
import Data.Aeson (encode)
|
|
import Data.Aeson.QQ (aesonQQ)
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Metadata (Metadata)
|
|
import Network.HTTP.Types.Header (Header)
|
|
import Network.HTTP.Types.Method (methodPost)
|
|
import Network.Wai.Test (SResponse)
|
|
import Test.Hspec.Wai (WaiSession)
|
|
import Test.Hspec.Wai qualified as HW
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
replaceMetadata :: Metadata -> WaiSession st SResponse
|
|
replaceMetadata metadata =
|
|
HW.post "/v1/metadata" $
|
|
encode
|
|
[aesonQQ|
|
|
{ type: "replace_metadata"
|
|
, args: { metadata: #{metadata} }
|
|
}
|
|
|]
|
|
|
|
postgresRunSql :: Text -> WaiSession st SResponse
|
|
postgresRunSql rawSql =
|
|
HW.post "/v2/query" $
|
|
encode
|
|
[aesonQQ|
|
|
{ type: "run_sql"
|
|
, args: { sql: #{rawSql} }
|
|
}
|
|
|]
|
|
|
|
v1graphql :: [Header] -> String -> WaiSession st SResponse
|
|
v1graphql headers graphqlQuery =
|
|
HW.request methodPost "/v1/graphql" headers $
|
|
encode
|
|
[aesonQQ|
|
|
{ query: #{graphqlQuery} }
|
|
|]
|