mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
5c7489cc23
> ## Description ✍️ -> Fleshes out the Capabilities types used by Data Connector agents. ### Related Issues ✍ -> https://hasurahq.atlassian.net/browse/GDW-85 ### Solution and Design ✍ > Capabilities are divided into sections for queries, mutation, subscriptions, filtering and relationships: ```haskell data Capabilities = Capabilities { cQueries :: Maybe QueryCapabilities, cMutations :: Maybe MutationCapabilities, cSubscriptions :: Maybe SubscriptionCapabilities, cFiltering :: Maybe FilteringCapabilities, cRelationships :: Maybe RelationshipCapabilities } ``` Each section is optional. If the section is absent it means the the related capabilities are not supported by the agent. The types for each section can contain additional details about exactly what is supported. E.g. ```haskell data QueryCapabilities = QueryCapabilities { qcSupportsPrimaryKeys :: Bool } ``` These are currently mostly empty, but will be filled in later. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4671 GitOrigin-RevId: 3d48570266bfce5e177a543a0ed6f63a7b450f0b
60 lines
2.1 KiB
Haskell
60 lines
2.1 KiB
Haskell
{-# LANGUAGE OverloadedLists #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Hasura.Backends.DataConnector.API.V0.CapabilitiesSpec (spec) where
|
|
|
|
import Data.Aeson.QQ.Simple (aesonQQ)
|
|
import Hasura.Backends.DataConnector.API.V0.Capabilities
|
|
import Hasura.Backends.DataConnector.API.V0.ConfigSchema
|
|
import Hasura.Prelude
|
|
import Hedgehog
|
|
import Hedgehog.Gen qualified as Gen
|
|
import Test.Aeson.Utils
|
|
import Test.Hspec
|
|
|
|
spec :: Spec
|
|
spec = do
|
|
describe "Capabilities" $ do
|
|
testToFromJSONToSchema emptyCapabilities [aesonQQ|{}|]
|
|
jsonOpenApiProperties genCapabilities
|
|
describe "CapabilitiesResponse" $ do
|
|
testToFromJSON
|
|
(CapabilitiesResponse (emptyCapabilities {cRelationships = Just RelationshipCapabilities {}}) emptyConfigSchemaResponse)
|
|
[aesonQQ|{"capabilities": {"relationships": {}}, "configSchemas": {"configSchema": {}, "otherSchemas": {}}}|]
|
|
|
|
genQueryCapabilities :: MonadGen m => m QueryCapabilities
|
|
genQueryCapabilities = QueryCapabilities <$> Gen.bool
|
|
|
|
genMutationCapabilities :: MonadGen m => m MutationCapabilities
|
|
genMutationCapabilities = pure MutationCapabilities {}
|
|
|
|
genSubscriptionCapabilities :: MonadGen m => m SubscriptionCapabilities
|
|
genSubscriptionCapabilities = pure SubscriptionCapabilities {}
|
|
|
|
genBooleanOperators :: MonadGen m => m BooleanOperators
|
|
genBooleanOperators = pure BooleanOperators {}
|
|
|
|
genComparisonOperators :: MonadGen m => m ComparisonOperators
|
|
genComparisonOperators = pure ComparisonOperators {}
|
|
|
|
genFilteringCapabilities :: MonadGen m => m FilteringCapabilities
|
|
genFilteringCapabilities =
|
|
FilteringCapabilities
|
|
<$> genBooleanOperators
|
|
<*> genComparisonOperators
|
|
|
|
genRelationshipCapabilities :: MonadGen m => m RelationshipCapabilities
|
|
genRelationshipCapabilities = pure RelationshipCapabilities {}
|
|
|
|
genCapabilities :: MonadGen m => m Capabilities
|
|
genCapabilities =
|
|
Capabilities
|
|
<$> Gen.maybe genQueryCapabilities
|
|
<*> Gen.maybe genMutationCapabilities
|
|
<*> Gen.maybe genSubscriptionCapabilities
|
|
<*> Gen.maybe genFilteringCapabilities
|
|
<*> Gen.maybe genRelationshipCapabilities
|
|
|
|
emptyConfigSchemaResponse :: ConfigSchemaResponse
|
|
emptyConfigSchemaResponse = ConfigSchemaResponse mempty mempty
|