mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
1f14781d15
dupe of @chrisdone's work https://github.com/hasura/graphql-engine-mono/pull/2829 with a branch rename PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2901 Co-authored-by: Chris Done <11019+chrisdone@users.noreply.github.com> GitOrigin-RevId: 8381e53a18242b75d7e17b18a2ba3b2d99dd1322
34 lines
1.0 KiB
Haskell
34 lines
1.0 KiB
Haskell
-- | Helpers for talking to graphql engine.
|
|
module Harness.GraphqlEngine
|
|
( post,
|
|
post_,
|
|
postGraphql,
|
|
postGraphqlYaml,
|
|
)
|
|
where
|
|
|
|
import Data.Aeson
|
|
import Data.Functor
|
|
import GHC.Stack
|
|
import Harness.Constants qualified as Constants
|
|
import Harness.Http qualified as Http
|
|
import Prelude
|
|
|
|
-- | Post some JSON to graphql-engine, getting back more
|
|
-- JSON. Optimistically assumes success. Use another function if you
|
|
-- want to test for failure.
|
|
post :: HasCallStack => String -> Value -> IO Value
|
|
post path = Http.postValue_ (Constants.graphqlEngineUrlPrefix ++ path)
|
|
|
|
-- | Same as post, but ignores the value.
|
|
post_ :: HasCallStack => String -> Value -> IO ()
|
|
post_ path = void . post path
|
|
|
|
-- | Same as post, but defaults to the graphql end-point.
|
|
postGraphqlYaml :: HasCallStack => Value -> IO Value
|
|
postGraphqlYaml = post "/v1/graphql"
|
|
|
|
-- | Same as 'postGraphqlYaml', but adds the {query:..} wrapper.
|
|
postGraphql :: HasCallStack => Value -> IO Value
|
|
postGraphql value = postGraphqlYaml (object ["query" .= value])
|