mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
super-connector: Mutations support for MySQL
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7669 Co-authored-by: Brandon Martin <40686+codedmart@users.noreply.github.com> Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com> GitOrigin-RevId: 0e3e764b0e10fc0065752503952b57fb9a67f29a
This commit is contained in:
parent
17a96a0fc6
commit
af0c9417c4
@ -22,7 +22,7 @@ import Data.Aeson.KeyMap qualified as KM
|
||||
import Data.Aeson.Lens
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Vector qualified as Vector
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..))
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..), ScalarTypes (..))
|
||||
import Harness.Backend.DataConnector.Chinook qualified as Chinook
|
||||
import Harness.Backend.DataConnector.Chinook.Reference qualified as Reference
|
||||
import Harness.Backend.DataConnector.Chinook.Sqlite qualified as Sqlite
|
||||
@ -122,7 +122,7 @@ schemaInspectionTests opts = describe "Schema and Source Inspection" $ do
|
||||
|]
|
||||
|
||||
describe "get_table_info" $ do
|
||||
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
|
||||
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}, scalarTypes = ScalarTypes {..}}) -> do
|
||||
let removeDescriptions (J.Object o) = J.Object (KM.delete "description" (removeDescriptions <$> o))
|
||||
removeDescriptions (J.Array a) = J.Array (removeDescriptions <$> a)
|
||||
removeDescriptions x = x
|
||||
@ -167,17 +167,17 @@ schemaInspectionTests opts = describe "Schema and Source Inspection" $ do
|
||||
columns:
|
||||
- name: *albumId
|
||||
nullable: false
|
||||
type: number
|
||||
type: *_stIntegerType
|
||||
insertable: *supportsInserts
|
||||
updatable: false
|
||||
- name: *artistId
|
||||
nullable: false
|
||||
type: number
|
||||
type: *_stIntegerType
|
||||
insertable: *supportsInserts
|
||||
updatable: *supportsUpdates
|
||||
- name: *title
|
||||
nullable: false
|
||||
type: string
|
||||
type: *_stStringType
|
||||
insertable: *supportsInserts
|
||||
updatable: *supportsUpdates
|
||||
name: *album
|
||||
|
@ -5,6 +5,7 @@
|
||||
module Harness.Backend.DataConnector.Chinook
|
||||
( ChinookTestEnv (..),
|
||||
NameFormatting (..),
|
||||
ScalarTypes (..),
|
||||
mkChinookCloneTestEnvironment,
|
||||
mkChinookStaticTestEnvironment,
|
||||
setupChinookSourceAction,
|
||||
@ -34,7 +35,9 @@ data ChinookTestEnv = ChinookTestEnv
|
||||
-- | Default configuration for the backend config that sets the agent configuration
|
||||
backendAgentConfig :: Aeson.Value,
|
||||
-- | Name formatting functions to correct for backend-specific naming rules
|
||||
nameFormatting :: NameFormatting
|
||||
nameFormatting :: NameFormatting,
|
||||
-- | Backend-specific expected scalar types
|
||||
scalarTypes :: ScalarTypes
|
||||
}
|
||||
|
||||
data NameFormatting = NameFormatting
|
||||
@ -47,13 +50,19 @@ data NameFormatting = NameFormatting
|
||||
_nfFormatForeignKeyName :: Text -> Text
|
||||
}
|
||||
|
||||
data ScalarTypes = ScalarTypes
|
||||
{ _stFloatType :: Text,
|
||||
_stIntegerType :: Text,
|
||||
_stStringType :: Text
|
||||
}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- | Create a test environment that uses agent dataset cloning to clone a copy of the Chinook
|
||||
-- DB for the test and use that as the source config configured in HGE.
|
||||
-- This should be used with agents that support datasets.
|
||||
mkChinookCloneTestEnvironment :: NameFormatting -> TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookCloneTestEnvironment nameFormatting testEnv = do
|
||||
mkChinookCloneTestEnvironment :: NameFormatting -> ScalarTypes -> TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookCloneTestEnvironment nameFormatting scalarTypes testEnv = do
|
||||
backendTypeConfig <- getBackendTypeConfig testEnv `onNothing` fail "Unable to find backend type config in this test environment"
|
||||
agentUrl <- Fixture.backendServerUrl backendTypeConfig `onNothing` fail ("Backend " <> show (Fixture.backendType backendTypeConfig) <> " does not have a server url")
|
||||
cloneConfig <- API._dccrConfig <$> createManagedClone agentUrl testEnv (API.DatasetTemplateName "Chinook")
|
||||
@ -65,16 +74,16 @@ mkChinookCloneTestEnvironment nameFormatting testEnv = do
|
||||
template:
|
||||
timeout:
|
||||
|]
|
||||
pure $ ChinookTestEnv sourceConfig agentBackendConfig nameFormatting
|
||||
pure $ ChinookTestEnv sourceConfig agentBackendConfig nameFormatting scalarTypes
|
||||
|
||||
-- | Create a test environment that uses the source config specified to connect to a specific DB on the agent
|
||||
-- that contains the Chinook dataset.
|
||||
-- This should be used with agents that do not support datasets.
|
||||
mkChinookStaticTestEnvironment :: NameFormatting -> Aeson.Value -> TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookStaticTestEnvironment nameFormatting sourceConfig testEnv = do
|
||||
mkChinookStaticTestEnvironment :: NameFormatting -> ScalarTypes -> Aeson.Value -> TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookStaticTestEnvironment nameFormatting scalarTypes sourceConfig testEnv = do
|
||||
backendTypeConfig <- getBackendTypeConfig testEnv `onNothing` fail "Unable to find backend type config in this test environment"
|
||||
let agentBackendConfig = mkAgentBackendConfig backendTypeConfig
|
||||
pure $ ChinookTestEnv sourceConfig agentBackendConfig nameFormatting
|
||||
pure $ ChinookTestEnv sourceConfig agentBackendConfig nameFormatting scalarTypes
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -14,7 +14,7 @@ where
|
||||
|
||||
import Control.Monad.Managed (Managed)
|
||||
import Data.Aeson qualified as Aeson
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..))
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..), ScalarTypes (..))
|
||||
import Harness.Backend.DataConnector.Chinook qualified as Chinook
|
||||
import Harness.Quoter.Yaml (yaml)
|
||||
import Harness.Test.BackendType qualified as BackendType
|
||||
@ -83,11 +83,19 @@ backendTypeConfig =
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
mkChinookStaticTestEnvironment :: TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookStaticTestEnvironment = Chinook.mkChinookStaticTestEnvironment nameFormatting sourceConfiguration
|
||||
mkChinookStaticTestEnvironment = Chinook.mkChinookStaticTestEnvironment nameFormatting scalarTypes sourceConfiguration
|
||||
|
||||
nameFormatting :: NameFormatting
|
||||
nameFormatting = NameFormatting id id id
|
||||
|
||||
scalarTypes :: ScalarTypes
|
||||
scalarTypes =
|
||||
ScalarTypes
|
||||
{ _stFloatType = "number",
|
||||
_stIntegerType = "number",
|
||||
_stStringType = "string"
|
||||
}
|
||||
|
||||
-- | Reference Agent specific @sources@ entry @configuration@ field.
|
||||
sourceConfiguration :: Aeson.Value
|
||||
sourceConfiguration =
|
||||
|
@ -13,7 +13,7 @@ where
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Control.Monad.Managed (Managed)
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..))
|
||||
import Harness.Backend.DataConnector.Chinook (ChinookTestEnv, NameFormatting (..), ScalarTypes (..))
|
||||
import Harness.Backend.DataConnector.Chinook qualified as Chinook
|
||||
import Harness.Quoter.Yaml (yaml)
|
||||
import Harness.Test.BackendType qualified as BackendType
|
||||
@ -107,7 +107,7 @@ backendTypeConfig =
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
mkChinookCloneTestEnvironment :: TestEnvironment -> Managed ChinookTestEnv
|
||||
mkChinookCloneTestEnvironment = Chinook.mkChinookCloneTestEnvironment nameFormatting
|
||||
mkChinookCloneTestEnvironment = Chinook.mkChinookCloneTestEnvironment nameFormatting scalarTypes
|
||||
|
||||
nameFormatting :: NameFormatting
|
||||
nameFormatting = NameFormatting id id formatForeignKeyName
|
||||
@ -118,6 +118,14 @@ formatForeignKeyName = \case
|
||||
"Artist" -> "Album.ArtistId->Artist.ArtistId"
|
||||
x -> x
|
||||
|
||||
scalarTypes :: ScalarTypes
|
||||
scalarTypes =
|
||||
ScalarTypes
|
||||
{ _stFloatType = "number",
|
||||
_stIntegerType = "number",
|
||||
_stStringType = "string"
|
||||
}
|
||||
|
||||
chinookFixture :: Fixture ChinookTestEnv
|
||||
chinookFixture =
|
||||
Fixture
|
||||
|
Loading…
Reference in New Issue
Block a user