Extract dc-api and its tests from graphql-engine.cabal

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6000
Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com>
GitOrigin-RevId: d8f3cd0194191ab4c51a5a7d350cb2c3a0a5a7f3
This commit is contained in:
Tom Harding 2022-09-27 09:20:46 +02:00 committed by hasura-bot
parent 8e05e51f1b
commit a1c5ac46f6
42 changed files with 157 additions and 120 deletions

View File

@ -7,7 +7,7 @@ Requirements:
Once node is installed, run `npm ci` to restore all npm packages.
## Project Structure
- `dc-api-types` - These are the TypeScript types, generated from the OpenAPI spec of the Data Connector Agent API. The OpenAPI spec is generated from our Haskell types in `/server/src-dc-api`.
- `dc-api-types` - These are the TypeScript types, generated from the OpenAPI spec of the Data Connector Agent API. The OpenAPI spec is generated from our Haskell types in `/server/lib/dc-api/src`.
- `reference` - The Reference agent that serves as an example implementation of a Data Connector agent
- `sqlite` - The SQLite Data Connector agent
- `sdk` - Assets that go into the Data Connector SDK zip file

View File

@ -36,7 +36,7 @@ start-reference-agent:
start-sqlite-agent:
npm start -w sqlite
TESTS_DC_API := cabal run test:tests-dc-api --
TESTS_DC_API := cabal run dc-api:test:tests-dc-api --
.PHONY: generate-types
## generate-types: Generates the TypeScript API types in dc-api-types

View File

@ -90,7 +90,7 @@ The dataset used for testing the reference agent is sourced from:
Run:
```sh
cabal run graphql-engine:test:tests-dc-api -- test --agent-base-url http://localhost:8100 --agent-config '{"db": "db.chinook2.sqlite"}'
cabal run dc-api:test:tests-dc-api -- test --agent-base-url http://localhost:8100 --agent-config '{"db": "db.chinook2.sqlite"}'
```
From the HGE repo.

View File

@ -1,9 +1,9 @@
cradle:
cabal:
- path: "./server/src-dc-api"
component: "graphql-engine:lib:dc-api"
- path: "./server/tests-dc-api"
component: "graphql-engine:test:tests-dc-api"
- path: "./server/lib/dc-api/src"
component: "dc-api:lib:dc-api"
- path: "./server/lib/dc-api/test"
component: "dc-api:test:tests-dc-api"
- path: "./server/src-lib"
component: "graphql-engine:lib:graphql-engine"

View File

