graphql-engine/server/src-gdw-api/Hasura/Backends/DataWrapper/API/V0/Schema.hs
Daniel Chambers a70e4979ee Moved GDW API types into their own internal lib
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4120
GitOrigin-RevId: e7688fdc5a5621c0b760c9169ebf61ce2aea4913
2022-04-01 01:21:29 +00:00

53 lines
1.7 KiB
Haskell

{-# LANGUAGE DeriveAnyClass #-}
module Hasura.Backends.DataWrapper.API.V0.Schema
( SchemaResponse (..),
Capabilities (..),
)
where
import Autodocodec
import Control.DeepSeq (NFData)
import Data.Aeson (FromJSON, ToJSON)
import Data.Data (Data)
import Data.Hashable (Hashable)
import Data.OpenApi (ToSchema)
import GHC.Generics (Generic)
import Hasura.Backends.DataWrapper.API.V0.Table qualified as API.V0
import Prelude
--------------------------------------------------------------------------------
-- Schema Response
-- | The Schema Response provides the schemas for tracked tables and
-- 'Capabilities' supported by the service.
data SchemaResponse = SchemaResponse
{ srCapabilities :: Capabilities,
srTables :: [API.V0.TableInfo]
}
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" $
SchemaResponse
<$> requiredField "capabilities" "Capabilities of the agent" .= srCapabilities
<*> requiredField "tables" "Available tables" .= srTables
-- | The 'Capabilities' describes the _capabilities_ of the
-- service. Specifically, the service is capable of serving queries
-- which involve relationships.
data Capabilities = Capabilities
{ dcRelationships :: Bool
}
deriving stock (Eq, Ord, Show, Generic, Data)
deriving anyclass (NFData, Hashable)
deriving (FromJSON, ToJSON, ToSchema) via Autodocodec Capabilities
instance HasCodec Capabilities where
codec =
object "Capabilities" $
Capabilities <$> requiredField "relationships" "Does the agent support relationships?" .= dcRelationships