2022-04-01 04:20:23 +03:00
|
|
|
{-# LANGUAGE DeriveAnyClass #-}
|
|
|
|
|
2022-05-02 08:03:12 +03:00
|
|
|
module Hasura.Backends.DataConnector.API.V0.Schema
|
2022-04-01 04:20:23 +03:00
|
|
|
( SchemaResponse (..),
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Autodocodec
|
|
|
|
import Control.DeepSeq (NFData)
|
2022-06-03 11:06:31 +03:00
|
|
|
import Data.Aeson (FromJSON, ToJSON)
|
2022-04-01 04:20:23 +03:00
|
|
|
import Data.Data (Data)
|
|
|
|
import Data.Hashable (Hashable)
|
|
|
|
import Data.OpenApi (ToSchema)
|
|
|
|
import GHC.Generics (Generic)
|
2022-05-02 08:03:12 +03:00
|
|
|
import Hasura.Backends.DataConnector.API.V0.Table qualified as API.V0
|
2022-04-01 04:20:23 +03:00
|
|
|
import Prelude
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- Schema Response
|
|
|
|
|
|
|
|
-- | The Schema Response provides the schemas for tracked tables and
|
|
|
|
-- 'Capabilities' supported by the service.
|
2022-06-03 11:06:31 +03:00
|
|
|
newtype SchemaResponse = SchemaResponse
|
|
|
|
{ srTables :: [API.V0.TableInfo]
|
2022-04-01 04:20:23 +03:00
|
|
|
}
|
|
|
|
deriving stock (Eq, Ord, Show, Generic, Data)
|
|
|
|
deriving anyclass (NFData, Hashable)
|
|
|
|
deriving (FromJSON, ToJSON, ToSchema) via Autodocodec SchemaResponse
|
|
|
|
|
|
|
|
instance HasCodec SchemaResponse where
|
|
|
|
codec =
|
|
|
|
object "SchemaResponse" $
|
2022-06-03 11:06:31 +03:00
|
|
|
SchemaResponse <$> requiredField "tables" "Available tables" .= srTables
|