@@ -213,18 +213,21 @@ fn test_schema(id: DeploymentHash, id_type: IdType) -> Schema {
213
213
id: ID!
214
214
title: String!
215
215
song: Song!
216
+ author: User!
216
217
}
217
218
218
219
type Photo implements Media @entity {
219
220
id: ID!
220
221
title: String!
221
222
song: Song! @derivedFrom(field: \" media\" )
223
+ author: User!
222
224
}
223
225
224
226
type Video implements Media @entity {
225
227
id: ID!
226
228
title: String!
227
229
song: Song! @derivedFrom(field: \" media\" )
230
+ author: User!
228
231
}
229
232
230
233
interface Release {
@@ -261,6 +264,7 @@ fn test_schema(id: DeploymentHash, id_type: IdType) -> Schema {
261
264
latestSongReview: SongReview!
262
265
latestBandReview: BandReview!
263
266
latestReview: Review!
267
+ medias: [Media!]! @derivedFrom(field: \" author\" )
264
268
}
265
269
266
270
type AnonymousUser implements Author @entity {
@@ -315,12 +319,12 @@ async fn insert_test_entities(
315
319
entity! { __typename: "User" , id: "u1" , name: "Baden" , latestSongReview: "r3" , latestBandReview: "r1" , latestReview: "r1" } ,
316
320
entity! { __typename: "User" , id: "u2" , name: "Goodwill" , latestSongReview: "r4" , latestBandReview: "r2" , latestReview: "r2" } ,
317
321
entity! { __typename: "AnonymousUser" , id: "u3" , name: "Anonymous 3" , latestSongReview: "r6" , latestBandReview: "r5" , latestReview: "r5" } ,
318
- entity! { __typename: "Photo" , id: md[ 1 ] , title: "Cheesy Tune Single Cover" } ,
319
- entity! { __typename: "Video" , id: md[ 2 ] , title: "Cheesy Tune Music Video" } ,
320
- entity! { __typename: "Photo" , id: md[ 3 ] , title: "Rock Tune Single Cover" } ,
321
- entity! { __typename: "Video" , id: md[ 4 ] , title: "Rock Tune Music Video" } ,
322
- entity! { __typename: "Photo" , id: md[ 5 ] , title: "Pop Tune Single Cover" } ,
323
- entity! { __typename: "Video" , id: md[ 6 ] , title: "Folk Tune Music Video" } ,
322
+ entity! { __typename: "Photo" , id: md[ 1 ] , title: "Cheesy Tune Single Cover" , author : "u1" } ,
323
+ entity! { __typename: "Video" , id: md[ 2 ] , title: "Cheesy Tune Music Video" , author : "u2" } ,
324
+ entity! { __typename: "Photo" , id: md[ 3 ] , title: "Rock Tune Single Cover" , author : "u1" } ,
325
+ entity! { __typename: "Video" , id: md[ 4 ] , title: "Rock Tune Music Video" , author : "u2" } ,
326
+ entity! { __typename: "Photo" , id: md[ 5 ] , title: "Pop Tune Single Cover" , author : "u1" } ,
327
+ entity! { __typename: "Video" , id: md[ 6 ] , title: "Folk Tune Music Video" , author : "u2" } ,
324
328
entity! { __typename: "Album" , id: "rl1" , title: "Pop and Folk" , songs: vec![ s[ 3 ] , s[ 4 ] ] } ,
325
329
entity! { __typename: "Single" , id: "rl2" , title: "Rock" , songs: vec![ s[ 2 ] ] } ,
326
330
entity! { __typename: "Single" , id: "rl3" , title: "Cheesy" , songs: vec![ s[ 1 ] ] } ,
@@ -806,13 +810,51 @@ fn can_query_with_sorting_by_child_interface() {
806
810
}
807
811
808
812
#[ test]
809
- fn can_query_interface_with_sorting_by_child_entity ( ) {
810
- // TODO
813
+ fn can_not_query_interface_with_sorting_by_child_entity ( ) {
814
+ const QUERY : & str = "
815
+ query {
816
+ desc: medias(first: 100, orderBy: author__name, orderDirection: desc) {
817
+ title
818
+ author {
819
+ name
820
+ }
821
+ }
822
+ asc: medias(first: 100, orderBy: author__name, orderDirection: asc) {
823
+ title
824
+ author {
825
+ name
826
+ }
827
+ }
828
+ }" ;
829
+
830
+ run_query ( QUERY , |result, _| {
831
+ // Sorting an interface by child-level entity (derived) is not supported
832
+ assert ! ( result. has_errors( ) ) ;
833
+ } ) ;
811
834
}
812
835
813
836
#[ test]
814
- fn can_query_interface_with_sorting_by_derived_child_entity ( ) {
815
- // TODO
837
+ fn can_not_query_interface_with_sorting_by_derived_child_entity ( ) {
838
+ const QUERY : & str = "
839
+ query {
840
+ desc: medias(first: 100, orderBy: song__title, orderDirection: desc) {
841
+ title
842
+ song {
843
+ title
844
+ }
845
+ }
846
+ asc: medias(first: 100, orderBy: song__title, orderDirection: asc) {
847
+ title
848
+ song {
849
+ title
850
+ }
851
+ }
852
+ }" ;
853
+
854
+ run_query ( QUERY , |result, _| {
855
+ // Sorting an interface by child-level entity is not supported
856
+ assert ! ( result. has_errors( ) ) ;
857
+ } ) ;
816
858
}
817
859
818
860
#[ test]
0 commit comments