diff --git a/fixtures/hasura/chinook/connector/chinook/native_queries/artists_with_albums_and_tracks.json b/fixtures/hasura/chinook/connector/chinook/native_queries/artists_with_albums_and_tracks.json index c4bfa50d..17f2dc3d 100644 --- a/fixtures/hasura/chinook/connector/chinook/native_queries/artists_with_albums_and_tracks.json +++ b/fixtures/hasura/chinook/connector/chinook/native_queries/artists_with_albums_and_tracks.json @@ -2,21 +2,20 @@ "name": "artists_with_albums_and_tracks", "representation": "collection", "inputCollection": "Artist", - "description": "combines artist, albums, and tracks into a single document per artist", + "description": "combines artist, albums, and tracks into a single document per artist - demonstrates array within array", "resultDocumentType": "ArtistWithAlbumsAndTracks", "objectTypes": { "ArtistWithAlbumsAndTracks": { "fields": { "_id": { "type": { "scalar": "objectId" } }, - "Name": { "type": { "scalar": "string" } }, - "Albums": { "type": { "arrayOf": { "object": "AlbumWithTracks" } } } + "name": { "type": { "scalar": "string" } }, + "albums": { "type": { "arrayOf": { "arrayOf": { "object": "TrackWithAlbumTitle" } } } } } }, - "AlbumWithTracks": { + "TrackWithAlbumTitle": { "fields": { - "_id": { "type": { "scalar": "objectId" } }, - "Title": { "type": { "scalar": "string" } }, - "Tracks": { "type": { "arrayOf": { "object": "Track" } } } + "track": { "type": { "scalar": "string" } }, + "album": { "type": { "scalar": "string" } } } } }, @@ -26,21 +25,25 @@ "from": "Album", "localField": "ArtistId", "foreignField": "ArtistId", - "as": "Albums", + "as": "albums", "pipeline": [ { "$lookup": { "from": "Track", "localField": "AlbumId", "foreignField": "AlbumId", - "as": "Tracks" - } - }, - { - "$replaceWith": { - "_id": "$_id", - "Title": "$Title", - "Tracks": "$Tracks" + "let": { + "albumTitle": "$Title" + }, + "as": "tracks", + "pipeline": [ + { + "$replaceWith": { + "track": "$Name", + "album": "$$albumTitle" + } + } + ] } } ] @@ -49,8 +52,8 @@ { "$replaceWith": { "_id": "$_id", - "Name": "$Name", - "Albums": "$Albums" + "name": "$Name", + "albums": { "$map": { "input": "$albums", "in": "$$this.tracks" } } } } ] diff --git a/fixtures/hasura/chinook/metadata/ArtistsWithAlbumsAndTracks.hml b/fixtures/hasura/chinook/metadata/ArtistsWithAlbumsAndTracks.hml index 43308e50..a1be50c0 100644 --- a/fixtures/hasura/chinook/metadata/ArtistsWithAlbumsAndTracks.hml +++ b/fixtures/hasura/chinook/metadata/ArtistsWithAlbumsAndTracks.hml @@ -1,45 +1,3 @@ ---- -kind: ObjectType -version: v1 -definition: - name: AlbumWithTracks - fields: - - name: id - type: Chinook_ObjectId! - - name: title - type: String! - - name: tracks - type: "[Track!]!" - graphql: - typeName: Chinook_AlbumWithTracks - inputTypeName: Chinook_AlbumWithTracksInput - dataConnectorTypeMapping: - - dataConnectorName: chinook - dataConnectorObjectType: AlbumWithTracks - fieldMapping: - id: - column: - name: _id - title: - column: - name: Title - tracks: - column: - name: Tracks - ---- -kind: TypePermissions -version: v1 -definition: - typeName: AlbumWithTracks - permissions: - - role: admin - output: - allowedFields: - - id - - title - - tracks - --- kind: ObjectType version: v1 @@ -49,7 +7,7 @@ definition: - name: id type: Chinook_ObjectId! - name: albums - type: "[AlbumWithTracks!]!" + type: "[[TrackWithAlbumTitle!]!]!" - name: name type: String! graphql: @@ -64,10 +22,10 @@ definition: name: _id albums: column: - name: Albums + name: albums name: column: - name: Name + name: name --- kind: TypePermissions @@ -143,3 +101,32 @@ definition: select: filter: null +--- +kind: ObjectType +version: v1 +definition: + name: TrackWithAlbumTitle + fields: + - name: album + type: String! + - name: track + type: String! + graphql: + typeName: Chinook_TrackWithAlbumTitle + inputTypeName: Chinook_TrackWithAlbumTitleInput + dataConnectorTypeMapping: + - dataConnectorName: chinook + dataConnectorObjectType: TrackWithAlbumTitle + +--- +kind: TypePermissions +version: v1 +definition: + typeName: TrackWithAlbumTitle + permissions: + - role: admin + output: + allowedFields: + - album + - track + diff --git a/fixtures/hasura/chinook/metadata/chinook.hml b/fixtures/hasura/chinook/metadata/chinook.hml index e242eade..81174270 100644 --- a/fixtures/hasura/chinook/metadata/chinook.hml +++ b/fixtures/hasura/chinook/metadata/chinook.hml @@ -536,22 +536,6 @@ definition: type: type: named name: String - AlbumWithTracks: - fields: - _id: - type: - type: named - name: ObjectId - Title: - type: - type: named - name: String - Tracks: - type: - type: array - element_type: - type: named - name: Track Artist: description: Object type for collection Artist fields: @@ -575,13 +559,15 @@ definition: type: type: named name: ObjectId - Albums: + albums: type: type: array element_type: - type: named - name: AlbumWithTracks - Name: + type: array + element_type: + type: named + name: TrackWithAlbumTitle + name: type: type: named name: String @@ -960,6 +946,16 @@ definition: type: type: named name: Decimal + TrackWithAlbumTitle: + fields: + album: + type: + type: named + name: String + track: + type: + type: named + name: String collections: - name: Album arguments: {} @@ -1050,7 +1046,7 @@ definition: - _id foreign_keys: {} - name: artists_with_albums_and_tracks - description: combines artist, albums, and tracks into a single document per artist + description: combines artist, albums, and tracks into a single document per artist - demonstrates array within array arguments: {} type: ArtistWithAlbumsAndTracks uniqueness_constraints: