2022-06-27 19:32:25 +03:00
|
|
|
module Hasura.Metadata.DTO.MetadataV1 (MetadataV1 (..)) where
|
|
|
|
|
|
|
|
import Autodocodec (Autodocodec (Autodocodec), HasCodec (codec), object, optionalField, requiredField, (.=))
|
2023-04-25 11:59:34 +03:00
|
|
|
import Autodocodec.Extended (optionalVersionField)
|
2022-06-27 19:32:25 +03:00
|
|
|
import Autodocodec.OpenAPI ()
|
|
|
|
import Data.Aeson (FromJSON, ToJSON)
|
|
|
|
import Data.OpenApi qualified as OpenApi
|
|
|
|
import Hasura.Metadata.DTO.Placeholder (PlaceholderArray)
|
|
|
|
import Hasura.Prelude
|
|
|
|
|
|
|
|
-- | Revision 1 of the Metadata export format. Note that values of the types,
|
|
|
|
-- 'PlaceholderArray' and 'PlaceholderObject' are placeholders that will
|
|
|
|
-- eventually be expanded to represent more detail.
|
|
|
|
data MetadataV1 = MetadataV1
|
|
|
|
{ metaV1Functions :: Maybe PlaceholderArray,
|
|
|
|
metaV1RemoteSchemas :: Maybe PlaceholderArray,
|
|
|
|
metaV1Tables :: PlaceholderArray
|
|
|
|
}
|
|
|
|
deriving stock (Show, Eq, Generic)
|
|
|
|
deriving (FromJSON, ToJSON, OpenApi.ToSchema) via (Autodocodec MetadataV1)
|
|
|
|
|
|
|
|
instance HasCodec MetadataV1 where
|
|
|
|
codec =
|
2023-05-24 16:51:56 +03:00
|
|
|
object "MetadataV1"
|
|
|
|
$ MetadataV1
|
|
|
|
<$ optionalVersionField 1
|
|
|
|
<*> optionalField "functions" "user-defined SQL functions"
|
|
|
|
.= metaV1Functions
|
|
|
|
<*> optionalField "remote_schemas" "merge remote GraphQL schemas and provide a unified GraphQL API"
|
|
|
|
.= metaV1RemoteSchemas
|
|
|
|
<*> requiredField "tables" "configured database tables"
|
|
|
|
.= metaV1Tables
|