mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
chore(server): add basic Explain test for Logical Models
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8502 GitOrigin-RevId: 7cc64139d98155b94c0aadf16f8717881ea2add6
This commit is contained in:
parent
abcb2b4489
commit
77d6058f3e
@ -16,7 +16,7 @@ import Harness.Test.Fixture qualified as Fixture
|
|||||||
import Harness.Test.Schema (Table (..), table)
|
import Harness.Test.Schema (Table (..), table)
|
||||||
import Harness.Test.Schema qualified as Schema
|
import Harness.Test.Schema qualified as Schema
|
||||||
import Harness.TestEnvironment (GlobalTestEnvironment, TestEnvironment (options), getBackendTypeConfig)
|
import Harness.TestEnvironment (GlobalTestEnvironment, TestEnvironment (options), getBackendTypeConfig)
|
||||||
import Harness.Yaml (shouldBeYaml, shouldReturnYaml)
|
import Harness.Yaml (shouldAtLeastBe, shouldBeYaml, shouldReturnYaml)
|
||||||
import Hasura.Prelude
|
import Hasura.Prelude
|
||||||
import Test.Hspec (SpecWith, describe, it)
|
import Test.Hspec (SpecWith, describe, it)
|
||||||
|
|
||||||
@ -78,6 +78,34 @@ tests = do
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe "Testing Logical Models" $ do
|
describe "Testing Logical Models" $ do
|
||||||
|
it "Explain works" $ \testEnvironment -> do
|
||||||
|
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
||||||
|
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||||
|
|
||||||
|
Schema.trackLogicalModel sourceName helloWorldLogicalModel testEnvironment
|
||||||
|
|
||||||
|
let explain :: Value
|
||||||
|
explain =
|
||||||
|
[graphql|
|
||||||
|
query {
|
||||||
|
hello_world_function (where: { two: { _eq: "world" } }){
|
||||||
|
one
|
||||||
|
two
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|]
|
||||||
|
|
||||||
|
expected =
|
||||||
|
[interpolateYaml|
|
||||||
|
[{
|
||||||
|
"field": "hello_world_function"
|
||||||
|
}]
|
||||||
|
|]
|
||||||
|
|
||||||
|
actual <- GraphqlEngine.postExplain testEnvironment explain
|
||||||
|
|
||||||
|
actual `shouldAtLeastBe` expected
|
||||||
|
|
||||||
it "Descriptions and nullability appear in the schema" $ \testEnvironment -> do
|
it "Descriptions and nullability appear in the schema" $ \testEnvironment -> do
|
||||||
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
||||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||||
|
Loading…
Reference in New Issue
Block a user