Skip to content

Commit b4f8956

Browse files
solomon-bhasura-bot
authored andcommitted
GDC: Integration Tests and Servant Agent
PR-URL: hasura/graphql-engine-mono#4467 GitOrigin-RevId: 5e81d8581197c90ad2de9106e724c63d7592ae72
1 parent 3db2411 commit b4f8956

25 files changed

Lines changed: 3571 additions & 19 deletions

File tree

cabal.project.freeze

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ constraints: any.Cabal ==3.2.1.0,
346346
any.servant-client ==0.19,
347347
any.servant-client-core ==0.19,
348348
any.servant-openapi3 ==2.0.1.3,
349+
any.servant-server ==0.19.1,
349350
any.setenv ==0.1.1.3,
350351
any.shakespeare ==2.0.25.1,
351352
shakespeare -test_coffee -test_export -test_roy,
@@ -444,6 +445,7 @@ constraints: any.Cabal ==3.2.1.0,
444445
void -safe,
445446
any.wai ==3.2.3,
446447
any.wai-extra ==3.1.8,
448+
any.wai-app-static ==3.1.7.4,
447449
wai-extra -build-example,
448450
any.wai-logger ==2.4.0,
449451
any.warp ==3.3.19,

server/graphql-engine.cabal

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,25 @@ library dc-api
137137
, autodocodec-openapi3
138138
, base
139139
, bytestring
140+
, containers
140141
, deepseq
142+
, file-embed
141143
, hashable
142144
, insert-ordered-containers
143145
, lens
144146
, lens-aeson
147+
, mtl
145148
, openapi3
146149
, scientific
147150
, servant
148151
, servant-client
149152
, servant-client-core
150153
, servant-openapi3
154+
, servant-server
151155
, text
152156
, unordered-containers
157+
, vector
158+
, warp
153159
if !flag(profiling)
154160
-- ghc-heap-view can't be built with profiling
155161
build-depends: ghc-heap-view
@@ -166,6 +172,10 @@ library dc-api
166172
, Hasura.Backends.DataConnector.API.V0.Scalar.Value
167173
, Hasura.Backends.DataConnector.API.V0.Schema
168174
, Hasura.Backends.DataConnector.API.V0.Table
175+
, Hasura.Backends.DataConnector.Agent.Data
176+
, Hasura.Backends.DataConnector.Agent.Query
177+
, Hasura.Backends.DataConnector.Agent.Schema
178+
, Hasura.Backends.DataConnector.Agent.Server
169179

170180
library
171181
import: common-all
@@ -1003,6 +1013,7 @@ test-suite tests-hspec
10031013
, dependent-map
10041014
, dependent-sum
10051015
, ekg-core
1016+
, dc-api
10061017
, graphql-engine
10071018
, graphql-parser
10081019
, haskell-src-meta
@@ -1088,6 +1099,7 @@ test-suite tests-hspec
10881099
-- Harness.Backend
10891100
Harness.Backend.BigQuery
10901101
Harness.Backend.Citus
1102+
Harness.Backend.DataConnector
10911103
Harness.Backend.Mysql
10921104
Harness.Backend.Postgres
10931105
Harness.Backend.Sqlserver
@@ -1108,6 +1120,7 @@ test-suite tests-hspec
11081120
Test.ColumnPresetsSpec
11091121
Test.CustomFieldNamesSpec
11101122
Test.DirectivesSpec
1123+
Test.DC.QuerySpec
11111124
Test.EventTriggersRunSQLSpec
11121125
Test.HelloWorldSpec
11131126
Test.InsertCheckPermissionSpec

server/src-dc-api/Hasura/Backends/DataConnector/API.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module Hasura.Backends.DataConnector.API
33
( module V0,
44
Api,
5+
ConfigSchemaApi,
56
SchemaApi,
67
QueryApi,
78
ConfigHeader,

server/src-dc-api/Hasura/Backends/DataConnector/API/V0/ConfigSchema.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ where
1111

1212
import Control.DeepSeq (NFData)
1313
import Control.Lens ((%~), (&), (.~), (^?))
14-
import Data.Aeson (FromJSON (..), Object, ToJSON (..), Value (..), encode, object, withObject, (.:), (.=), (<?>))
14+
import Data.Aeson (FromJSON (..), Object, ToJSON (..), Value (..), eitherDecode, encode, object, withObject, (.:), (.=), (<?>))
1515
import Data.Aeson.Lens (AsPrimitive (..), key, members, values)
1616
import Data.Aeson.Types (JSONPathElement (..))
17+
import Data.Bifunctor (first)
1718
import Data.ByteString.Lazy qualified as BSL
1819
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
1920
import Data.Hashable (Hashable)
@@ -23,13 +24,17 @@ import Data.OpenApi qualified as OpenApi
2324
import Data.Text (Text)
2425
import Data.Text qualified as Text
2526
import Data.Text.Encoding qualified as Text
26-
import Servant.API (ToHttpApiData (..))
27+
import Servant.API (FromHttpApiData (..), ToHttpApiData (..))
2728
import Prelude
2829

2930
newtype Config = Config {unConfig :: Object}
3031
deriving stock (Eq, Show, Ord)
3132
deriving newtype (Hashable, NFData, ToJSON, FromJSON)
3233

34+
instance FromHttpApiData Config where
35+
parseUrlPiece = first Text.pack . eitherDecode . BSL.fromStrict . Text.encodeUtf8
36+
parseHeader = first Text.pack . eitherDecode . BSL.fromStrict
37+
3338
instance ToHttpApiData Config where
3439
toUrlPiece (Config val) = Text.decodeUtf8 . BSL.toStrict $ encode val
3540
toHeader (Config val) = BSL.toStrict $ encode val

server/src-dc-api/Hasura/Backends/DataConnector/API/V0/Table.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ where
1212
import Autodocodec
1313
import Autodocodec.OpenAPI ()
1414
import Control.DeepSeq (NFData)
15-
import Data.Aeson (FromJSON, ToJSON)
15+
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
1616
import Data.Data (Data)
1717
import Data.Hashable (Hashable)
1818
import Data.OpenApi (ToSchema)
@@ -26,6 +26,7 @@ import Prelude
2626
newtype TableName = TableName {unTableName :: Text}
2727
deriving stock (Eq, Ord, Show, Generic, Data)
2828
deriving anyclass (NFData, Hashable)
29+
deriving newtype (FromJSONKey, ToJSONKey)
2930
deriving (FromJSON, ToJSON, ToSchema) via Autodocodec TableName
3031

3132
instance HasCodec TableName where

0 commit comments

Comments
 (0)