graphql-engine/server/src-gdw-api/Hasura/Backends/DataWrapper/API.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.0 KiB
Haskell
Raw Normal View History

--
module Hasura.Backends.DataWrapper.API
( module V0,
Api,
SchemaApi,
QueryApi,
openApiSchema,
)
where
import Data.Data (Proxy (..))
import Data.OpenApi (OpenApi)
import Hasura.Backends.DataWrapper.API.V0.API as V0
import Servant.API
import Servant.API.Generic
import Servant.OpenApi
--------------------------------------------------------------------------------
-- Servant Routes
type SchemaApi =
"schema"
:> Get '[JSON] V0.SchemaResponse
type QueryApi =
"query"
:> ReqBody '[JSON] V0.Query
:> Post '[JSON] V0.QueryResponse
data Routes mode = Routes
{ -- | 'GET /schema'
_schema :: mode :- SchemaApi,
-- | 'POST /query'
_query :: mode :- QueryApi
}
deriving stock (Generic)
-- | servant-openapi3 does not (yet) support NamedRoutes so we need to compose the
-- API the old-fashioned way using :<|> for use by @toOpenApi@
type Api = SchemaApi :<|> QueryApi
-- | Provide an OpenApi 3.0 schema for the API
openApiSchema :: OpenApi
openApiSchema = toOpenApi (Proxy :: Proxy Api)