mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-11 10:46:25 +03:00
Rename Data Wrapper to Data Connector [GDW-89]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4400 GitOrigin-RevId: 2d90542f95ef4dad70c8dfe1ca3b4c1f3bdaa527
This commit is contained in:
parent
53ca4da79d
commit
4f835623b1
@ -423,8 +423,6 @@ constraints: any.Cabal ==3.2.1.0,
|
||||
any.unliftio-core ==0.2.0.1,
|
||||
any.unordered-containers ==0.2.15.0,
|
||||
unordered-containers -debug,
|
||||
any.uri-bytestring ==0.3.3.1,
|
||||
uri-bytestring -lib-werror,
|
||||
any.uri-encode ==1.5.0.7,
|
||||
uri-encode +network-uri -tools,
|
||||
any.url ==2.1.3,
|
||||
|
@ -129,9 +129,9 @@ common common-exe
|
||||
-- workaround for limitations in monitoring tools than anything...
|
||||
"-with-rtsopts=-N -I0 -T -qn2 -kc8K --disable-delayed-os-memory-return"
|
||||
|
||||
library gdw-api
|
||||
library dc-api
|
||||
import: common-all
|
||||
hs-source-dirs: src-gdw-api
|
||||
hs-source-dirs: src-dc-api
|
||||
build-depends: aeson
|
||||
, autodocodec
|
||||
, autodocodec-openapi3
|
||||
@ -153,16 +153,16 @@ library gdw-api
|
||||
build-depends: ghc-heap-view
|
||||
|
||||
exposed-modules: Autodocodec.Extended
|
||||
, Hasura.Backends.DataWrapper.API
|
||||
, Hasura.Backends.DataWrapper.API.V0.API
|
||||
, Hasura.Backends.DataWrapper.API.V0.Column
|
||||
, Hasura.Backends.DataWrapper.API.V0.Expression
|
||||
, Hasura.Backends.DataWrapper.API.V0.OrderBy
|
||||
, Hasura.Backends.DataWrapper.API.V0.Query
|
||||
, Hasura.Backends.DataWrapper.API.V0.Scalar.Type
|
||||
, Hasura.Backends.DataWrapper.API.V0.Scalar.Value
|
||||
, Hasura.Backends.DataWrapper.API.V0.Schema
|
||||
, Hasura.Backends.DataWrapper.API.V0.Table
|
||||
, Hasura.Backends.DataConnector.API
|
||||
, Hasura.Backends.DataConnector.API.V0.API
|
||||
, Hasura.Backends.DataConnector.API.V0.Column
|
||||
, Hasura.Backends.DataConnector.API.V0.Expression
|
||||
, Hasura.Backends.DataConnector.API.V0.OrderBy
|
||||
, Hasura.Backends.DataConnector.API.V0.Query
|
||||
, Hasura.Backends.DataConnector.API.V0.Scalar.Type
|
||||
, Hasura.Backends.DataConnector.API.V0.Scalar.Value
|
||||
, Hasura.Backends.DataConnector.API.V0.Schema
|
||||
, Hasura.Backends.DataConnector.API.V0.Table
|
||||
|
||||
library
|
||||
import: common-all
|
||||
@ -185,7 +185,7 @@ library
|
||||
, either
|
||||
, exceptions
|
||||
, fast-logger
|
||||
, gdw-api
|
||||
, dc-api
|
||||
, free
|
||||
, hashable
|
||||
, hashable-time
|
||||
@ -367,11 +367,6 @@ library
|
||||
, mysql
|
||||
, mysql-simple
|
||||
|
||||
-- TODO(jkachmar): re-organize this before merging
|
||||
-- dynamic backends stuff
|
||||
, uri-bytestring
|
||||
, witch
|
||||
|
||||
if !flag(profiling)
|
||||
-- ghc-heap-view can't be built with profiling
|
||||
build-depends: ghc-heap-view
|
||||
@ -547,28 +542,28 @@ library
|
||||
, Hasura.Backends.MySQL.ToQuery
|
||||
, Hasura.Backends.MySQL.Instances.API
|
||||
|
||||
-- GraphQL Data Wrappers
|
||||
, Hasura.Backends.DataWrapper.Adapter.API
|
||||
, Hasura.Backends.DataWrapper.Adapter.Backend
|
||||
, Hasura.Backends.DataWrapper.Adapter.Execute
|
||||
, Hasura.Backends.DataWrapper.Adapter.Metadata
|
||||
, Hasura.Backends.DataWrapper.Adapter.Schema
|
||||
, Hasura.Backends.DataWrapper.Adapter.Transport
|
||||
, Hasura.Backends.DataWrapper.Adapter.Types
|
||||
, Hasura.Backends.DataWrapper.Agent.Client
|
||||
, Hasura.Backends.DataWrapper.IR.Column
|
||||
, Hasura.Backends.DataWrapper.IR.Expression
|
||||
, Hasura.Backends.DataWrapper.IR.Export
|
||||
, Hasura.Backends.DataWrapper.IR.Function
|
||||
, Hasura.Backends.DataWrapper.IR.Name
|
||||
, Hasura.Backends.DataWrapper.IR.OrderBy
|
||||
, Hasura.Backends.DataWrapper.IR.Query
|
||||
, Hasura.Backends.DataWrapper.IR.Scalar.Type
|
||||
, Hasura.Backends.DataWrapper.IR.Scalar.Value
|
||||
, Hasura.Backends.DataWrapper.IR.Table
|
||||
, Hasura.Backends.DataWrapper.Plan
|
||||
, Hasura.Backends.DataWrapper.Schema.Column
|
||||
, Hasura.Backends.DataWrapper.Schema.Table
|
||||
-- GraphQL Data Connector
|
||||
, Hasura.Backends.DataConnector.Adapter.API
|
||||
, Hasura.Backends.DataConnector.Adapter.Backend
|
||||
, Hasura.Backends.DataConnector.Adapter.Execute
|
||||
, Hasura.Backends.DataConnector.Adapter.Metadata
|
||||
, Hasura.Backends.DataConnector.Adapter.Schema
|
||||
, Hasura.Backends.DataConnector.Adapter.Transport
|
||||
, Hasura.Backends.DataConnector.Adapter.Types
|
||||
, Hasura.Backends.DataConnector.Agent.Client
|
||||
, Hasura.Backends.DataConnector.IR.Column
|
||||
, Hasura.Backends.DataConnector.IR.Expression
|
||||
, Hasura.Backends.DataConnector.IR.Export
|
||||
, Hasura.Backends.DataConnector.IR.Function
|
||||
, Hasura.Backends.DataConnector.IR.Name
|
||||
, Hasura.Backends.DataConnector.IR.OrderBy
|
||||
, Hasura.Backends.DataConnector.IR.Query
|
||||
, Hasura.Backends.DataConnector.IR.Scalar.Type
|
||||
, Hasura.Backends.DataConnector.IR.Scalar.Value
|
||||
, Hasura.Backends.DataConnector.IR.Table
|
||||
, Hasura.Backends.DataConnector.Plan
|
||||
, Hasura.Backends.DataConnector.Schema.Column
|
||||
, Hasura.Backends.DataConnector.Schema.Table
|
||||
|
||||
-- Exposed for benchmark:
|
||||
, Hasura.Cache.Bounded
|
||||
@ -867,7 +862,7 @@ test-suite graphql-engine-tests
|
||||
, dependent-map
|
||||
, dependent-sum
|
||||
, ekg-core
|
||||
, gdw-api
|
||||
, dc-api
|
||||
, free
|
||||
, graphql-engine
|
||||
, graphql-parser
|
||||
@ -931,21 +926,21 @@ test-suite graphql-engine-tests
|
||||
Data.TrieSpec
|
||||
Database.MSSQL.TransactionSpec
|
||||
Hasura.AppSpec
|
||||
Hasura.Backends.DataWrapper.API.V0Spec
|
||||
Hasura.Backends.DataWrapper.API.V0.ColumnSpec
|
||||
Hasura.Backends.DataWrapper.API.V0.ExpressionSpec
|
||||
Hasura.Backends.DataWrapper.API.V0.OrderBySpec
|
||||
Hasura.Backends.DataWrapper.API.V0.QuerySpec
|
||||
Hasura.Backends.DataWrapper.API.V0.Scalar.TypeSpec
|
||||
Hasura.Backends.DataWrapper.API.V0.Scalar.ValueSpec
|
||||
Hasura.Backends.DataWrapper.API.V0.SchemaSpec
|
||||
Hasura.Backends.DataWrapper.API.V0.TableSpec
|
||||
Hasura.Backends.DataWrapper.RQLGenerator
|
||||
Hasura.Backends.DataWrapper.RQLGenerator.GenAnnSelectG
|
||||
Hasura.Backends.DataWrapper.RQLGenerator.GenCommon
|
||||
Hasura.Backends.DataWrapper.RQLGenerator.GenTablePermG
|
||||
Hasura.Backends.DataWrapper.RQLGenerator.GenSelectArgsG
|
||||
Hasura.Backends.DataWrapper.RQLGenerator.GenSelectFromG
|
||||
Hasura.Backends.DataConnector.API.V0Spec
|
||||
Hasura.Backends.DataConnector.API.V0.ColumnSpec
|
||||
Hasura.Backends.DataConnector.API.V0.ExpressionSpec
|
||||
Hasura.Backends.DataConnector.API.V0.OrderBySpec
|
||||
Hasura.Backends.DataConnector.API.V0.QuerySpec
|
||||
Hasura.Backends.DataConnector.API.V0.Scalar.TypeSpec
|
||||
Hasura.Backends.DataConnector.API.V0.Scalar.ValueSpec
|
||||
Hasura.Backends.DataConnector.API.V0.SchemaSpec
|
||||
Hasura.Backends.DataConnector.API.V0.TableSpec
|
||||
Hasura.Backends.DataConnector.RQLGenerator
|
||||
Hasura.Backends.DataConnector.RQLGenerator.GenAnnSelectG
|
||||
Hasura.Backends.DataConnector.RQLGenerator.GenCommon
|
||||
Hasura.Backends.DataConnector.RQLGenerator.GenTablePermG
|
||||
Hasura.Backends.DataConnector.RQLGenerator.GenSelectArgsG
|
||||
Hasura.Backends.DataConnector.RQLGenerator.GenSelectFromG
|
||||
Hasura.Backends.MSSQL.ErrorSpec
|
||||
Hasura.Backends.MySQL.DataLoader.ExecuteTests
|
||||
Hasura.Backends.Postgres.RQLGenerator
|
||||
@ -1130,7 +1125,7 @@ test-suite tests-hspec
|
||||
Test.InsertEnumColumnSpec
|
||||
Test.SQLServer.InsertVarcharColumnSpec
|
||||
|
||||
test-suite tests-gdw-api
|
||||
test-suite tests-dc-api
|
||||
import: common-all, common-exe
|
||||
type: exitcode-stdio-1.0
|
||||
build-depends:
|
||||
@ -1141,7 +1136,7 @@ test-suite tests-gdw-api
|
||||
, bytestring
|
||||
, deepseq
|
||||
, file-embed
|
||||
, gdw-api
|
||||
, dc-api
|
||||
, hashable
|
||||
, hspec
|
||||
, hspec-core
|
||||
@ -1161,7 +1156,7 @@ test-suite tests-gdw-api
|
||||
, text
|
||||
, unordered-containers
|
||||
, vector
|
||||
hs-source-dirs: tests-gdw-api
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API
|
||||
module Hasura.Backends.DataConnector.API
|
||||
( module V0,
|
||||
Api,
|
||||
SchemaApi,
|
||||
@ -20,7 +20,7 @@ import Data.Data (Proxy (..))
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.OpenApi (AdditionalProperties (..), OpenApi, OpenApiType (..), Schema (..), ToParamSchema (..))
|
||||
import Data.Text.Encoding qualified as Text
|
||||
import Hasura.Backends.DataWrapper.API.V0.API as V0
|
||||
import Hasura.Backends.DataConnector.API.V0.API as V0
|
||||
import Servant.API
|
||||
import Servant.API.Generic
|
||||
import Servant.Client (Client, ClientM, client)
|
@ -0,0 +1,21 @@
|
||||
--
|
||||
module Hasura.Backends.DataConnector.API.V0.API
|
||||
( module Column,
|
||||
module Expression,
|
||||
module OrderBy,
|
||||
module Query,
|
||||
module Scalar.Type,
|
||||
module Scalar.Value,
|
||||
module Schema,
|
||||
module Table,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataConnector.API.V0.Column as Column
|
||||
import Hasura.Backends.DataConnector.API.V0.Expression as Expression
|
||||
import Hasura.Backends.DataConnector.API.V0.OrderBy as OrderBy
|
||||
import Hasura.Backends.DataConnector.API.V0.Query as Query
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Type as Scalar.Type
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Value as Scalar.Value
|
||||
import Hasura.Backends.DataConnector.API.V0.Schema as Schema
|
||||
import Hasura.Backends.DataConnector.API.V0.Table as Table
|
@ -1,7 +1,7 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.Column
|
||||
module Hasura.Backends.DataConnector.API.V0.Column
|
||||
( ColumnInfo (..),
|
||||
ColumnName (..),
|
||||
)
|
||||
@ -18,7 +18,7 @@ import Data.Hashable (Hashable)
|
||||
import Data.OpenApi (ToSchema)
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Type qualified as API.V0.Scalar
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Type qualified as API.V0.Scalar
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -4,7 +4,7 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.Expression
|
||||
module Hasura.Backends.DataConnector.API.V0.Expression
|
||||
( Expression (..),
|
||||
Operator (..),
|
||||
)
|
||||
@ -19,8 +19,8 @@ import Data.Data (Data)
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.OpenApi (ToSchema)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Value qualified as API.V0.Scalar
|
||||
import Hasura.Backends.DataConnector.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Value qualified as API.V0.Scalar
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -2,7 +2,7 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.OrderBy
|
||||
module Hasura.Backends.DataConnector.API.V0.OrderBy
|
||||
( OrderBy (..),
|
||||
OrderType (..),
|
||||
)
|
||||
@ -18,7 +18,7 @@ import Data.Data (Data)
|
||||
import Data.Hashable (Hashable)
|
||||
import Data.OpenApi (ToSchema)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Column qualified as API.V0
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -4,7 +4,7 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.Query
|
||||
module Hasura.Backends.DataConnector.API.V0.Query
|
||||
( Query (..),
|
||||
Field (..),
|
||||
RelField (..),
|
||||
@ -26,10 +26,10 @@ import Data.List.NonEmpty (NonEmpty)
|
||||
import Data.OpenApi (ToSchema)
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataWrapper.API.V0.Expression qualified as API.V0
|
||||
import Hasura.Backends.DataWrapper.API.V0.OrderBy qualified as API.V0
|
||||
import Hasura.Backends.DataWrapper.API.V0.Table qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Expression qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.OrderBy qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Table qualified as API.V0
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -2,7 +2,7 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.Scalar.Type
|
||||
module Hasura.Backends.DataConnector.API.V0.Scalar.Type
|
||||
( Type (..),
|
||||
)
|
||||
where
|
@ -3,7 +3,7 @@
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.Scalar.Value
|
||||
module Hasura.Backends.DataConnector.API.V0.Scalar.Value
|
||||
( Value (..),
|
||||
)
|
||||
where
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.Schema
|
||||
module Hasura.Backends.DataConnector.API.V0.Schema
|
||||
( SchemaResponse (..),
|
||||
QueryResponse (..),
|
||||
Capabilities (..),
|
||||
@ -14,7 +14,7 @@ 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 Hasura.Backends.DataConnector.API.V0.Table qualified as API.V0
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -1,7 +1,7 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.Table
|
||||
module Hasura.Backends.DataConnector.API.V0.Table
|
||||
( TableInfo (..),
|
||||
TableName (..),
|
||||
)
|
||||
@ -18,7 +18,7 @@ import Data.Hashable (Hashable)
|
||||
import Data.OpenApi (ToSchema)
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Column qualified as API.V0
|
||||
import Hasura.Backends.DataConnector.API.V0.Column qualified as API.V0
|
||||
import Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -1,21 +0,0 @@
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.API.V0.API
|
||||
( module Column,
|
||||
module Expression,
|
||||
module OrderBy,
|
||||
module Query,
|
||||
module Scalar.Type,
|
||||
module Scalar.Value,
|
||||
module Schema,
|
||||
module Table,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.API.V0.Column as Column
|
||||
import Hasura.Backends.DataWrapper.API.V0.Expression as Expression
|
||||
import Hasura.Backends.DataWrapper.API.V0.OrderBy as OrderBy
|
||||
import Hasura.Backends.DataWrapper.API.V0.Query as Query
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Type as Scalar.Type
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Value as Scalar.Value
|
||||
import Hasura.Backends.DataWrapper.API.V0.Schema as Schema
|
||||
import Hasura.Backends.DataWrapper.API.V0.Table as Table
|
@ -1,18 +1,18 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.API () where
|
||||
module Hasura.Backends.DataConnector.Adapter.API () where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Prelude
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Hasura.SQL.Backend (BackendType (DataConnector))
|
||||
import Hasura.Server.API.Backend (BackendAPI (..), sourceCommands, tableCommands)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
instance BackendAPI 'DataWrapper where
|
||||
instance BackendAPI 'DataConnector where
|
||||
metadataV1CommandParsers =
|
||||
concat
|
||||
[ sourceCommands @'DataWrapper,
|
||||
tableCommands @'DataWrapper
|
||||
[ sourceCommands @'DataConnector,
|
||||
tableCommands @'DataConnector
|
||||
]
|
104
server/src-lib/Hasura/Backends/DataConnector/Adapter/Backend.hs
Normal file
104
server/src-lib/Hasura/Backends/DataConnector/Adapter/Backend.hs
Normal file
@ -0,0 +1,104 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataConnector.Adapter.Backend () where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.Aeson qualified as J (Value)
|
||||
import Hasura.Backends.DataConnector.Adapter.Types qualified as Adapter
|
||||
import Hasura.Backends.DataConnector.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.Function qualified as IR.F
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataConnector.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Value qualified as IR.S.V
|
||||
import Hasura.Backends.DataConnector.IR.Table as IR.T
|
||||
import Hasura.Base.Error (Code (ValidationFailed), QErr, throw400)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Backend (Backend (..), XDisable)
|
||||
import Hasura.RQL.Types.Common as RQL (boolScalar, floatScalar, stringScalar)
|
||||
import Hasura.SQL.Backend (BackendType (DataConnector))
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- | An alias for '()' indicating that a particular associated type has not yet
|
||||
-- been implemented for the 'DataConnector' backend.
|
||||
--
|
||||
-- '()' is used (rather than a type with an empty data constructor) because it
|
||||
-- comes with many of the instances that these associated types require.
|
||||
--
|
||||
-- This alias should /not/ be exported from this module, and it's only defined
|
||||
-- for clarity.
|
||||
type Unimplemented = ()
|
||||
|
||||
instance Backend 'DataConnector where
|
||||
type BackendConfig 'DataConnector = Adapter.DataConnectorBackendConfig
|
||||
type SourceConfig 'DataConnector = Adapter.SourceConfig
|
||||
type SourceConnConfiguration 'DataConnector = Adapter.ConnSourceConfig
|
||||
|
||||
type TableName 'DataConnector = IR.T.Name
|
||||
type FunctionName 'DataConnector = IR.F.Name
|
||||
type RawFunctionInfo 'DataConnector = XDisable
|
||||
type FunctionArgType 'DataConnector = XDisable
|
||||
type ConstraintName 'DataConnector = Unimplemented
|
||||
type BasicOrderType 'DataConnector = IR.O.OrderType
|
||||
type NullsOrderType 'DataConnector = Unimplemented
|
||||
type CountType 'DataConnector = Unimplemented
|
||||
type Column 'DataConnector = IR.C.Name
|
||||
type ScalarValue 'DataConnector = IR.S.V.Value
|
||||
type ScalarType 'DataConnector = IR.S.T.Type
|
||||
type SQLExpression 'DataConnector = IR.E.Expression
|
||||
type SQLOperator 'DataConnector = IR.E.Operator
|
||||
type BooleanOperators 'DataConnector = Const XDisable
|
||||
type ExtraTableMetadata 'DataConnector = Unimplemented
|
||||
|
||||
type XComputedField 'DataConnector = XDisable
|
||||
type XRelay 'DataConnector = XDisable
|
||||
type XNodesAgg 'DataConnector = XDisable
|
||||
type XNestedInserts 'DataConnector = XDisable
|
||||
type XStreamingSubscription 'DataConnector = XDisable
|
||||
|
||||
functionArgScalarType :: FunctionArgType 'DataConnector -> ScalarType 'DataConnector
|
||||
functionArgScalarType = error "functionArgScalarType: not implemented for the Data Connector backend."
|
||||
|
||||
isComparableType :: ScalarType 'DataConnector -> Bool
|
||||
isComparableType = isNumType @'DataConnector
|
||||
|
||||
isNumType :: ScalarType 'DataConnector -> Bool
|
||||
isNumType IR.S.T.Number = True
|
||||
isNumType _ = False
|
||||
|
||||
textToScalarValue :: Maybe Text -> ScalarValue 'DataConnector
|
||||
textToScalarValue = error "textToScalarValue: not implemented for the Data Connector backend."
|
||||
|
||||
parseScalarValue :: ScalarType 'DataConnector -> J.Value -> Either QErr (ScalarValue 'DataConnector)
|
||||
parseScalarValue = error "parseScalarValue: not implemented for the Data Connector backend."
|
||||
|
||||
scalarValueToJSON :: ScalarValue 'DataConnector -> J.Value
|
||||
scalarValueToJSON = error "scalarValueToJSON: not implemented for the Data Connector backend."
|
||||
|
||||
functionToTable :: FunctionName 'DataConnector -> TableName 'DataConnector
|
||||
functionToTable = error "functionToTable: not implemented for the Data Connector backend."
|
||||
|
||||
-- phil said this was cursed
|
||||
tableToFunction :: TableName 'DataConnector -> FunctionName 'DataConnector
|
||||
tableToFunction = coerce
|
||||
|
||||
tableGraphQLName :: TableName 'DataConnector -> Either QErr G.Name
|
||||
tableGraphQLName name =
|
||||
G.mkName (IR.N.unName name)
|
||||
`onNothing` throw400 ValidationFailed ("TableName " <> IR.N.unName name <> " is not a valid GraphQL identifier")
|
||||
|
||||
functionGraphQLName :: FunctionName 'DataConnector -> Either QErr G.Name
|
||||
functionGraphQLName = error "functionGraphQLName: not implemented for the Data Connector backend."
|
||||
|
||||
scalarTypeGraphQLName :: ScalarType 'DataConnector -> Either QErr G.Name
|
||||
scalarTypeGraphQLName = \case
|
||||
IR.S.T.String -> pure stringScalar
|
||||
IR.S.T.Number -> pure floatScalar
|
||||
IR.S.T.Bool -> pure boolScalar
|
||||
|
||||
snakeCaseTableName :: TableName 'DataConnector -> Text
|
||||
snakeCaseTableName = IR.N.unName
|
@ -1,6 +1,6 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Execute
|
||||
module Hasura.Backends.DataConnector.Adapter.Execute
|
||||
(
|
||||
)
|
||||
where
|
||||
@ -10,42 +10,42 @@ where
|
||||
import Data.Aeson qualified as J
|
||||
import Data.ByteString.Lazy qualified as BL
|
||||
import Data.Text.Encoding qualified as TE
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.Agent.Client
|
||||
import Hasura.Backends.DataWrapper.IR.Export as IR
|
||||
import Hasura.Backends.DataWrapper.IR.Query qualified as IR.Q
|
||||
import Hasura.Backends.DataWrapper.Plan qualified as GDW
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.Agent.Client
|
||||
import Hasura.Backends.DataConnector.IR.Export as IR
|
||||
import Hasura.Backends.DataConnector.IR.Query qualified as IR.Q
|
||||
import Hasura.Backends.DataConnector.Plan qualified as DC
|
||||
import Hasura.Base.Error (Code (..), QErr, throw400, throw500)
|
||||
import Hasura.EncJSON (EncJSON, encJFromJValue)
|
||||
import Hasura.GraphQL.Execute.Backend (BackendExecute (..), DBStepInfo (..), ExplainPlan (..))
|
||||
import Hasura.GraphQL.Namespace qualified as GQL
|
||||
import Hasura.Prelude
|
||||
import Hasura.SQL.AnyBackend (mkAnyBackend)
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Hasura.SQL.Backend (BackendType (DataConnector))
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
instance BackendExecute 'DataWrapper where
|
||||
type PreparedQuery 'DataWrapper = GDW.Plan
|
||||
type MultiplexedQuery 'DataWrapper = Void
|
||||
type ExecutionMonad 'DataWrapper = Tracing.TraceT (ExceptT QErr IO)
|
||||
instance BackendExecute 'DataConnector where
|
||||
type PreparedQuery 'DataConnector = DC.Plan
|
||||
type MultiplexedQuery 'DataConnector = Void
|
||||
type ExecutionMonad 'DataConnector = Tracing.TraceT (ExceptT QErr IO)
|
||||
|
||||
mkDBQueryPlan UserInfo {..} sourceName sourceConfig ir = do
|
||||
plan' <- GDW.mkPlan _uiSession sourceConfig ir
|
||||
plan' <- DC.mkPlan _uiSession sourceConfig ir
|
||||
pure
|
||||
DBStepInfo
|
||||
{ dbsiSourceName = sourceName,
|
||||
dbsiSourceConfig = sourceConfig,
|
||||
dbsiPreparedQuery = Just plan',
|
||||
dbsiAction = buildAction sourceConfig (GDW.query plan')
|
||||
dbsiAction = buildAction sourceConfig (DC.query plan')
|
||||
}
|
||||
|
||||
mkDBQueryExplain fieldName UserInfo {..} sourceName sourceConfig ir = do
|
||||
plan' <- GDW.mkPlan _uiSession sourceConfig ir
|
||||
plan' <- DC.mkPlan _uiSession sourceConfig ir
|
||||
pure $
|
||||
mkAnyBackend @'DataWrapper
|
||||
mkAnyBackend @'DataConnector
|
||||
DBStepInfo
|
||||
{ dbsiSourceName = sourceName,
|
||||
dbsiSourceConfig = sourceConfig,
|
||||
@ -53,24 +53,24 @@ instance BackendExecute 'DataWrapper where
|
||||
dbsiAction = pure . encJFromJValue . toExplainPlan fieldName $ plan'
|
||||
}
|
||||
mkDBMutationPlan _ _ _ _ _ =
|
||||
throw400 NotSupported "mkDBMutationPlan: not implemented for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "mkDBMutationPlan: not implemented for the Data Connector backend."
|
||||
mkLiveQuerySubscriptionPlan _ _ _ _ _ =
|
||||
throw400 NotSupported "mkLiveQuerySubscriptionPlan: not implemented for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "mkLiveQuerySubscriptionPlan: not implemented for the Data Connector backend."
|
||||
mkDBStreamingSubscriptionPlan _ _ _ _ =
|
||||
throw400 NotSupported "mkLiveQuerySubscriptionPlan: not implemented for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "mkLiveQuerySubscriptionPlan: not implemented for the Data Connector backend."
|
||||
mkDBRemoteRelationshipPlan _ _ _ _ _ _ _ =
|
||||
throw500 "mkDBRemoteRelationshipPlan: not implemented for GraphQL Data Wrappers."
|
||||
throw500 "mkDBRemoteRelationshipPlan: not implemented for the Data Connector backend."
|
||||
mkSubscriptionExplain _ =
|
||||
throw400 NotSupported "mkSubscriptionExplain: not implemented for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "mkSubscriptionExplain: not implemented for the Data Connector backend."
|
||||
|
||||
toExplainPlan :: GQL.RootFieldAlias -> GDW.Plan -> ExplainPlan
|
||||
toExplainPlan :: GQL.RootFieldAlias -> DC.Plan -> ExplainPlan
|
||||
toExplainPlan fieldName plan_ =
|
||||
ExplainPlan fieldName (Just "") (Just [TE.decodeUtf8 $ BL.toStrict $ J.encode $ GDW.query $ plan_])
|
||||
ExplainPlan fieldName (Just "") (Just [TE.decodeUtf8 $ BL.toStrict $ J.encode $ DC.query $ plan_])
|
||||
|
||||
buildAction :: GDW.SourceConfig -> IR.Q.Query -> Tracing.TraceT (ExceptT QErr IO) EncJSON
|
||||
buildAction GDW.SourceConfig {..} query = do
|
||||
buildAction :: DC.SourceConfig -> IR.Q.Query -> Tracing.TraceT (ExceptT QErr IO) EncJSON
|
||||
buildAction DC.SourceConfig {..} query = do
|
||||
-- NOTE: Should this check occur during query construction in 'mkPlan'?
|
||||
when (GDW.queryHasRelations query && not (API.dcRelationships (API.srCapabilities _scSchema))) $
|
||||
when (DC.queryHasRelations query && not (API.dcRelationships (API.srCapabilities _scSchema))) $
|
||||
throw400 NotSupported "Agents must provide their own dataloader."
|
||||
API.Routes {..} <- liftIO $ client @(Tracing.TraceT (ExceptT QErr IO)) _scManager _scEndpoint
|
||||
case fmap (_query _scConfig) $ IR.queryToAPI query of
|
@ -1,6 +1,6 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Metadata () where
|
||||
module Hasura.Backends.DataConnector.Adapter.Metadata () where
|
||||
|
||||
import Data.Aeson qualified as J
|
||||
import Data.Environment (Environment)
|
||||
@ -8,14 +8,14 @@ import Data.HashMap.Strict qualified as Map
|
||||
import Data.HashMap.Strict.InsOrd qualified as OMap
|
||||
import Data.Sequence.NonEmpty qualified as NESeq
|
||||
import Data.Text.Extended (toTxt)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types (ConnSourceConfig (..))
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types qualified as GDW
|
||||
import Hasura.Backends.DataWrapper.Agent.Client qualified as Agent.Client
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataWrapper.IR.Table qualified as IR.T
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.Adapter.Types (ConnSourceConfig (..))
|
||||
import Hasura.Backends.DataConnector.Adapter.Types qualified as DC
|
||||
import Hasura.Backends.DataConnector.Agent.Client qualified as Agent.Client
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataConnector.IR.Table qualified as IR.T
|
||||
import Hasura.Backends.Postgres.SQL.Types (PGDescription (..))
|
||||
import Hasura.Base.Error (Code (..), QErr, throw400, withPathK)
|
||||
import Hasura.Prelude
|
||||
@ -36,34 +36,34 @@ import Language.GraphQL.Draft.Syntax qualified as GQL
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
import Witch qualified
|
||||
|
||||
instance BackendMetadata 'DataWrapper where
|
||||
instance BackendMetadata 'DataConnector where
|
||||
resolveSourceConfig = resolveSourceConfig'
|
||||
resolveDatabaseMetadata = resolveDatabaseMetadata'
|
||||
parseBoolExpOperations = parseBoolExpOperations'
|
||||
parseCollectableType = parseCollectableType'
|
||||
buildComputedFieldInfo = error "buildComputedFieldInfo: not implemented for GraphQL Data Wrappers."
|
||||
fetchAndValidateEnumValues = error "fetchAndValidateEnumValues: not implemented for GraphQL Data Wrappers."
|
||||
buildFunctionInfo = error "buildFunctionInfo: not implemented for GraphQL Data Wrappers."
|
||||
updateColumnInEventTrigger = error "updateColumnInEventTrigger: not implemented for GraphQL Data Wrappers."
|
||||
postDropSourceHook = error "postDropSourceHook: not implemented for GraphQL Data Wrappers."
|
||||
buildComputedFieldInfo = error "buildComputedFieldInfo: not implemented for the Data Connector backend."
|
||||
fetchAndValidateEnumValues = error "fetchAndValidateEnumValues: not implemented for the Data Connector backend."
|
||||
buildFunctionInfo = error "buildFunctionInfo: not implemented for the Data Connector backend."
|
||||
updateColumnInEventTrigger = error "updateColumnInEventTrigger: not implemented for the Data Connector backend."
|
||||
postDropSourceHook = error "postDropSourceHook: not implemented for the Data Connector backend."
|
||||
|
||||
resolveSourceConfig' ::
|
||||
MonadIO m =>
|
||||
SourceName ->
|
||||
GDW.ConnSourceConfig ->
|
||||
BackendSourceKind 'DataWrapper ->
|
||||
GDW.DataConnectorBackendConfig ->
|
||||
DC.ConnSourceConfig ->
|
||||
BackendSourceKind 'DataConnector ->
|
||||
DC.DataConnectorBackendConfig ->
|
||||
Environment ->
|
||||
m (Either QErr GDW.SourceConfig)
|
||||
resolveSourceConfig' _sourceName (ConnSourceConfig config) (DataWrapperKind dataConnectorName) backendConfig _ = runExceptT do
|
||||
GDW.DataConnectorOptions {..} <-
|
||||
m (Either QErr DC.SourceConfig)
|
||||
resolveSourceConfig' _sourceName (ConnSourceConfig config) (DataConnectorKind dataConnectorName) backendConfig _ = runExceptT do
|
||||
DC.DataConnectorOptions {..} <-
|
||||
OMap.lookup dataConnectorName backendConfig
|
||||
`onNothing` throw400 DataConnectorError ("Data connector named " <> toTxt dataConnectorName <> " was not found in the data connector backend config")
|
||||
manager <- liftIO $ HTTP.newManager HTTP.defaultManagerSettings
|
||||
API.Routes {..} <- liftIO $ Agent.Client.client manager _dcoUri
|
||||
schemaResponse <- runTraceTWithReporter noReporter "resolve source" $ _schema config
|
||||
pure
|
||||
GDW.SourceConfig
|
||||
DC.SourceConfig
|
||||
{ _scEndpoint = _dcoUri,
|
||||
_scConfig = config,
|
||||
_scSchema = schemaResponse,
|
||||
@ -72,11 +72,11 @@ resolveSourceConfig' _sourceName (ConnSourceConfig config) (DataWrapperKind data
|
||||
|
||||
resolveDatabaseMetadata' ::
|
||||
Applicative m =>
|
||||
SourceMetadata 'DataWrapper ->
|
||||
GDW.SourceConfig ->
|
||||
SourceMetadata 'DataConnector ->
|
||||
DC.SourceConfig ->
|
||||
SourceTypeCustomization ->
|
||||
m (Either QErr (ResolvedSource 'DataWrapper))
|
||||
resolveDatabaseMetadata' _ sc@(GDW.SourceConfig {_scSchema = API.SchemaResponse {..}}) customization =
|
||||
m (Either QErr (ResolvedSource 'DataConnector))
|
||||
resolveDatabaseMetadata' _ sc@(DC.SourceConfig {_scSchema = API.SchemaResponse {..}}) customization =
|
||||
let tables = Map.fromList $ do
|
||||
API.TableInfo {..} <- srTables
|
||||
let meta =
|
||||
@ -116,23 +116,23 @@ resolveDatabaseMetadata' _ sc@(GDW.SourceConfig {_scSchema = API.SchemaResponse
|
||||
parseBoolExpOperations' ::
|
||||
forall m v.
|
||||
MonadError QErr m =>
|
||||
RQL.T.C.ValueParser 'DataWrapper m v ->
|
||||
RQL.T.C.ValueParser 'DataConnector m v ->
|
||||
IR.T.Name ->
|
||||
RQL.T.T.FieldInfoMap (RQL.T.T.FieldInfo 'DataWrapper) ->
|
||||
RQL.T.C.ColumnReference 'DataWrapper ->
|
||||
RQL.T.T.FieldInfoMap (RQL.T.T.FieldInfo 'DataConnector) ->
|
||||
RQL.T.C.ColumnReference 'DataConnector ->
|
||||
J.Value ->
|
||||
m [OpExpG 'DataWrapper v]
|
||||
m [OpExpG 'DataConnector v]
|
||||
parseBoolExpOperations' rhsParser _table _fields columnRef value =
|
||||
withPathK (toTxt columnRef) $ parseOperations (RQL.T.C.columnReferenceType columnRef) value
|
||||
where
|
||||
parseWithTy ty = rhsParser (CollectableTypeScalar ty)
|
||||
|
||||
parseOperations :: RQL.T.C.ColumnType 'DataWrapper -> J.Value -> m [OpExpG 'DataWrapper v]
|
||||
parseOperations :: RQL.T.C.ColumnType 'DataConnector -> J.Value -> m [OpExpG 'DataConnector v]
|
||||
parseOperations columnType = \case
|
||||
J.Object o -> traverse (parseOperation columnType) $ Map.toList o
|
||||
v -> pure . AEQ False <$> parseWithTy columnType v
|
||||
|
||||
parseOperation :: RQL.T.C.ColumnType 'DataWrapper -> (Text, J.Value) -> m (OpExpG 'DataWrapper v)
|
||||
parseOperation :: RQL.T.C.ColumnType 'DataConnector -> (Text, J.Value) -> m (OpExpG 'DataConnector v)
|
||||
parseOperation columnType (opStr, val) = withPathK opStr $
|
||||
case opStr of
|
||||
"_eq" -> parseEq
|
||||
@ -175,9 +175,9 @@ parseBoolExpOperations' rhsParser _table _fields columnRef value =
|
||||
|
||||
parseCollectableType' ::
|
||||
MonadError QErr m =>
|
||||
CollectableType (RQL.T.C.ColumnType 'DataWrapper) ->
|
||||
CollectableType (RQL.T.C.ColumnType 'DataConnector) ->
|
||||
J.Value ->
|
||||
m (PartialSQLExp 'DataWrapper)
|
||||
m (PartialSQLExp 'DataConnector)
|
||||
parseCollectableType' collectableType = \case
|
||||
J.String t
|
||||
| HSU.isSessionVariable t -> pure $ mkTypedSessionVar collectableType $ mkSessionVariable t
|
||||
@ -186,16 +186,16 @@ parseCollectableType' collectableType = \case
|
||||
CollectableTypeScalar scalarType ->
|
||||
PSESQLExp . IR.E.Literal <$> RQL.T.C.parseScalarValueColumnType scalarType val
|
||||
CollectableTypeArray _ ->
|
||||
throw400 NotSupported "Array types are not supported by dynamic backends"
|
||||
throw400 NotSupported "Array types are not supported by the Data Connector backend"
|
||||
|
||||
mkTypedSessionVar ::
|
||||
CollectableType (RQL.T.C.ColumnType 'DataWrapper) ->
|
||||
CollectableType (RQL.T.C.ColumnType 'DataConnector) ->
|
||||
SessionVariable ->
|
||||
PartialSQLExp 'DataWrapper
|
||||
PartialSQLExp 'DataConnector
|
||||
mkTypedSessionVar columnType =
|
||||
PSESessVar (columnTypeToScalarType <$> columnType)
|
||||
|
||||
columnTypeToScalarType :: RQL.T.C.ColumnType 'DataWrapper -> IR.S.T.Type
|
||||
columnTypeToScalarType :: RQL.T.C.ColumnType 'DataConnector -> IR.S.T.Type
|
||||
columnTypeToScalarType = \case
|
||||
RQL.T.C.ColumnScalar scalarType -> scalarType
|
||||
-- NOTE: This should be unreachable:
|
@ -1,17 +1,17 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Schema () where
|
||||
module Hasura.Backends.DataConnector.Adapter.Schema () where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.Has
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Text.Extended ((<<>))
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Value qualified as IR.S.V
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Value qualified as IR.S.V
|
||||
import Hasura.Base.Error
|
||||
import Hasura.GraphQL.Parser qualified as P
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
@ -25,13 +25,13 @@ import Hasura.RQL.IR.Select (SelectArgsG (..))
|
||||
import Hasura.RQL.Types.Backend qualified as RQL
|
||||
import Hasura.RQL.Types.Column qualified as RQL
|
||||
import Hasura.RQL.Types.Common qualified as RQL
|
||||
import Hasura.RQL.Types.SchemaCache as RQL
|
||||
import Hasura.RQL.Types.Table qualified as RQL
|
||||
import Hasura.SQL.Backend (BackendType (..))
|
||||
import Language.GraphQL.Draft.Syntax qualified as GQL
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
instance BackendSchema 'DataWrapper where
|
||||
instance BackendSchema 'DataConnector where
|
||||
-- top level parsers
|
||||
buildTableQueryFields = GS.B.buildTableQueryFields
|
||||
|
||||
@ -60,38 +60,38 @@ instance BackendSchema 'DataWrapper where
|
||||
comparisonExps = comparisonExps'
|
||||
|
||||
countTypeInput =
|
||||
error "countTypeInput: not implemented for GraphQL Data Wrappers."
|
||||
error "countTypeInput: not implemented for the Data Connector backend."
|
||||
aggregateOrderByCountType =
|
||||
error "aggregateOrderByCountType: not implemented for GraphQL Data Wrappers."
|
||||
error "aggregateOrderByCountType: not implemented for the Data Connector backend."
|
||||
computedField =
|
||||
error "computedField: not implemented for GraphQL Data Wrappers."
|
||||
error "computedField: not implemented for the Data Connector backend."
|
||||
node =
|
||||
error "node: not implemented for GraphQL Data Wrappers."
|
||||
error "node: not implemented for the Data Connector backend."
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
experimentalBuildTableRelayQueryFields ::
|
||||
MonadBuildSchema 'DataWrapper r m n =>
|
||||
MonadBuildSchema 'DataConnector r m n =>
|
||||
RQL.SourceName ->
|
||||
RQL.TableName 'DataWrapper ->
|
||||
RQL.TableInfo 'DataWrapper ->
|
||||
RQL.TableName 'DataConnector ->
|
||||
RQL.TableInfo 'DataConnector ->
|
||||
GQL.Name ->
|
||||
NESeq (RQL.ColumnInfo 'DataWrapper) ->
|
||||
NESeq (RQL.ColumnInfo 'DataConnector) ->
|
||||
m [a]
|
||||
experimentalBuildTableRelayQueryFields _sourceName _tableName _tableInfo _gqlName _pkeyColumns =
|
||||
pure []
|
||||
|
||||
columnParser' ::
|
||||
(MonadSchema n m, MonadError QErr m) =>
|
||||
RQL.ColumnType 'DataWrapper ->
|
||||
RQL.ColumnType 'DataConnector ->
|
||||
GQL.Nullability ->
|
||||
m (P.Parser 'P.Both n (P.ValueWithOrigin (RQL.ColumnValue 'DataWrapper)))
|
||||
m (P.Parser 'P.Both n (P.ValueWithOrigin (RQL.ColumnValue 'DataConnector)))
|
||||
columnParser' columnType (GQL.Nullability isNullable) = do
|
||||
parser <- case columnType of
|
||||
RQL.ColumnScalar IR.S.T.String -> pure (IR.S.V.String <$> P.string)
|
||||
RQL.ColumnScalar IR.S.T.Number -> pure (IR.S.V.Number <$> P.scientific)
|
||||
RQL.ColumnScalar IR.S.T.Bool -> pure (IR.S.V.Boolean <$> P.boolean)
|
||||
_ -> throw400 NotSupported "This column type is unsupported by the dynamic backend"
|
||||
_ -> throw400 NotSupported "This column type is unsupported by the Data Connector backend"
|
||||
pure . P.peelWithOrigin . fmap (RQL.ColumnValue columnType) . possiblyNullable $ parser
|
||||
where
|
||||
possiblyNullable ::
|
||||
@ -102,7 +102,7 @@ columnParser' columnType (GQL.Nullability isNullable) = do
|
||||
| isNullable = fmap (fromMaybe IR.S.V.Null) . P.nullable
|
||||
| otherwise = id
|
||||
|
||||
orderByOperators' :: NonEmpty (P.Definition P.EnumValueInfo, (RQL.BasicOrderType 'DataWrapper, RQL.NullsOrderType 'DataWrapper))
|
||||
orderByOperators' :: NonEmpty (P.Definition P.EnumValueInfo, (RQL.BasicOrderType 'DataConnector, RQL.NullsOrderType 'DataConnector))
|
||||
orderByOperators' =
|
||||
NE.fromList
|
||||
[ ( define $$(GQL.litName "asc") "in ascending order",
|
||||
@ -117,14 +117,14 @@ orderByOperators' =
|
||||
|
||||
comparisonExps' ::
|
||||
forall m n r.
|
||||
( BackendSchema 'DataWrapper,
|
||||
( BackendSchema 'DataConnector,
|
||||
MonadSchema n m,
|
||||
MonadError QErr m,
|
||||
MonadReader r m,
|
||||
Has GS.C.QueryContext r
|
||||
) =>
|
||||
RQL.ColumnType 'DataWrapper ->
|
||||
m (P.Parser 'P.Input n [ComparisonExp 'DataWrapper])
|
||||
RQL.ColumnType 'DataConnector ->
|
||||
m (P.Parser 'P.Input n [ComparisonExp 'DataConnector])
|
||||
comparisonExps' = P.memoize 'comparisonExps' $ \columnType -> do
|
||||
collapseIfNull <- asks $ GS.C.qcDangerousBooleanCollapse . getter
|
||||
typedParser <- columnParser' columnType (GQL.Nullability False)
|
||||
@ -152,7 +152,7 @@ comparisonExps' = P.memoize 'comparisonExps' $ \columnType -> do
|
||||
(P.mkParameter <$> typedParser)
|
||||
]
|
||||
where
|
||||
mkListLiteral :: [RQL.ColumnValue 'DataWrapper] -> P.UnpreparedValue 'DataWrapper
|
||||
mkListLiteral :: [RQL.ColumnValue 'DataConnector] -> P.UnpreparedValue 'DataConnector
|
||||
mkListLiteral columnValues =
|
||||
P.UVLiteral $ IR.E.Array $ mapMaybe extractLiteral $ fmap (IR.E.Literal . RQL.cvValue) columnValues
|
||||
|
||||
@ -162,10 +162,10 @@ comparisonExps' = P.memoize 'comparisonExps' $ \columnType -> do
|
||||
|
||||
tableArgs' ::
|
||||
forall r m n.
|
||||
MonadBuildSchema 'DataWrapper r m n =>
|
||||
MonadBuildSchema 'DataConnector r m n =>
|
||||
RQL.SourceName ->
|
||||
RQL.TableInfo 'DataWrapper ->
|
||||
m (P.InputFieldsParser n (SelectArgsG 'DataWrapper (P.UnpreparedValue 'DataWrapper)))
|
||||
RQL.TableInfo 'DataConnector ->
|
||||
m (P.InputFieldsParser n (SelectArgsG 'DataConnector (P.UnpreparedValue 'DataConnector)))
|
||||
tableArgs' sourceName tableInfo = do
|
||||
whereParser <- GS.S.tableWhereArg sourceName tableInfo
|
||||
orderByParser <- GS.S.tableOrderByArg sourceName tableInfo
|
@ -1,15 +1,15 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Transport () where
|
||||
module Hasura.Backends.DataConnector.Adapter.Transport () where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Control.Exception.Safe (throwIO)
|
||||
import Data.Aeson qualified as J
|
||||
import Data.Text.Extended ((<>>))
|
||||
import Hasura.Backends.DataWrapper.Adapter.Execute ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types (SourceConfig)
|
||||
import Hasura.Backends.DataWrapper.Plan qualified as GDW
|
||||
import Hasura.Backends.DataConnector.Adapter.Execute ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Types (SourceConfig)
|
||||
import Hasura.Backends.DataConnector.Plan qualified as DC
|
||||
import Hasura.Base.Error (Code (NotSupported), QErr, throw400)
|
||||
import Hasura.EncJSON (EncJSON)
|
||||
import Hasura.GraphQL.Execute.Backend (DBStepInfo (..))
|
||||
@ -19,22 +19,22 @@ import Hasura.GraphQL.Transport.Backend (BackendTransport (..))
|
||||
import Hasura.GraphQL.Transport.HTTP.Protocol (GQLReqUnparsed)
|
||||
import Hasura.Logging (Hasura, Logger)
|
||||
import Hasura.Prelude
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Hasura.SQL.Backend (BackendType (DataConnector))
|
||||
import Hasura.Server.Types (RequestId)
|
||||
import Hasura.Session (UserInfo)
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
instance BackendTransport 'DataWrapper where
|
||||
instance BackendTransport 'DataConnector where
|
||||
runDBQuery = runDBQuery'
|
||||
runDBQueryExplain = runDBQueryExplain'
|
||||
runDBMutation _ _ _ _ _ _ _ _ =
|
||||
throw400 NotSupported "runDBMutation: not implemented for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "runDBMutation: not implemented for the Data Connector backend."
|
||||
runDBStreamingSubscription _ _ _ =
|
||||
liftIO . throwIO $ userError "runDBStreamingSubscription: not implemented for GraphQL Data Wrappers."
|
||||
liftIO . throwIO $ userError "runDBStreamingSubscription: not implemented for the Data Connector backend."
|
||||
runDBSubscription _ _ _ =
|
||||
liftIO . throwIO $ userError "runDBSubscription: not implemented for GraphQL Data Wrappers."
|
||||
liftIO . throwIO $ userError "runDBSubscription: not implemented for the Data Connector backend."
|
||||
|
||||
runDBQuery' ::
|
||||
( MonadIO m,
|
||||
@ -49,31 +49,31 @@ runDBQuery' ::
|
||||
Logger Hasura ->
|
||||
SourceConfig ->
|
||||
Tracing.TraceT (ExceptT QErr IO) a ->
|
||||
Maybe GDW.Plan ->
|
||||
Maybe DC.Plan ->
|
||||
m (DiffTime, a)
|
||||
runDBQuery' requestId query fieldName _userInfo logger _sourceConfig action ir = do
|
||||
void $ HGL.logQueryLog logger $ mkQueryLog query fieldName ir requestId
|
||||
withElapsedTime
|
||||
. Tracing.trace ("Dynamic backend query for root field " <>> fieldName)
|
||||
. Tracing.trace ("Data Connector backend query for root field " <>> fieldName)
|
||||
. Tracing.interpTraceT (liftEitherM . liftIO . runExceptT)
|
||||
$ action
|
||||
|
||||
mkQueryLog ::
|
||||
GQLReqUnparsed ->
|
||||
RootFieldAlias ->
|
||||
Maybe GDW.Plan ->
|
||||
Maybe DC.Plan ->
|
||||
RequestId ->
|
||||
HGL.QueryLog
|
||||
mkQueryLog gqlQuery fieldName maybePlan requestId =
|
||||
HGL.QueryLog
|
||||
gqlQuery
|
||||
((\plan -> (fieldName, HGL.GeneratedQuery (GDW.renderPlan plan) J.Null)) <$> maybePlan)
|
||||
((\plan -> (fieldName, HGL.GeneratedQuery (DC.renderPlan plan) J.Null)) <$> maybePlan)
|
||||
requestId
|
||||
HGL.QueryLogKindDatabase
|
||||
|
||||
runDBQueryExplain' ::
|
||||
(MonadIO m, MonadError QErr m) =>
|
||||
DBStepInfo 'DataWrapper ->
|
||||
DBStepInfo 'DataConnector ->
|
||||
m EncJSON
|
||||
runDBQueryExplain' (DBStepInfo _ _ _ action) =
|
||||
liftEitherM $
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Types
|
||||
module Hasura.Backends.DataConnector.Adapter.Types
|
||||
( ConnSourceConfig (..),
|
||||
SourceConfig (..),
|
||||
DataConnectorBackendConfig,
|
||||
@ -13,7 +13,7 @@ import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey, genericParseJSON, g
|
||||
import Data.Aeson qualified as J
|
||||
import Data.Text.Extended (ToTxt)
|
||||
import Data.Text.NonEmpty (NonEmptyText)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Incremental (Cacheable (..))
|
||||
import Hasura.Prelude
|
||||
import Network.HTTP.Client (Manager)
|
@ -1,5 +1,5 @@
|
||||
module Hasura.Backends.DataWrapper.Agent.Client
|
||||
( Hasura.Backends.DataWrapper.Agent.Client.client,
|
||||
module Hasura.Backends.DataConnector.Agent.Client
|
||||
( Hasura.Backends.DataConnector.Agent.Client.client,
|
||||
)
|
||||
where
|
||||
|
||||
@ -9,7 +9,7 @@ import Control.Monad.Free
|
||||
|
||||
-- import qualified Network.HTTP.Client.Transformable as Transformable
|
||||
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Prelude
|
||||
import Network.HTTP.Client (Manager)
|
||||
@ -45,7 +45,7 @@ client mgr baseUrl = do
|
||||
Left ex ->
|
||||
-- TODO: log the error details
|
||||
throw500 $
|
||||
"Error in dynamic backend: "
|
||||
"Error in Data Connector backend: "
|
||||
<> case ex of
|
||||
HTTP.InvalidUrlException {} -> "invalid URL"
|
||||
HTTP.HttpExceptionRequest _ detail ->
|
||||
@ -80,7 +80,7 @@ client mgr baseUrl = do
|
||||
let s = (responseStatusCode res)
|
||||
in tshow (statusCode s) <> " " <> bsToTxt (statusMessage s)
|
||||
throw500 $
|
||||
"Error in dynamic backend: "
|
||||
"Error in Data Connector backend: "
|
||||
<> case err of
|
||||
FailureResponse _ res -> "the server returned status " <> status res
|
||||
DecodeFailure _ res -> "unable to decode the response; status " <> status res
|
@ -1,11 +1,11 @@
|
||||
module Hasura.Backends.DataWrapper.IR.Column
|
||||
module Hasura.Backends.DataConnector.IR.Column
|
||||
( Name,
|
||||
)
|
||||
where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as IR.N
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Export
|
||||
module Hasura.Backends.DataConnector.IR.Export
|
||||
( QueryError (..),
|
||||
queryToAPI,
|
||||
)
|
||||
@ -11,9 +11,9 @@ where
|
||||
import Autodocodec.Extended
|
||||
import Data.Aeson (ToJSON)
|
||||
import Data.HashMap.Strict qualified as M
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.Query qualified as IR.Q
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.Query qualified as IR.Q
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
||||
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Expression
|
||||
module Hasura.Backends.DataConnector.IR.Expression
|
||||
( Expression (..),
|
||||
Operator (..),
|
||||
)
|
||||
@ -9,9 +9,9 @@ where
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.Aeson (FromJSON, ToJSON)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Value qualified as IR.S
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Value qualified as IR.S
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
@ -1,8 +1,8 @@
|
||||
module Hasura.Backends.DataWrapper.IR.Function (Name) where
|
||||
module Hasura.Backends.DataConnector.IR.Function (Name) where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as IR.N
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE StandaloneKindSignatures #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Name
|
||||
module Hasura.Backends.DataConnector.IR.Name
|
||||
( Name (..),
|
||||
NameType (..),
|
||||
)
|
||||
@ -11,7 +11,7 @@ where
|
||||
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
|
||||
import Data.Kind (Type)
|
||||
import Data.Text.Extended (ToTxt)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.OrderBy
|
||||
module Hasura.Backends.DataConnector.IR.OrderBy
|
||||
( OrderBy (..),
|
||||
OrderType (..),
|
||||
)
|
||||
@ -10,8 +10,8 @@ where
|
||||
|
||||
import Data.Aeson (ToJSON)
|
||||
import Data.Aeson qualified as J
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.IR.Column qualified as IR.C
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Query
|
||||
module Hasura.Backends.DataConnector.IR.Query
|
||||
( Query (..),
|
||||
Field (..),
|
||||
Cardinality (..),
|
||||
@ -16,11 +16,11 @@ where
|
||||
import Autodocodec.Extended (ValueWrapper (ValueWrapper))
|
||||
import Data.Aeson (ToJSON, ToJSONKey)
|
||||
import Data.Aeson qualified as J
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataWrapper.IR.Table qualified as IR.T
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataConnector.IR.Table qualified as IR.T
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
||||
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Scalar.Type
|
||||
module Hasura.Backends.DataConnector.IR.Scalar.Type
|
||||
( Type (..),
|
||||
)
|
||||
where
|
||||
@ -9,7 +9,7 @@ where
|
||||
|
||||
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
|
||||
import Data.Text.Extended (ToTxt (..))
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.IR.Scalar.Value
|
||||
module Hasura.Backends.DataConnector.IR.Scalar.Value
|
||||
( Value (..),
|
||||
)
|
||||
where
|
||||
@ -9,7 +9,7 @@ where
|
||||
|
||||
import Data.Aeson (FromJSON, ToJSON)
|
||||
import Data.Scientific
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
@ -1,11 +1,11 @@
|
||||
module Hasura.Backends.DataWrapper.IR.Table
|
||||
module Hasura.Backends.DataConnector.IR.Table
|
||||
( Name,
|
||||
)
|
||||
where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as IR.N
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Plan
|
||||
module Hasura.Backends.DataConnector.Plan
|
||||
( SourceConfig (..),
|
||||
Plan (..),
|
||||
mkPlan,
|
||||
@ -21,13 +21,13 @@ import Data.Text as T
|
||||
import Data.Text.Encoding qualified as TE
|
||||
import Data.These
|
||||
import Data.Vector qualified as V
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types
|
||||
import Hasura.Backends.DataWrapper.IR.Export qualified as IR
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataWrapper.IR.Query qualified as IR.Q
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Value qualified as IR.S
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Hasura.Backends.DataConnector.Adapter.Types
|
||||
import Hasura.Backends.DataConnector.IR.Export qualified as IR
|
||||
import Hasura.Backends.DataConnector.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataConnector.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataConnector.IR.Query qualified as IR.Q
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Value qualified as IR.S
|
||||
import Hasura.Base.Error
|
||||
import Hasura.GraphQL.Parser.Column
|
||||
import Hasura.Prelude
|
||||
@ -67,18 +67,18 @@ renderPlan :: Plan -> Text
|
||||
renderPlan =
|
||||
TE.decodeUtf8 . BL.toStrict . J.encode . IR.queryToAPI . query
|
||||
|
||||
-- | Map a 'QueryDB 'DataWrapper' term into a 'Plan'
|
||||
-- | Map a 'QueryDB 'DataConnector' term into a 'Plan'
|
||||
mkPlan ::
|
||||
forall m.
|
||||
MonadError QErr m =>
|
||||
SessionVariables ->
|
||||
SourceConfig ->
|
||||
QueryDB 'DataWrapper Void (UnpreparedValue 'DataWrapper) ->
|
||||
QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector) ->
|
||||
m Plan
|
||||
mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = translateQueryDB ir
|
||||
where
|
||||
translateQueryDB ::
|
||||
QueryDB 'DataWrapper Void (UnpreparedValue 'DataWrapper) ->
|
||||
QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector) ->
|
||||
m Plan
|
||||
translateQueryDB =
|
||||
traverse replaceSessionVariables >=> \case
|
||||
@ -96,7 +96,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
|
||||
translateAnnSelect ::
|
||||
IR.Q.Cardinality ->
|
||||
AnnSimpleSelectG 'DataWrapper Void IR.E.Expression ->
|
||||
AnnSimpleSelectG 'DataConnector Void IR.E.Expression ->
|
||||
m IR.Q.Query
|
||||
translateAnnSelect card s = do
|
||||
tableName <- case _asnFrom s of
|
||||
@ -127,7 +127,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
}
|
||||
|
||||
translateOrderBy ::
|
||||
Maybe (NE.NonEmpty (AnnotatedOrderByItemG 'DataWrapper IR.E.Expression)) ->
|
||||
Maybe (NE.NonEmpty (AnnotatedOrderByItemG 'DataConnector IR.E.Expression)) ->
|
||||
m [IR.O.OrderBy]
|
||||
translateOrderBy = \case
|
||||
Nothing -> pure []
|
||||
@ -142,11 +142,11 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
-- NOTE: Picking a default ordering.
|
||||
ordering = fromMaybe IR.O.Ascending obiType
|
||||
}
|
||||
_ -> throw400 NotSupported "translateOrderBy: references unsupported in dynamic backends"
|
||||
_ -> throw400 NotSupported "translateOrderBy: references unsupported in the Data Connector backend"
|
||||
|
||||
translateFields ::
|
||||
IR.Q.Cardinality ->
|
||||
AnnFieldsG 'DataWrapper Void IR.E.Expression ->
|
||||
AnnFieldsG 'DataConnector Void IR.E.Expression ->
|
||||
m (HashMap Text IR.Q.Field)
|
||||
translateFields card xs = do
|
||||
fields <- traverse (traverse (translateField card)) xs
|
||||
@ -161,7 +161,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
|
||||
translateField ::
|
||||
IR.Q.Cardinality ->
|
||||
AnnFieldG 'DataWrapper Void IR.E.Expression ->
|
||||
AnnFieldG 'DataConnector Void IR.E.Expression ->
|
||||
m (Maybe IR.Q.Field)
|
||||
translateField _card (AFColumn colField) =
|
||||
-- TODO: make sure certain fields in colField are not in use, since we don't
|
||||
@ -193,7 +193,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
translateField _ _ = throw400 NotSupported "translateField: field type not supported"
|
||||
|
||||
replaceSessionVariables ::
|
||||
UnpreparedValue 'DataWrapper ->
|
||||
UnpreparedValue 'DataConnector ->
|
||||
m IR.E.Expression
|
||||
replaceSessionVariables (UVLiteral e) = pure e
|
||||
replaceSessionVariables (UVParameter _ e) = pure (IR.E.Literal (cvValue e))
|
||||
@ -204,7 +204,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
Just s -> pure (IR.E.Literal (IR.S.String s))
|
||||
|
||||
translateBoolExp ::
|
||||
AnnBoolExp 'DataWrapper IR.E.Expression ->
|
||||
AnnBoolExp 'DataConnector IR.E.Expression ->
|
||||
m IR.E.Expression
|
||||
translateBoolExp (BoolAnd xs) =
|
||||
IR.E.And <$> traverse translateBoolExp xs
|
||||
@ -217,11 +217,11 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
<$> sequence
|
||||
[translateOp (IR.E.Column (ciColumn c)) x | x <- xs]
|
||||
translateBoolExp _ =
|
||||
throw400 NotSupported "An expression type is not supported by the dynamic backend"
|
||||
throw400 NotSupported "An expression type is not supported by the Data Connector backend"
|
||||
|
||||
translateOp ::
|
||||
IR.E.Expression ->
|
||||
OpExpG 'DataWrapper IR.E.Expression ->
|
||||
OpExpG 'DataConnector IR.E.Expression ->
|
||||
m IR.E.Expression
|
||||
translateOp lhs = \case
|
||||
AEQ _ rhs ->
|
||||
@ -242,7 +242,7 @@ mkPlan session (SourceConfig {_scSchema = API.SchemaResponse {..}}) ir = transla
|
||||
pure $ IR.E.Not (IR.E.IsNull lhs)
|
||||
AIN (IR.E.Array rhs) -> pure $ IR.E.In lhs rhs
|
||||
_ ->
|
||||
throw400 NotSupported "An operator is not supported by the dynamic backend"
|
||||
throw400 NotSupported "An operator is not supported by the Data Connector backend"
|
||||
|
||||
-- | We need to modify any JSON substructures which appear as a result
|
||||
-- of fetching object relationships, to peel off the outer array sent
|
@ -1,12 +1,12 @@
|
||||
module Hasura.Backends.DataWrapper.Schema.Column
|
||||
module Hasura.Backends.DataConnector.Schema.Column
|
||||
( Column (..),
|
||||
)
|
||||
where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Column qualified as Column (Name)
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Type qualified as Scalar (Type)
|
||||
import Hasura.Backends.DataConnector.IR.Column qualified as Column (Name)
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Type qualified as Scalar (Type)
|
||||
import Hasura.Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -1,12 +1,12 @@
|
||||
module Hasura.Backends.DataWrapper.Schema.Table
|
||||
module Hasura.Backends.DataConnector.Schema.Table
|
||||
( Table (..),
|
||||
)
|
||||
where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Table qualified as Table (Name)
|
||||
import Hasura.Backends.DataWrapper.Schema.Column (Column)
|
||||
import Hasura.Backends.DataConnector.IR.Table qualified as Table (Name)
|
||||
import Hasura.Backends.DataConnector.Schema.Column (Column)
|
||||
import Hasura.Prelude
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -1,104 +0,0 @@
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.Adapter.Backend () where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.Aeson qualified as J (Value)
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types qualified as Adapter
|
||||
import Hasura.Backends.DataWrapper.IR.Column qualified as IR.C
|
||||
import Hasura.Backends.DataWrapper.IR.Expression qualified as IR.E
|
||||
import Hasura.Backends.DataWrapper.IR.Function qualified as IR.F
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as IR.N
|
||||
import Hasura.Backends.DataWrapper.IR.OrderBy qualified as IR.O
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Type qualified as IR.S.T
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Value qualified as IR.S.V
|
||||
import Hasura.Backends.DataWrapper.IR.Table as IR.T
|
||||
import Hasura.Base.Error (Code (ValidationFailed), QErr, throw400)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Backend (Backend (..), XDisable)
|
||||
import Hasura.RQL.Types.Common as RQL (boolScalar, floatScalar, stringScalar)
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- | An alias for '()' indicating that a particular associated type has not yet
|
||||
-- been implemented for the 'DataWrapper' backend.
|
||||
--
|
||||
-- '()' is used (rather than a type with an empty data constructor) because it
|
||||
-- comes with many of the instances that these associated types require.
|
||||
--
|
||||
-- This alias should /not/ be exported from this module, and it's only defined
|
||||
-- for clarity.
|
||||
type Unimplemented = ()
|
||||
|
||||
instance Backend 'DataWrapper where
|
||||
type BackendConfig 'DataWrapper = Adapter.DataConnectorBackendConfig
|
||||
type SourceConfig 'DataWrapper = Adapter.SourceConfig
|
||||
type SourceConnConfiguration 'DataWrapper = Adapter.ConnSourceConfig
|
||||
|
||||
type TableName 'DataWrapper = IR.T.Name
|
||||
type FunctionName 'DataWrapper = IR.F.Name
|
||||
type RawFunctionInfo 'DataWrapper = XDisable
|
||||
type FunctionArgType 'DataWrapper = XDisable
|
||||
type ConstraintName 'DataWrapper = Unimplemented
|
||||
type BasicOrderType 'DataWrapper = IR.O.OrderType
|
||||
type NullsOrderType 'DataWrapper = Unimplemented
|
||||
type CountType 'DataWrapper = Unimplemented
|
||||
type Column 'DataWrapper = IR.C.Name
|
||||
type ScalarValue 'DataWrapper = IR.S.V.Value
|
||||
type ScalarType 'DataWrapper = IR.S.T.Type
|
||||
type SQLExpression 'DataWrapper = IR.E.Expression
|
||||
type SQLOperator 'DataWrapper = IR.E.Operator
|
||||
type BooleanOperators 'DataWrapper = Const XDisable
|
||||
type ExtraTableMetadata 'DataWrapper = Unimplemented
|
||||
|
||||
type XComputedField 'DataWrapper = XDisable
|
||||
type XRelay 'DataWrapper = XDisable
|
||||
type XNodesAgg 'DataWrapper = XDisable
|
||||
type XNestedInserts 'DataWrapper = XDisable
|
||||
type XStreamingSubscription 'DataWrapper = XDisable
|
||||
|
||||
functionArgScalarType :: FunctionArgType 'DataWrapper -> ScalarType 'DataWrapper
|
||||
functionArgScalarType = error "functionArgScalarType: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
isComparableType :: ScalarType 'DataWrapper -> Bool
|
||||
isComparableType = isNumType @'DataWrapper
|
||||
|
||||
isNumType :: ScalarType 'DataWrapper -> Bool
|
||||
isNumType IR.S.T.Number = True
|
||||
isNumType _ = False
|
||||
|
||||
textToScalarValue :: Maybe Text -> ScalarValue 'DataWrapper
|
||||
textToScalarValue = error "textToScalarValue: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
parseScalarValue :: ScalarType 'DataWrapper -> J.Value -> Either QErr (ScalarValue 'DataWrapper)
|
||||
parseScalarValue = error "parseScalarValue: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
scalarValueToJSON :: ScalarValue 'DataWrapper -> J.Value
|
||||
scalarValueToJSON = error "scalarValueToJSON: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
functionToTable :: FunctionName 'DataWrapper -> TableName 'DataWrapper
|
||||
functionToTable = error "functionToTable: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
-- phil said this was cursed
|
||||
tableToFunction :: TableName 'DataWrapper -> FunctionName 'DataWrapper
|
||||
tableToFunction = coerce
|
||||
|
||||
tableGraphQLName :: TableName 'DataWrapper -> Either QErr G.Name
|
||||
tableGraphQLName name =
|
||||
G.mkName (IR.N.unName name)
|
||||
`onNothing` throw400 ValidationFailed ("TableName " <> IR.N.unName name <> " is not a valid GraphQL identifier")
|
||||
|
||||
functionGraphQLName :: FunctionName 'DataWrapper -> Either QErr G.Name
|
||||
functionGraphQLName = error "functionGraphQLName: not implemented for GraphQL Data Wrappers."
|
||||
|
||||
scalarTypeGraphQLName :: ScalarType 'DataWrapper -> Either QErr G.Name
|
||||
scalarTypeGraphQLName = \case
|
||||
IR.S.T.String -> pure stringScalar
|
||||
IR.S.T.Number -> pure floatScalar
|
||||
IR.S.T.Bool -> pure boolScalar
|
||||
|
||||
snakeCaseTableName :: TableName 'DataWrapper -> Text
|
||||
snakeCaseTableName = IR.N.unName
|
@ -3,7 +3,7 @@
|
||||
module Hasura.GraphQL.Execute.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.Execute as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Execute as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Execute as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.Execute as B ()
|
||||
import Hasura.Backends.MySQL.Instances.Execute as B ()
|
||||
import Hasura.Backends.Postgres.Instances.Execute as B ()
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Hasura.GraphQL.Schema.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.Schema as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Schema as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Schema as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.Schema as B ()
|
||||
import Hasura.Backends.MySQL.Instances.Schema as B ()
|
||||
import Hasura.Backends.Postgres.Instances.Schema as B ()
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Hasura.GraphQL.Transport.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.Transport as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Transport as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Transport as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.Transport as B ()
|
||||
import Hasura.Backends.MySQL.Instances.Transport as B ()
|
||||
import Hasura.Backends.Postgres.Instances.Transport as B ()
|
||||
|
@ -284,28 +284,28 @@ instance BackendEventTrigger 'MySQL where
|
||||
-- implement these methods in the 'Hasura.Experimental.Adapters' module
|
||||
-- hierarchy just to keep everything as tidy as possible for that section of
|
||||
-- code.
|
||||
instance BackendEventTrigger 'DataWrapper where
|
||||
instance BackendEventTrigger 'DataConnector where
|
||||
insertManualEvent _ _ _ _ _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
fetchUndeliveredEvents _ _ _ _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
setRetry _ _ _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
recordSuccess _ _ _ _ =
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
getMaintenanceModeVersion _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
recordError _ _ _ _ _ =
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
recordError' _ _ _ _ _ =
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
dropTriggerAndArchiveEvents _ _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
dropDanglingSQLTrigger _ _ _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers"
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend"
|
||||
redeliverEvent _ _ =
|
||||
throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
unlockEventsInSource _ _ =
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
createTableEventTrigger _ _ _ _ _ _ _ =
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for GraphQL Data Wrappers."
|
||||
runExceptT $ throw400 NotSupported "Event triggers are not supported for the Data Connector backend."
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Hasura.RQL.Types.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.Types as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Backend as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Backend as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.Types as B ()
|
||||
import Hasura.Backends.MySQL.Instances.Types as B ()
|
||||
import Hasura.Backends.Postgres.Instances.Types as B ()
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Hasura.RQL.Types.Metadata.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.Metadata as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.Metadata as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.Metadata as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.Metadata as B ()
|
||||
import Hasura.Backends.MySQL.Instances.Metadata as B ()
|
||||
import Hasura.Backends.Postgres.Instances.Metadata as B ()
|
||||
|
@ -29,7 +29,7 @@ import Data.Aeson
|
||||
import Data.Aeson.Types (Parser)
|
||||
import Data.Kind (Constraint, Type)
|
||||
import Data.Text.NonEmpty (mkNonEmptyText)
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types (DataConnectorName (..))
|
||||
import Hasura.Backends.DataConnector.Adapter.Types (DataConnectorName (..))
|
||||
import Hasura.Incremental (Cacheable)
|
||||
import Hasura.Prelude
|
||||
import Hasura.SQL.Backend
|
||||
@ -632,7 +632,7 @@ backendSourceKindFromText text =
|
||||
<|> BigQueryValue <$> staticKindFromText BigQueryKind
|
||||
<|> MySQLValue <$> staticKindFromText MySQLKind
|
||||
-- IMPORTANT: This must be the last thing here, since it will accept (almost) any string
|
||||
<|> DataWrapperValue . DataWrapperKind . DataConnectorName <$> mkNonEmptyText text
|
||||
<|> DataConnectorValue . DataConnectorKind . DataConnectorName <$> mkNonEmptyText text
|
||||
where
|
||||
staticKindFromText :: BackendSourceKind b -> Maybe (BackendSourceKind b)
|
||||
staticKindFromText kind =
|
||||
@ -648,4 +648,4 @@ parseBackendSourceKindFromJSON value =
|
||||
<|> BigQueryValue <$> parseJSON @(BackendSourceKind ('BigQuery)) value
|
||||
<|> MySQLValue <$> parseJSON @(BackendSourceKind ('MySQL)) value
|
||||
-- IMPORTANT: This must the last thing here, since it will accept (almost) any string
|
||||
<|> DataWrapperValue <$> parseJSON @(BackendSourceKind ('DataWrapper)) value
|
||||
<|> DataConnectorValue <$> parseJSON @(BackendSourceKind ('DataConnector)) value
|
||||
|
@ -20,7 +20,7 @@ import Data.Proxy
|
||||
import Data.Text (unpack)
|
||||
import Data.Text.Extended
|
||||
import Data.Text.NonEmpty (NonEmptyText, mkNonEmptyText, nonEmptyTextQQ)
|
||||
import Hasura.Backends.DataWrapper.Adapter.Types (DataConnectorName (..))
|
||||
import Hasura.Backends.DataConnector.Adapter.Types (DataConnectorName (..))
|
||||
import Hasura.Incremental
|
||||
import Hasura.Prelude
|
||||
import Witch qualified
|
||||
@ -39,7 +39,7 @@ data BackendType
|
||||
| MSSQL
|
||||
| BigQuery
|
||||
| MySQL
|
||||
| DataWrapper
|
||||
| DataConnector
|
||||
deriving stock (Show, Eq, Ord, Generic)
|
||||
deriving anyclass (Hashable, Cacheable)
|
||||
|
||||
@ -50,7 +50,7 @@ instance Witch.From BackendType NonEmptyText where
|
||||
from MSSQL = [nonEmptyTextQQ|mssql|]
|
||||
from BigQuery = [nonEmptyTextQQ|bigquery|]
|
||||
from MySQL = [nonEmptyTextQQ|mysql|]
|
||||
from DataWrapper = [nonEmptyTextQQ|dataconnector|]
|
||||
from DataConnector = [nonEmptyTextQQ|dataconnector|]
|
||||
|
||||
instance ToTxt BackendType where
|
||||
toTxt = toTxt . Witch.into @NonEmptyText
|
||||
@ -63,22 +63,22 @@ instance ToJSON BackendType where
|
||||
|
||||
instance Cacheable (Proxy (b :: BackendType))
|
||||
|
||||
-- | Similar to 'BackendType', however, in the case of 'DataWrapperKind' we need to be able
|
||||
-- capture the name of the data connector that should be used by the DataWrapper backend.
|
||||
-- | Similar to 'BackendType', however, in the case of 'DataConnectorKind' we need to be able
|
||||
-- capture the name of the data connector that should be used by the DataConnector backend.
|
||||
-- This type correlates to the kind property of 'SourceMetadata', which is usually just
|
||||
-- postgres, mssql, etc for static backends, but can be a configurable value for DataWrapper
|
||||
-- hence requiring 'DataConnectorName' for 'DataWrapperKind'
|
||||
-- postgres, mssql, etc for static backends, but can be a configurable value for DataConnector
|
||||
-- hence requiring 'DataConnectorName' for 'DataConnectorKind'
|
||||
--
|
||||
-- This type cannot entirely replace 'BackendType' because 'BackendType' has a fixed number of
|
||||
-- possible values which can be enumerated over at compile time, but 'BackendSourceKind' does
|
||||
-- not because DataWrapper fundamentally is configured at runtime with 'DataConnectorName'.
|
||||
-- not because DataConnector fundamentally is configured at runtime with 'DataConnectorName'.
|
||||
data BackendSourceKind (b :: BackendType) where
|
||||
PostgresVanillaKind :: BackendSourceKind ('Postgres 'Vanilla)
|
||||
PostgresCitusKind :: BackendSourceKind ('Postgres 'Citus)
|
||||
MSSQLKind :: BackendSourceKind 'MSSQL
|
||||
BigQueryKind :: BackendSourceKind 'BigQuery
|
||||
MySQLKind :: BackendSourceKind 'MySQL
|
||||
DataWrapperKind :: DataConnectorName -> BackendSourceKind 'DataWrapper
|
||||
DataConnectorKind :: DataConnectorName -> BackendSourceKind 'DataConnector
|
||||
|
||||
deriving instance Show (BackendSourceKind b)
|
||||
|
||||
@ -97,7 +97,7 @@ instance Witch.From (BackendSourceKind b) NonEmptyText where
|
||||
from k@MSSQLKind = Witch.into @NonEmptyText $ backendTypeFromBackendSourceKind k
|
||||
from k@BigQueryKind = Witch.into @NonEmptyText $ backendTypeFromBackendSourceKind k
|
||||
from k@MySQLKind = Witch.into @NonEmptyText $ backendTypeFromBackendSourceKind k
|
||||
from (DataWrapperKind dataConnectorName) = Witch.into @NonEmptyText dataConnectorName
|
||||
from (DataConnectorKind dataConnectorName) = Witch.into @NonEmptyText dataConnectorName
|
||||
|
||||
instance ToTxt (BackendSourceKind b) where
|
||||
toTxt = toTxt . Witch.into @NonEmptyText
|
||||
@ -124,9 +124,9 @@ instance FromJSON (BackendSourceKind ('BigQuery)) where
|
||||
instance FromJSON (BackendSourceKind ('MySQL)) where
|
||||
parseJSON = mkParseStaticBackendSourceKind MySQLKind
|
||||
|
||||
instance FromJSON (BackendSourceKind ('DataWrapper)) where
|
||||
instance FromJSON (BackendSourceKind ('DataConnector)) where
|
||||
parseJSON = withText "BackendSourceKind" $ \text ->
|
||||
DataWrapperKind . DataConnectorName <$> mkNonEmptyText text
|
||||
DataConnectorKind . DataConnectorName <$> mkNonEmptyText text
|
||||
`onNothing` fail "Cannot be empty string"
|
||||
|
||||
mkParseStaticBackendSourceKind :: BackendSourceKind b -> (Value -> Parser (BackendSourceKind b))
|
||||
@ -152,7 +152,7 @@ supportedBackends =
|
||||
MSSQL,
|
||||
BigQuery,
|
||||
MySQL,
|
||||
DataWrapper
|
||||
DataConnector
|
||||
]
|
||||
|
||||
backendTextNames :: BackendType -> [Text]
|
||||
@ -185,4 +185,4 @@ backendTypeFromBackendSourceKind = \case
|
||||
MSSQLKind -> MSSQL
|
||||
BigQueryKind -> BigQuery
|
||||
MySQLKind -> MySQL
|
||||
DataWrapperKind _ -> DataWrapper
|
||||
DataConnectorKind _ -> DataConnector
|
||||
|
@ -3,7 +3,7 @@
|
||||
module Hasura.Server.API.Instances (module B) where
|
||||
|
||||
import Hasura.Backends.BigQuery.Instances.API as B ()
|
||||
import Hasura.Backends.DataWrapper.Adapter.API as B ()
|
||||
import Hasura.Backends.DataConnector.Adapter.API as B ()
|
||||
import Hasura.Backends.MSSQL.Instances.API as B ()
|
||||
import Hasura.Backends.MySQL.Instances.API as B ()
|
||||
import Hasura.Backends.Postgres.Instances.API as B ()
|
||||
|
@ -40,7 +40,7 @@ import Data.Text.Extended
|
||||
import Data.Text.Lazy qualified as LT
|
||||
import Data.Text.Lazy.Encoding qualified as TL
|
||||
import GHC.Stats.Extended qualified as RTS
|
||||
import Hasura.Backends.DataWrapper.API (openApiSchema)
|
||||
import Hasura.Backends.DataConnector.API (openApiSchema)
|
||||
import Hasura.Backends.Postgres.Execute.Types
|
||||
import Hasura.Base.Error
|
||||
import Hasura.EncJSON
|
||||
@ -1065,7 +1065,7 @@ httpApp setupHook corsCfg serverCtx enableConsole consoleAssetsDir enableTelemet
|
||||
onlyAdmin
|
||||
respJ <- liftIO $ ES.dumpSubscriptionsState True $ scSubscriptionState serverCtx
|
||||
return (emptyHttpLogMetadata @m, JSONResp $ HttpResponse (encJFromJValue respJ) [])
|
||||
Spock.get "dev/gdw/schema" $
|
||||
Spock.get "dev/dataconnector/schema" $
|
||||
spockAction encodeQErr id $
|
||||
mkGetHandler $ do
|
||||
onlyAdmin
|
||||
|
@ -1,11 +1,11 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.ColumnSpec (spec, genColumnName, genColumnInfo) where
|
||||
module Hasura.Backends.DataConnector.API.V0.ColumnSpec (spec, genColumnName, genColumnInfo) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.API
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.TypeSpec (genType)
|
||||
import Hasura.Backends.DataConnector.API.V0.API
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.TypeSpec (genType)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen
|
@ -1,13 +1,13 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.ExpressionSpec (spec, genOperator, genExpression) where
|
||||
module Hasura.Backends.DataConnector.API.V0.ExpressionSpec (spec, genOperator, genExpression) where
|
||||
|
||||
import Autodocodec.Extended
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.API
|
||||
import Hasura.Backends.DataWrapper.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.ValueSpec (genValue)
|
||||
import Hasura.Backends.DataConnector.API.V0.API
|
||||
import Hasura.Backends.DataConnector.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.ValueSpec (genValue)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,11 +1,11 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.OrderBySpec (spec, genOrderBy, genOrderType) where
|
||||
module Hasura.Backends.DataConnector.API.V0.OrderBySpec (spec, genOrderBy, genOrderType) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.API
|
||||
import Hasura.Backends.DataWrapper.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Backends.DataConnector.API.V0.API
|
||||
import Hasura.Backends.DataConnector.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,13 +1,13 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.QuerySpec (spec) where
|
||||
module Hasura.Backends.DataConnector.API.V0.QuerySpec (spec) where
|
||||
|
||||
import Autodocodec.Extended
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Data.HashMap.Strict qualified as Map
|
||||
import Hasura.Backends.DataWrapper.API.V0.API
|
||||
import Hasura.Backends.DataWrapper.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Backends.DataConnector.API.V0.API
|
||||
import Hasura.Backends.DataConnector.API.V0.ColumnSpec (genColumnName)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,9 +1,9 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.Scalar.TypeSpec (spec, genType) where
|
||||
module Hasura.Backends.DataConnector.API.V0.Scalar.TypeSpec (spec, genType) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Type
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Type
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,9 +1,9 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.Scalar.ValueSpec (spec, genValue) where
|
||||
module Hasura.Backends.DataConnector.API.V0.Scalar.ValueSpec (spec, genValue) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.Value
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.Value
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,11 +1,11 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.SchemaSpec (spec) where
|
||||
module Hasura.Backends.DataConnector.API.V0.SchemaSpec (spec) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.Schema
|
||||
import Hasura.Backends.DataWrapper.API.V0.TableSpec (genTableInfo)
|
||||
import Hasura.Backends.DataConnector.API.V0.Schema
|
||||
import Hasura.Backends.DataConnector.API.V0.TableSpec (genTableInfo)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen qualified as Gen
|
@ -1,11 +1,11 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.DataWrapper.API.V0.TableSpec (spec, genTableName, genTableInfo) where
|
||||
module Hasura.Backends.DataConnector.API.V0.TableSpec (spec, genTableName, genTableInfo) where
|
||||
|
||||
import Data.Aeson.QQ.Simple (aesonQQ)
|
||||
import Hasura.Backends.DataWrapper.API.V0.API
|
||||
import Hasura.Backends.DataWrapper.API.V0.ColumnSpec (genColumnInfo)
|
||||
import Hasura.Backends.DataConnector.API.V0.API
|
||||
import Hasura.Backends.DataConnector.API.V0.ColumnSpec (genColumnInfo)
|
||||
import Hasura.Prelude
|
||||
import Hedgehog
|
||||
import Hedgehog.Gen
|
22
server/src-test/Hasura/Backends/DataConnector/API/V0Spec.hs
Normal file
22
server/src-test/Hasura/Backends/DataConnector/API/V0Spec.hs
Normal file
@ -0,0 +1,22 @@
|
||||
module Hasura.Backends.DataConnector.API.V0Spec (spec) where
|
||||
|
||||
import Hasura.Backends.DataConnector.API.V0.ColumnSpec qualified as ColumnSpec
|
||||
import Hasura.Backends.DataConnector.API.V0.ExpressionSpec qualified as ExpressionSpec
|
||||
import Hasura.Backends.DataConnector.API.V0.OrderBySpec qualified as OrderBySpec
|
||||
import Hasura.Backends.DataConnector.API.V0.QuerySpec qualified as QuerySpec
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.TypeSpec qualified as TypeSpec
|
||||
import Hasura.Backends.DataConnector.API.V0.Scalar.ValueSpec qualified as ValueSpec
|
||||
import Hasura.Backends.DataConnector.API.V0.SchemaSpec qualified as SchemaSpec
|
||||
import Hasura.Backends.DataConnector.API.V0.TableSpec qualified as TableSpec
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Column" ColumnSpec.spec
|
||||
describe "Expression" ExpressionSpec.spec
|
||||
describe "OrderBy" OrderBySpec.spec
|
||||
describe "Query" QuerySpec.spec
|
||||
describe "Scalar.Type" TypeSpec.spec
|
||||
describe "Scalar.Value" ValueSpec.spec
|
||||
describe "Schema" SchemaSpec.spec
|
||||
describe "Table" TableSpec.spec
|
@ -0,0 +1,10 @@
|
||||
module Hasura.Backends.DataConnector.RQLGenerator
|
||||
( module M,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenAnnSelectG as M
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenCommon as M
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenSelectArgsG as M
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenSelectFromG as M
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenTablePermG as M
|
@ -1,23 +1,23 @@
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator.GenAnnSelectG
|
||||
module Hasura.Backends.DataConnector.RQLGenerator.GenAnnSelectG
|
||||
( genAnnSelectG,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenSelectArgsG (genSelectArgsG)
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenSelectFromG (genSelectFromG)
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenTablePermG (genTablePermG)
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenSelectArgsG (genSelectArgsG)
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenSelectFromG (genSelectFromG)
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenTablePermG (genTablePermG)
|
||||
import Hasura.Generator.Common (defaultRange)
|
||||
import Hasura.Prelude (Applicative ((<*>)), Bool (..), (<$>), (<&>))
|
||||
import Hasura.RQL.IR (AnnSelectG (..))
|
||||
import Hasura.RQL.IR.Generator (genFields)
|
||||
import Hasura.RQL.Types.Common (StringifyNumbers (..))
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Hasura.SQL.Backend (BackendType (..))
|
||||
import Hedgehog (MonadGen)
|
||||
import Hedgehog.Gen (bool)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
genAnnSelectG :: forall m f a. MonadGen m => m a -> m (f a) -> m (AnnSelectG 'DataWrapper f a)
|
||||
genAnnSelectG :: forall m f a. MonadGen m => m a -> m (f a) -> m (AnnSelectG 'DataConnector f a)
|
||||
genAnnSelectG genA genFA =
|
||||
AnnSelectG
|
||||
<$> genFields genFA defaultRange defaultRange
|
@ -1,4 +1,4 @@
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator.GenCommon
|
||||
module Hasura.Backends.DataConnector.RQLGenerator.GenCommon
|
||||
( genAnnBoolExpFld,
|
||||
genAnnotatedOrderByElement,
|
||||
|
||||
@ -10,8 +10,8 @@ module Hasura.Backends.DataWrapper.RQLGenerator.GenCommon
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.IR.Name qualified as Name
|
||||
import Hasura.Backends.DataWrapper.IR.Scalar.Type qualified as ScalarType
|
||||
import Hasura.Backends.DataConnector.IR.Name qualified as Name
|
||||
import Hasura.Backends.DataConnector.IR.Scalar.Type qualified as ScalarType
|
||||
import Hasura.Generator.Common (defaultRange, genArbitraryUnicodeText, genHashMap)
|
||||
import Hasura.Prelude (coerce, fmap, pure, ($), (<$>), (<*>))
|
||||
import Hasura.RQL.IR
|
||||
@ -27,12 +27,12 @@ import Hedgehog.Gen (bool_, choice, element, list)
|
||||
genAnnBoolExpFld ::
|
||||
MonadGen m =>
|
||||
m a ->
|
||||
m (AnnBoolExpFld 'DataWrapper a)
|
||||
m (AnnBoolExpFld 'DataConnector a)
|
||||
genAnnBoolExpFld genA = choice [column, relationship]
|
||||
where
|
||||
column =
|
||||
AVColumn
|
||||
<$> genColumnInfo @_ @('DataWrapper)
|
||||
<$> genColumnInfo @_ @('DataConnector)
|
||||
genColumn
|
||||
genTableName
|
||||
genScalarType
|
||||
@ -45,7 +45,7 @@ genAnnBoolExpFld genA = choice [column, relationship]
|
||||
genAnnotatedOrderByElement ::
|
||||
MonadGen m =>
|
||||
m a ->
|
||||
m (AnnotatedOrderByElement 'DataWrapper a)
|
||||
m (AnnotatedOrderByElement 'DataConnector a)
|
||||
genAnnotatedOrderByElement genA =
|
||||
choice
|
||||
[ column,
|
||||
@ -77,13 +77,13 @@ genAnnotatedOrderByElement genA =
|
||||
genTableName
|
||||
genScalarType
|
||||
|
||||
genColumn :: MonadGen m => m (Column 'DataWrapper)
|
||||
genColumn :: MonadGen m => m (Column 'DataConnector)
|
||||
genColumn = coerce <$> genArbitraryUnicodeText defaultRange
|
||||
|
||||
genTableName :: MonadGen m => m (TableName 'DataWrapper)
|
||||
genTableName :: MonadGen m => m (TableName 'DataConnector)
|
||||
genTableName = coerce <$> genArbitraryUnicodeText defaultRange
|
||||
|
||||
genScalarType :: MonadGen m => m (ScalarType 'DataWrapper)
|
||||
genScalarType :: MonadGen m => m (ScalarType 'DataConnector)
|
||||
genScalarType =
|
||||
choice
|
||||
[ pure ScalarType.String,
|
||||
@ -91,7 +91,7 @@ genScalarType =
|
||||
pure ScalarType.Bool
|
||||
]
|
||||
|
||||
genFunctionName :: MonadGen m => m (FunctionName 'DataWrapper)
|
||||
genFunctionName :: MonadGen m => m (FunctionName 'DataConnector)
|
||||
genFunctionName = coerce <$> genArbitraryUnicodeText defaultRange
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -100,7 +100,7 @@ genFunctionName = coerce <$> genArbitraryUnicodeText defaultRange
|
||||
genOpExpG ::
|
||||
MonadGen m =>
|
||||
m a ->
|
||||
m (OpExpG 'DataWrapper a)
|
||||
m (OpExpG 'DataConnector a)
|
||||
genOpExpG genA =
|
||||
choice
|
||||
[ acast,
|
||||
@ -152,7 +152,7 @@ genOpExpG genA =
|
||||
|
||||
genRelInfo ::
|
||||
MonadGen m =>
|
||||
m (RelInfo 'DataWrapper)
|
||||
m (RelInfo 'DataConnector)
|
||||
genRelInfo =
|
||||
RelInfo
|
||||
<$> genRelName
|
@ -1,19 +1,19 @@
|
||||
--
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator.GenSelectArgsG
|
||||
module Hasura.Backends.DataConnector.RQLGenerator.GenSelectArgsG
|
||||
( genSelectArgsG,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Int (Int64)
|
||||
import Hasura.Backends.DataWrapper.IR.OrderBy qualified as IR
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenCommon (genAnnBoolExpFld, genAnnotatedOrderByElement, genColumn, genTableName)
|
||||
import Hasura.Backends.DataConnector.IR.OrderBy qualified as IR
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenCommon (genAnnBoolExpFld, genAnnotatedOrderByElement, genColumn, genTableName)
|
||||
import Hasura.Generator.Common (defaultRange)
|
||||
import Hasura.Prelude (Int, Maybe, NonEmpty, pure, ($), (.))
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.Generator (genAnnBoolExp, genAnnotatedOrderByItemG)
|
||||
import Hasura.RQL.IR.Select (AnnotatedOrderByItemG, SelectArgsG (..))
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.SQL.Backend (BackendType (DataWrapper))
|
||||
import Hasura.SQL.Backend (BackendType (..))
|
||||
import Hedgehog (MonadGen)
|
||||
import Hedgehog.Gen (element, maybe, nonEmpty)
|
||||
import Hedgehog.Internal.Gen (integral)
|
||||
@ -21,7 +21,7 @@ import Hedgehog.Internal.Gen (integral)
|
||||
--------------------------------------------------------------------------------
|
||||
-- Exported
|
||||
|
||||
genSelectArgsG :: forall m a. MonadGen m => m a -> m (SelectArgsG 'DataWrapper a)
|
||||
genSelectArgsG :: forall m a. MonadGen m => m a -> m (SelectArgsG 'DataConnector a)
|
||||
genSelectArgsG genA = do
|
||||
_saWhere <- where'
|
||||
_saOrderBy <- orderBy
|
||||
@ -30,13 +30,13 @@ genSelectArgsG genA = do
|
||||
_saDistinct <- distinct
|
||||
pure SelectArgs {..}
|
||||
where
|
||||
where' :: m (Maybe (AnnBoolExp 'DataWrapper a))
|
||||
where' :: m (Maybe (AnnBoolExp 'DataConnector a))
|
||||
where' = maybe $ genAnnBoolExp (genAnnBoolExpFld genA) genTableName
|
||||
|
||||
orderBy :: m (Maybe (NonEmpty (AnnotatedOrderByItemG 'DataWrapper a)))
|
||||
orderBy :: m (Maybe (NonEmpty (AnnotatedOrderByItemG 'DataConnector a)))
|
||||
orderBy =
|
||||
maybe . nonEmpty defaultRange $
|
||||
genAnnotatedOrderByItemG @_ @'DataWrapper
|
||||
genAnnotatedOrderByItemG @_ @'DataConnector
|
||||
genBasicOrderType
|
||||
genNullsOrderType
|
||||
(genAnnotatedOrderByElement genA)
|
||||
@ -47,11 +47,11 @@ genSelectArgsG genA = do
|
||||
offset :: m (Maybe Int64)
|
||||
offset = maybe $ integral defaultRange
|
||||
|
||||
distinct :: m (Maybe (NonEmpty (Column 'DataWrapper)))
|
||||
distinct :: m (Maybe (NonEmpty (Column 'DataConnector)))
|
||||
distinct = maybe . nonEmpty defaultRange $ genColumn
|
||||
|
||||
genBasicOrderType :: MonadGen m => m (BasicOrderType 'DataWrapper)
|
||||
genBasicOrderType :: MonadGen m => m (BasicOrderType 'DataConnector)
|
||||
genBasicOrderType = element [IR.Ascending, IR.Descending]
|
||||
|
||||
genNullsOrderType :: MonadGen m => m (NullsOrderType 'DataWrapper)
|
||||
genNullsOrderType :: MonadGen m => m (NullsOrderType 'DataConnector)
|
||||
genNullsOrderType = element [(), ()]
|
@ -1,9 +1,9 @@
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator.GenSelectFromG
|
||||
module Hasura.Backends.DataConnector.RQLGenerator.GenSelectFromG
|
||||
( genSelectFromG,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenCommon
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenCommon
|
||||
( genColumn,
|
||||
genFunctionName,
|
||||
genScalarType,
|
||||
@ -23,7 +23,7 @@ import Hedgehog.Gen (choice, list, maybe)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
genSelectFromG :: MonadGen m => m a -> m (SelectFromG 'DataWrapper a)
|
||||
genSelectFromG :: MonadGen m => m a -> m (SelectFromG 'DataConnector a)
|
||||
genSelectFromG genA = choice [fromTable, fromIdentifier, fromFunction]
|
||||
where
|
||||
fromTable = FromTable <$> genTableName
|
@ -1,15 +1,15 @@
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator.GenTablePermG
|
||||
module Hasura.Backends.DataConnector.RQLGenerator.GenTablePermG
|
||||
( genTablePermG,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenCommon (genAnnBoolExpFld, genTableName)
|
||||
import Hasura.Backends.DataConnector.RQLGenerator.GenCommon (genAnnBoolExpFld, genTableName)
|
||||
import Hasura.Generator.Common (defaultRange)
|
||||
import Hasura.Prelude (pure, ($))
|
||||
import Hasura.RQL.IR.Generator (genAnnBoolExp)
|
||||
import Hasura.RQL.IR.Select (TablePermG (TablePerm))
|
||||
import Hasura.SQL.Backend
|
||||
( BackendType (DataWrapper),
|
||||
( BackendType (DataConnector),
|
||||
)
|
||||
import Hedgehog (MonadGen)
|
||||
import Hedgehog.Gen
|
||||
@ -20,9 +20,9 @@ import Hedgehog.Gen
|
||||
--------------------------------------------------------------------------------
|
||||
-- Exported
|
||||
|
||||
genTablePermG :: MonadGen m => m a -> m (TablePermG 'DataWrapper a)
|
||||
genTablePermG :: MonadGen m => m a -> m (TablePermG 'DataConnector a)
|
||||
genTablePermG genA = do
|
||||
let genV = genAnnBoolExpFld genA
|
||||
gBoolExp <- genAnnBoolExp @_ @_ @('DataWrapper) genV genTableName
|
||||
gBoolExp <- genAnnBoolExp @_ @_ @('DataConnector) genV genTableName
|
||||
limit <- maybe (integral defaultRange)
|
||||
pure $ TablePerm gBoolExp limit
|
@ -1,22 +0,0 @@
|
||||
module Hasura.Backends.DataWrapper.API.V0Spec (spec) where
|
||||
|
||||
import Hasura.Backends.DataWrapper.API.V0.ColumnSpec qualified as ColumnSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.ExpressionSpec qualified as ExpressionSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.OrderBySpec qualified as OrderBySpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.QuerySpec qualified as QuerySpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.TypeSpec qualified as TypeSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.Scalar.ValueSpec qualified as ValueSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.SchemaSpec qualified as SchemaSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0.TableSpec qualified as TableSpec
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Column" ColumnSpec.spec
|
||||
describe "Expression" ExpressionSpec.spec
|
||||
describe "OrderBy" OrderBySpec.spec
|
||||
describe "Query" QuerySpec.spec
|
||||
describe "Scalar.Type" TypeSpec.spec
|
||||
describe "Scalar.Value" ValueSpec.spec
|
||||
describe "Schema" SchemaSpec.spec
|
||||
describe "Table" TableSpec.spec
|
@ -1,10 +0,0 @@
|
||||
module Hasura.Backends.DataWrapper.RQLGenerator
|
||||
( module M,
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenAnnSelectG as M
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenCommon as M
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenSelectArgsG as M
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenSelectFromG as M
|
||||
import Hasura.Backends.DataWrapper.RQLGenerator.GenTablePermG as M
|
@ -27,7 +27,7 @@ import Hasura.App
|
||||
mkPgSourceResolver,
|
||||
)
|
||||
import Hasura.AppSpec qualified as AppSpec
|
||||
import Hasura.Backends.DataWrapper.API.V0Spec qualified as DataWrapper.API.V0Spec
|
||||
import Hasura.Backends.DataConnector.API.V0Spec qualified as DataConnector.API.V0Spec
|
||||
import Hasura.Backends.MSSQL.ErrorSpec qualified as MSSQLErrorSpec
|
||||
import Hasura.Backends.MySQL.DataLoader.ExecuteTests qualified as MySQLDataLoader
|
||||
import Hasura.Backends.Postgres.Connection.MonadTx
|
||||
@ -113,7 +113,7 @@ unitSpecs = do
|
||||
describe "Data.Time" TimeSpec.spec
|
||||
describe "Data.Trie" TrieSpec.spec
|
||||
describe "Hasura.App" AppSpec.spec
|
||||
describe "Hasura.Backends.DataWrapper.API.V0" DataWrapper.API.V0Spec.spec
|
||||
describe "Hasura.Backends.DataConnector.API.V0" DataConnector.API.V0Spec.spec
|
||||
describe "Hasura.Backends.MSSQL.ErrorSpec" MSSQLErrorSpec.spec
|
||||
describe "Hasura.Backends.MySQL.DataLoader.ExecuteTests" MySQLDataLoader.spec
|
||||
describe "Hasura.Eventing" EventingSpec.spec
|
||||
|
@ -20,7 +20,7 @@ import Data.Text (Text)
|
||||
import Data.Text qualified as Text
|
||||
import Data.Text.Encoding qualified as Text
|
||||
import Data.Version (showVersion)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Options.Applicative
|
||||
import Paths_graphql_engine qualified as PackageInfo
|
||||
import Servant.Client (BaseUrl, parseBaseUrl)
|
||||
@ -56,7 +56,7 @@ parseCommandLine =
|
||||
info
|
||||
(helper <*> version <*> commandParser)
|
||||
( fullDesc
|
||||
<> header "Hasura GraphQL Data Wrapper Agent Test Utility"
|
||||
<> header "Hasura Data Connector Agent Test Utility"
|
||||
)
|
||||
|
||||
version :: Parser (a -> a)
|
||||
@ -88,7 +88,7 @@ commandParser =
|
||||
"export-openapi-spec"
|
||||
( info
|
||||
(helper <*> pure ExportOpenAPISpec)
|
||||
(progDesc "Exports the OpenAPI specification of the GDW API agents must implement")
|
||||
(progDesc "Exports the OpenAPI specification of the Data Connector API that agents must implement")
|
||||
)
|
||||
|
||||
testOptionsParser :: Parser TestOptions
|
||||
@ -99,7 +99,7 @@ testOptionsParser =
|
||||
( long "agent-base-url"
|
||||
<> short 'u'
|
||||
<> metavar "URL"
|
||||
<> help "The base URL of the GDW agent to be tested"
|
||||
<> help "The base URL of the Data Connector agent to be tested"
|
||||
)
|
||||
<*> option
|
||||
configValue
|
@ -6,8 +6,8 @@ import Control.Monad ((>=>))
|
||||
import Data.Aeson.Text (encodeToLazyText)
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Text.Lazy.IO qualified as Text
|
||||
import Hasura.Backends.DataWrapper.API (Routes (..), apiClient, openApiSchema)
|
||||
import Hasura.Backends.DataWrapper.API qualified as API
|
||||
import Hasura.Backends.DataConnector.API (Routes (..), apiClient, openApiSchema)
|
||||
import Hasura.Backends.DataConnector.API qualified as API
|
||||
import Network.HTTP.Client (defaultManagerSettings, newManager)
|
||||
import Servant.API (NamedRoutes)
|
||||
import Servant.Client (Client, ClientError, hoistClient, mkClientEnv, runClientM, (//))
|
@ -1,17 +1,17 @@
|
||||
# GraphQL Data Wrappers Agent Tests
|
||||
This test suite provides a set of tests that is able to test any GDW agent that contains the Chinook data set to ensure the agent is behaving as expected. The test executable is designed to be distributable to customers building GDW agents, but is also useful to ensure Hasura's own agents are working correctly.
|
||||
# Data Connector Agent Tests
|
||||
This test suite provides a set of tests that is able to test any Data Connector agent that contains the Chinook data set to ensure the agent is behaving as expected. The test executable is designed to be distributable to customers building Data Connector agents, but is also useful to ensure Hasura's own agents are working correctly.
|
||||
|
||||
Not all tests will be appropriate for all agents. Agents self-describe their capabilities and only the tests appropriate for those capabilities will be run.
|
||||
|
||||
The executable also has the ability to export the OpenAPI spec of the GDW agent API so that customers can use that to ensure their agent complies with the API format.
|
||||
The executable also has the ability to export the OpenAPI spec of the Data Connector agent API so that customers can use that to ensure their agent complies with the API format.
|
||||
|
||||
## How to Use
|
||||
First, start your GDW agent and ensure it is populated with the Chinook data set. For example, you could start the Reference Agent by following the instructions in [its README](../../gdw-agents/reference/README.md).
|
||||
First, start your Data Connector agent and ensure it is populated with the Chinook data set. For example, you could start the Reference Agent by following the instructions in [its README](../../dc-agents/reference/README.md).
|
||||
|
||||
To run the tests against the agent (for example), you must specify the agent's URL on the command line (`-u`), as well as the agent's configuration JSON (`-s`, sent in the `X-Hasura-DataConnector-Config` header):
|
||||
|
||||
```
|
||||
cabal run test:tests-gdw-api -- test -u "http://localhost:8100" -s '{}'
|
||||
cabal run test:tests-dc-api -- test -u "http://localhost:8100" -s '{}'
|
||||
```
|
||||
|
||||
By default, the test suite will discover what capabilities the agent exposes by querying it. Otherwise, the user can use command line flags to specify which capabilities their agent has to ensure that it exposes the expected capabilities and that the test suite only runs the tests that correspond to those capabilities.
|
||||
@ -19,7 +19,7 @@ By default, the test suite will discover what capabilities the agent exposes by
|
||||
To set the agent's available the capabilities use `-c` and comma separate them:
|
||||
|
||||
```
|
||||
> cabal run test:tests-gdw-api -- test -u "http://localhost:8100" -s '{}' -c relationships
|
||||
> cabal run test:tests-dc-api -- test -u "http://localhost:8100" -s '{}' -c relationships
|
||||
```
|
||||
|
||||
If `-c` is omitted, the default value is `autodetect`. If you have no capabilities, you can specify `none`.
|
||||
@ -27,5 +27,5 @@ If `-c` is omitted, the default value is `autodetect`. If you have no capabiliti
|
||||
To export the OpenAPI spec, you can run this command, and the spec will be written to stdout.
|
||||
|
||||
```
|
||||
> cabal run test:tests-gdw-api -- export-openapi-spec
|
||||
> cabal run test:tests-dc-api -- export-openapi-spec
|
||||
```
|
@ -27,7 +27,7 @@ import Data.Maybe (mapMaybe)
|
||||
import Data.Scientific (Scientific)
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics (Generic)
|
||||
import Hasura.Backends.DataWrapper.API (TableInfo (..))
|
||||
import Hasura.Backends.DataConnector.API (TableInfo (..))
|
||||
import Prelude
|
||||
|
||||
data Artist = Artist
|
||||
@ -59,13 +59,13 @@ instance FromJSON Album where
|
||||
<*> obj .: "artist_id"
|
||||
|
||||
schemaBS :: ByteString
|
||||
schemaBS = $(makeRelativeToProject "tests-gdw-api/Test/Data/schema-tables.json" >>= embedFile)
|
||||
schemaBS = $(makeRelativeToProject "tests-dc-api/Test/Data/schema-tables.json" >>= embedFile)
|
||||
|
||||
artistsBS :: ByteString
|
||||
artistsBS = $(makeRelativeToProject "tests-gdw-api/Test/Data/artists.json" >>= embedFile)
|
||||
artistsBS = $(makeRelativeToProject "tests-dc-api/Test/Data/artists.json" >>= embedFile)
|
||||
|
||||
albumsBS :: ByteString
|
||||
albumsBS = $(makeRelativeToProject "tests-gdw-api/Test/Data/albums.json" >>= embedFile)
|
||||
albumsBS = $(makeRelativeToProject "tests-dc-api/Test/Data/albums.json" >>= embedFile)
|
||||
|
||||
schemaTables :: [TableInfo]
|
||||
schemaTables = sortOn dtiName . either error id . eitherDecodeStrict $ schemaBS
|
@ -1,7 +1,7 @@
|
||||
module Test.QuerySpec (spec) where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Hasura.Backends.DataWrapper.API (Capabilities (..), Config, Routes (..))
|
||||
import Hasura.Backends.DataConnector.API (Capabilities (..), Config, Routes (..))
|
||||
import Servant.API (NamedRoutes)
|
||||
import Servant.Client (Client)
|
||||
import Test.Hspec
|
@ -8,7 +8,7 @@ import Data.List (sortOn)
|
||||
import Data.List.NonEmpty (NonEmpty (..))
|
||||
import Data.Ord (Down (..))
|
||||
import Data.Text (Text)
|
||||
import Hasura.Backends.DataWrapper.API
|
||||
import Hasura.Backends.DataConnector.API
|
||||
import Servant.API (NamedRoutes)
|
||||
import Servant.Client (Client, (//))
|
||||
import Test.Data qualified as Data
|
@ -9,7 +9,7 @@ import Data.HashMap.Strict qualified as HashMap
|
||||
import Data.List.NonEmpty (NonEmpty (..))
|
||||
import Data.Text (Text)
|
||||
import Data.Vector qualified as Vector
|
||||
import Hasura.Backends.DataWrapper.API
|
||||
import Hasura.Backends.DataConnector.API
|
||||
import Servant.API (NamedRoutes)
|
||||
import Servant.Client (Client, (//))
|
||||
import Test.Data qualified as Data
|
@ -1,7 +1,7 @@
|
||||
module Test.SchemaSpec (spec) where
|
||||
|
||||
import Data.List (sortOn)
|
||||
import Hasura.Backends.DataWrapper.API (Capabilities, Config, Routes (..), SchemaResponse (..), TableInfo (..))
|
||||
import Hasura.Backends.DataConnector.API (Capabilities, Config, Routes (..), SchemaResponse (..), TableInfo (..))
|
||||
import Servant.API (NamedRoutes)
|
||||
import Servant.Client (Client, (//))
|
||||
import Test.Data qualified as Data
|
Loading…
Reference in New Issue
Block a user