@ -25,10 +25,6 @@ extra-source-files:
src-rsr/mssql_table_metadata.sql
src-rsr/catalog_versions.txt
src-rsr/catalog_version.txt
-- Test data used by Data Connector agent tests
src/tests-dc-api/Test/Data/ChinookData.xml.gz
src/tests-dc-api/Test/Data/schema-tables.json
source-repository head
type: git
@ -352,51 +348,6 @@ common lib-depends
-- ghc-heap-view can't be built with profiling
build-depends: ghc-heap-view
library dc-api
import: common-all
hs-source-dirs: src-dc-api
build-depends: aeson
, autodocodec
, autodocodec-openapi3
, base
, bytestring
, deepseq
, extra
, graphql-parser
, hashable
, insert-ordered-containers
, lens
, lens-aeson
, openapi3
, scientific
, servant
, servant-client
, servant-client-core
, servant-openapi3
, text
, unordered-containers
, http-media
if !flag(profiling)
-- ghc-heap-view can't be built with profiling
build-depends: ghc-heap-view
exposed-modules: Autodocodec.Extended
, Hasura.Backends.DataConnector.API
, Hasura.Backends.DataConnector.API.V0
, Hasura.Backends.DataConnector.API.V0.Aggregate
, Hasura.Backends.DataConnector.API.V0.Capabilities
, Hasura.Backends.DataConnector.API.V0.Column
, Hasura.Backends.DataConnector.API.V0.ConfigSchema
, Hasura.Backends.DataConnector.API.V0.Expression
, Hasura.Backends.DataConnector.API.V0.OrderBy
, Hasura.Backends.DataConnector.API.V0.Query
, Hasura.Backends.DataConnector.API.V0.Raw
, Hasura.Backends.DataConnector.API.V0.Explain
, Hasura.Backends.DataConnector.API.V0.Relationships
, Hasura.Backends.DataConnector.API.V0.Scalar
, Hasura.Backends.DataConnector.API.V0.Schema
, Hasura.Backends.DataConnector.API.V0.Table
library
import: common-all, lib-depends
hs-source-dirs: src-lib
@ -1338,63 +1289,3 @@ test-suite tests-hspec
Test.ServiceLivenessSpec
Test.SQLServer.InsertVarcharColumnSpec
Test.Subscriptions.CustomFieldsSpec
test-suite tests-dc-api
import: common-all, common-exe
type: exitcode-stdio-1.0
build-depends:
, Diff
, aeson
, ansi-terminal
, autodocodec
, autodocodec-openapi3
, base
, bytestring
, case-insensitive
, data-fix
, deepseq
, dc-api
, file-embed
, hashable
, hspec
, hspec-core
, http-client
, lens
, lens-aeson
, mtl
, network-uri
, openapi3
, optparse-applicative
, scientific
, servant
, servant-client
, servant-client-core
, servant-openapi3
, text
, unordered-containers
, vector
, xml-conduit
, xml-lens
, yaml
, zlib
hs-source-dirs: tests-dc-api
-- Turning off optimizations is intentional; tests aren't
-- performance sensitive and waiting for compilation is a problem.
ghc-options: -Wall -O0 -threaded
main-is: Main.hs
other-modules:
Command
, Paths_graphql_engine
, Test.Data
, Test.CapabilitiesSpec
, Test.Expectations
, Test.HealthSpec
, Test.MetricsSpec
, Test.ExplainSpec
, Test.QuerySpec
, Test.QuerySpec.AggregatesSpec
, Test.QuerySpec.BasicSpec
, Test.QuerySpec.FilteringSpec
, Test.QuerySpec.OrderBySpec
, Test.QuerySpec.RelationshipsSpec
, Test.SchemaSpec

View File

