2022-05-11 09:14:25 +03:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
|
|
|
|
-- | Query Tests for Data Connector Backend
|
2022-06-24 09:58:25 +03:00
|
|
|
module Test.DataConnector.QuerySpec
|
2022-05-11 09:14:25 +03:00
|
|
|
( spec,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2022-06-25 22:05:58 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2022-05-11 09:14:25 +03:00
|
|
|
import Harness.Backend.DataConnector qualified as DataConnector
|
|
|
|
import Harness.GraphqlEngine qualified as GraphqlEngine
|
|
|
|
import Harness.Quoter.Graphql (graphql)
|
2022-08-05 12:34:25 +03:00
|
|
|
import Harness.Quoter.Yaml (yaml)
|
2022-08-10 10:52:57 +03:00
|
|
|
import Harness.Test.Fixture qualified as Fixture
|
2022-05-11 09:14:25 +03:00
|
|
|
import Harness.TestEnvironment (TestEnvironment)
|
2022-09-07 06:42:20 +03:00
|
|
|
import Harness.TestEnvironment qualified as TE
|
2022-08-05 12:34:25 +03:00
|
|
|
import Harness.Yaml (shouldReturnYaml)
|
2022-08-03 17:18:43 +03:00
|
|
|
import Hasura.Prelude
|
2022-09-07 06:42:20 +03:00
|
|
|
import Test.Hspec (SpecWith, describe, it, pendingWith)
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2022-06-25 22:05:58 +03:00
|
|
|
-- Reference Agent Query Tests
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
spec :: SpecWith TestEnvironment
|
|
|
|
spec =
|
2022-08-10 10:52:57 +03:00
|
|
|
Fixture.runWithLocalTestEnvironment
|
2022-09-07 06:42:20 +03:00
|
|
|
( ( \(DataConnector.TestSourceConfig backendType backendConfig _sourceConfig md) ->
|
|
|
|
(Fixture.fixture $ Fixture.Backend backendType)
|
2022-08-11 18:03:04 +03:00
|
|
|
{ Fixture.setupTeardown = \(testEnv, _) ->
|
|
|
|
[ DataConnector.setupFixtureAction
|
2022-09-07 06:42:20 +03:00
|
|
|
md
|
|
|
|
backendConfig
|
2022-08-11 18:03:04 +03:00
|
|
|
testEnv
|
|
|
|
]
|
|
|
|
}
|
2022-09-07 06:42:20 +03:00
|
|
|
)
|
|
|
|
<$> DataConnector.backendConfigs
|
2022-08-03 17:18:43 +03:00
|
|
|
)
|
2022-05-11 09:14:25 +03:00
|
|
|
tests
|
|
|
|
|
2022-06-25 22:05:58 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2022-08-10 10:52:57 +03:00
|
|
|
tests :: Fixture.Options -> SpecWith (TestEnvironment, a)
|
2022-05-11 09:14:25 +03:00
|
|
|
tests opts = describe "Queries" $ do
|
|
|
|
describe "Basic Tests" $ do
|
|
|
|
it "works with simple object query" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
|
|
|
albums(limit: 1) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
2022-06-13 23:58:44 +03:00
|
|
|
albums:
|
2022-05-11 09:14:25 +03:00
|
|
|
- id: 1
|
2022-06-13 23:58:44 +03:00
|
|
|
title: For Those About To Rock We Salute You
|
2022-05-11 09:14:25 +03:00
|
|
|
|]
|
|
|
|
|
|
|
|
it "works with a primary key" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums_by_pk(id: 1) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums_by_pk:
|
2022-07-20 08:20:49 +03:00
|
|
|
id: 1
|
|
|
|
title: "For Those About To Rock We Salute You"
|
2022-07-01 15:20:07 +03:00
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with non existent primary key" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums_by_pk(id: 999999) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
2022-07-20 08:20:49 +03:00
|
|
|
albums_by_pk: null
|
2022-07-01 15:20:07 +03:00
|
|
|
|]
|
|
|
|
|
|
|
|
it "works with a composite primary key" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
|
|
|
PlaylistTrack_by_pk(PlaylistId: 1, TrackId: 2) {
|
|
|
|
Playlist {
|
|
|
|
Name
|
|
|
|
}
|
|
|
|
Track {
|
|
|
|
Name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
PlaylistTrack_by_pk:
|
2022-07-20 08:20:49 +03:00
|
|
|
Playlist:
|
|
|
|
Name: "Music"
|
|
|
|
Track:
|
|
|
|
Name: "Balls to the Wall"
|
2022-07-01 15:20:07 +03:00
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
2022-09-07 06:42:20 +03:00
|
|
|
it "works with pagination" $ \(testEnvironment, _) -> do
|
|
|
|
-- NOTE: We order by in this pagination test to ensure that the rows are ordered correctly (which they are not in db.chinook.sqlite)
|
2022-08-19 10:00:46 +03:00
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
2022-09-07 06:42:20 +03:00
|
|
|
albums (limit: 3, offset: 2, order_by: {id: asc}) {
|
2022-08-19 10:00:46 +03:00
|
|
|
id
|
|
|
|
}
|
2022-07-01 15:20:07 +03:00
|
|
|
}
|
2022-08-19 10:00:46 +03:00
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 3
|
|
|
|
- id: 4
|
|
|
|
- id: 5
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
2022-06-07 04:34:37 +03:00
|
|
|
describe "Array Relationships" $ do
|
2022-08-29 03:20:00 +03:00
|
|
|
describe "Manual" $ do
|
|
|
|
it "joins on album id" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getArtist {
|
|
|
|
artists_by_pk(id: 1) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
albums {
|
|
|
|
title
|
|
|
|
}
|
2022-07-01 15:20:07 +03:00
|
|
|
}
|
|
|
|
}
|
2022-08-29 03:20:00 +03:00
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
artists_by_pk:
|
|
|
|
name: AC/DC
|
|
|
|
id: 1
|
|
|
|
albums:
|
|
|
|
- title: For Those About To Rock We Salute You
|
|
|
|
- title: Let There Be Rock
|
|
|
|
|]
|
|
|
|
|
2022-09-07 06:42:20 +03:00
|
|
|
describe "Foreign Key Constraint On" do
|
|
|
|
it "joins on PlaylistId" $ \(testEnvironment, _) -> do
|
|
|
|
-- NOTE: Ordering is used for the query due to inconsistencies in data-set ordering.
|
2022-08-29 03:20:00 +03:00
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getPlaylist {
|
|
|
|
Playlist_by_pk(PlaylistId: 1) {
|
2022-09-07 06:42:20 +03:00
|
|
|
Tracks (order_by: {TrackId: desc}, limit: 3) {
|
2022-08-29 03:20:00 +03:00
|
|
|
TrackId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
Playlist_by_pk:
|
|
|
|
Tracks:
|
2022-09-07 06:42:20 +03:00
|
|
|
- TrackId: 3503
|
|
|
|
- TrackId: 3502
|
|
|
|
- TrackId: 3501
|
2022-08-29 03:20:00 +03:00
|
|
|
|]
|
2022-06-07 04:34:37 +03:00
|
|
|
|
2022-09-07 06:42:20 +03:00
|
|
|
describe "Object Relationships" do
|
|
|
|
describe "Manual" do
|
2022-08-29 03:20:00 +03:00
|
|
|
it "joins on artist id" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
|
|
|
albums_by_pk(id: 1) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
artist {
|
|
|
|
name
|
|
|
|
}
|
2022-07-01 15:20:07 +03:00
|
|
|
}
|
|
|
|
}
|
2022-08-29 03:20:00 +03:00
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
albums_by_pk:
|
|
|
|
id: 1
|
|
|
|
title: "For Those About To Rock We Salute You"
|
|
|
|
artist:
|
|
|
|
name: "AC/DC"
|
|
|
|
|]
|
|
|
|
|
|
|
|
describe "Foreign Key Constraint On" $ do
|
|
|
|
it "joins on PlaylistId" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getPlaylist {
|
|
|
|
PlaylistTrack_by_pk(PlaylistId: 1, TrackId: 2) {
|
|
|
|
Playlist {
|
|
|
|
Name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
PlaylistTrack_by_pk:
|
|
|
|
Playlist:
|
|
|
|
Name: "Music"
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
describe "Where Clause Tests" $ do
|
|
|
|
it "works with '_in' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums(where: {id: {_in: [1, 3, 5]}}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
- id: 3
|
|
|
|
title: Restless and Wild
|
|
|
|
- id: 5
|
|
|
|
title: Big Ones
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_nin' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums(where: {id: {_in: [1, 3, 5]}, title: {_nin: ["Big Ones"]}}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
- id: 3
|
|
|
|
title: Restless and Wild
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_eq' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums(where: {id: {_eq: 1}}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_neq' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums(where: {id: {_neq: 2, _in: [1, 2, 3]}}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
- id: 3
|
|
|
|
title: Restless and Wild
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_lt' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getAlbum {
|
|
|
|
albums(where: {id: {_lt: 2}}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_lte' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getArtists {
|
|
|
|
artists(where: {id: {_lte: 2}}) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
artists:
|
|
|
|
- id: 1
|
|
|
|
name: AC/DC
|
|
|
|
- id: 2
|
|
|
|
name: Accept
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_gt' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getArtists {
|
|
|
|
artists(where: {id: {_gt: 274}}) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
artists:
|
|
|
|
- id: 275
|
|
|
|
name: Philip Glass Ensemble
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
|
|
|
|
it "works with '_gte' predicate" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
2022-07-01 15:20:07 +03:00
|
|
|
query getArtists {
|
|
|
|
artists(where: {id: {_gte: 274}}) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
2022-05-11 09:14:25 +03:00
|
|
|
)
|
|
|
|
[yaml|
|
2022-07-01 15:20:07 +03:00
|
|
|
data:
|
|
|
|
artists:
|
|
|
|
- id: 274
|
|
|
|
name: Nash Ensemble
|
|
|
|
- id: 275
|
|
|
|
name: Philip Glass Ensemble
|
|
|
|
|]
|
2022-08-19 10:00:46 +03:00
|
|
|
|
|
|
|
describe "Order By Tests" $ do
|
|
|
|
it "works with order_by id asc" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
|
|
|
albums(limit: 3, order_by: {id: asc}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 1
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
- id: 2
|
|
|
|
title: Balls to the Wall
|
|
|
|
- id: 3
|
|
|
|
title: Restless and Wild
|
|
|
|
|]
|
|
|
|
|
|
|
|
it "works with order_by id desc" $ \(testEnvironment, _) ->
|
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbum {
|
|
|
|
albums(limit: 3, order_by: {id: desc}) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- id: 347
|
|
|
|
title: Koyaanisqatsi (Soundtrack from the Motion Picture)
|
|
|
|
- id: 346
|
|
|
|
title: 'Mozart: Chamber Music'
|
|
|
|
- id: 345
|
|
|
|
title: 'Monteverdi: L''Orfeo'
|
|
|
|
|]
|
|
|
|
|
2022-09-07 06:42:20 +03:00
|
|
|
it "can order by an aggregate" $ \(testEnvironment, _) -> do
|
|
|
|
when (TE.backendType testEnvironment == Just Fixture.DataConnectorSqlite) (pendingWith "TODO: Test currently broken for SQLite DataConnector")
|
2022-08-19 10:00:46 +03:00
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getArtists {
|
|
|
|
artists(limit: 3, order_by: {albums_aggregate: {count: desc}}) {
|
|
|
|
name
|
|
|
|
albums_aggregate {
|
|
|
|
aggregate {
|
|
|
|
count
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
artists:
|
|
|
|
- name: Iron Maiden
|
|
|
|
albums_aggregate:
|
|
|
|
aggregate:
|
|
|
|
count: 21
|
|
|
|
- name: Led Zeppelin
|
|
|
|
albums_aggregate:
|
|
|
|
aggregate:
|
|
|
|
count: 14
|
|
|
|
- name: Deep Purple
|
|
|
|
albums_aggregate:
|
|
|
|
aggregate:
|
|
|
|
count: 11
|
|
|
|
|]
|
|
|
|
|
2022-09-07 06:42:20 +03:00
|
|
|
it "can order by a related field" $ \(testEnvironment, _) -> do
|
|
|
|
when (TE.backendType testEnvironment == Just Fixture.DataConnectorSqlite) (pendingWith "TODO: Test currently broken for SQLite DataConnector")
|
2022-08-19 10:00:46 +03:00
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query getAlbums {
|
|
|
|
albums(limit: 4, order_by: [{artist: {name: asc}}, {title: desc}]) {
|
|
|
|
artist {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
albums:
|
|
|
|
- artist:
|
|
|
|
name: AC/DC
|
|
|
|
title: Let There Be Rock
|
|
|
|
- artist:
|
|
|
|
name: AC/DC
|
|
|
|
title: For Those About To Rock We Salute You
|
|
|
|
- artist:
|
|
|
|
name: Aaron Copland & London Symphony Orchestra
|
|
|
|
title: A Copland Celebration, Vol. I
|
|
|
|
- artist:
|
|
|
|
name: Aaron Goldberg
|
|
|
|
title: Worlds
|
|
|
|
|]
|
2022-09-06 07:24:46 +03:00
|
|
|
describe "Custom scalar types and operators" $ do
|
2022-09-07 06:42:20 +03:00
|
|
|
it "works with custom scalar types and comparison operators" $ \(testEnvironment, _) -> do
|
|
|
|
when (TE.backendType testEnvironment == Just Fixture.DataConnectorSqlite) do
|
|
|
|
pendingWith "TODO: Test currently broken for SQLite DataConnector"
|
2022-09-06 07:24:46 +03:00
|
|
|
shouldReturnYaml
|
|
|
|
opts
|
|
|
|
( GraphqlEngine.postGraphql
|
|
|
|
testEnvironment
|
|
|
|
[graphql|
|
|
|
|
query MyQuery {
|
|
|
|
employees(where: {birth_date: {in_year: 1965}}) {
|
|
|
|
birth_date
|
|
|
|
last_name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
)
|
|
|
|
[yaml|
|
|
|
|
data:
|
|
|
|
employees:
|
|
|
|
- birth_date: '1965-03-03T00:00:00-08:00'
|
|
|
|
last_name: Johnson
|
|
|
|
|]
|