@ -0,0 +1,146 @@
cabal-version: 3.0
name: dc-api
version: 1.0.0
extra-source-files:
test/Test/Data/ChinookData.xml.gz
test/Test/Data/schema-tables.json
flag profiling
description: Configures the project to be profiling-compatible
default: False
manual: True
common common-all
default-language: Haskell2010
default-extensions:
BlockArguments
DataKinds
DeriveDataTypeable
DeriveFunctor
DeriveGeneric
DerivingStrategies
DerivingVia
FlexibleContexts
GADTs
GeneralizedNewtypeDeriving
ImportQualifiedPost
LambdaCase
MultiParamTypeClasses
NamedFieldPuns
OverloadedStrings
RankNTypes
RecordWildCards
ScopedTypeVariables
TupleSections
TypeApplications
TypeFamilies
TypeOperators
library
import: common-all
hs-source-dirs: src
build-depends:
aeson,
autodocodec,
autodocodec-openapi3,
base,
bytestring,
deepseq,
extra,
graphql-parser,
hashable,
insert-ordered-containers,
lens,
lens-aeson,
openapi3,
scientific,
servant,
servant-client,
servant-client-core,
servant-openapi3,
text,
unordered-containers,
http-media
if !flag(profiling)
-- ghc-heap-view can't be built with profiling
build-depends: ghc-heap-view
exposed-modules:
Autodocodec.Extended
Hasura.Backends.DataConnector.API
Hasura.Backends.DataConnector.API.V0
Hasura.Backends.DataConnector.API.V0.Aggregate
Hasura.Backends.DataConnector.API.V0.Capabilities
Hasura.Backends.DataConnector.API.V0.Column
Hasura.Backends.DataConnector.API.V0.ConfigSchema
Hasura.Backends.DataConnector.API.V0.Expression
Hasura.Backends.DataConnector.API.V0.OrderBy
Hasura.Backends.DataConnector.API.V0.Query
Hasura.Backends.DataConnector.API.V0.Explain
Hasura.Backends.DataConnector.API.V0.Raw
Hasura.Backends.DataConnector.API.V0.Relationships
Hasura.Backends.DataConnector.API.V0.Scalar
Hasura.Backends.DataConnector.API.V0.Schema
Hasura.Backends.DataConnector.API.V0.Table
test-suite tests-dc-api
import: common-all
type: exitcode-stdio-1.0
build-depends:
Diff,
aeson,
ansi-terminal,
autodocodec,
autodocodec-openapi3,
base,
bytestring,
case-insensitive,
data-fix,
deepseq,
dc-api,
file-embed,
hashable,
hspec,
hspec-core,
http-client,
lens,
lens-aeson,
mtl,
network-uri,
openapi3,
optparse-applicative,
scientific,
servant,
servant-client,
servant-client-core,
servant-openapi3,
text,
unordered-containers,
vector,
xml-conduit,
xml-lens,
yaml,
zlib
hs-source-dirs: test
-- Turning off optimizations is intentional; tests aren't
-- performance sensitive and waiting for compilation is a problem.
ghc-options: -Wall -O0 -threaded
main-is: Main.hs
other-modules:
Command
Paths_dc_api
Test.Data
Test.CapabilitiesSpec
Test.Expectations
Test.HealthSpec
Test.MetricsSpec
Test.ExplainSpec
Test.QuerySpec
Test.QuerySpec.AggregatesSpec
Test.QuerySpec.BasicSpec
Test.QuerySpec.FilteringSpec
Test.QuerySpec.OrderBySpec
Test.QuerySpec.RelationshipsSpec
Test.SchemaSpec

View File

@ -22,7 +22,7 @@ import Data.Text.Encoding qualified as Text
import Data.Version (showVersion)
import Hasura.Backends.DataConnector.API qualified as API
import Options.Applicative
import Paths_graphql_engine qualified as PackageInfo
import Paths_dc_api qualified as PackageInfo
import Servant.Client (BaseUrl, parseBaseUrl)
import Prelude

View File

@ -102,7 +102,7 @@ import Text.XML.Lens qualified as XML
import Prelude
schemaBS :: ByteString
schemaBS = $(makeRelativeToProject "tests-dc-api/Test/Data/schema-tables.json" >>= embedFile)
schemaBS = $(makeRelativeToProject "test/Test/Data/schema-tables.json" >>= embedFile)
schemaTables :: [API.TableInfo]
schemaTables = sortOn API._tiName . either error id . eitherDecodeStrict $ schemaBS
@ -111,7 +111,7 @@ numericColumns :: [API.ColumnName]
numericColumns = schemaTables >>= (API._tiColumns >>> mapMaybe (\API.ColumnInfo {..} -> if _ciType == API.NumberTy then Just _ciName else Nothing))
chinookXmlBS :: ByteString
chinookXmlBS = $(makeRelativeToProject "tests-dc-api/Test/Data/ChinookData.xml.gz" >>= embedFile)
chinookXmlBS = $(makeRelativeToProject "test/Test/Data/ChinookData.xml.gz" >>= embedFile)
chinookXml :: XML.Document
chinookXml = XML.parseLBS_ XML.def . GZip.decompress $ BSL.fromStrict chinookXmlBS

View File

@ -0,0 +1 @@
../../../../../../dc-agents/reference/src/data/ChinookData.xml.gz

View File

@ -1 +0,0 @@
../../../../dc-agents/reference/src/data/ChinookData.xml.gz