@@ -213,18 +213,21 @@ fn test_schema(id: DeploymentHash, id_type: IdType) -> Schema {
213213 id: ID!
214214 title: String!
215215 song: Song!
216+ author: User!
216217 }
217218
218219 type Photo implements Media @entity {
219220 id: ID!
220221 title: String!
221222 song: Song! @derivedFrom(field: \" media\" )
223+ author: User!
222224 }
223225
224226 type Video implements Media @entity {
225227 id: ID!
226228 title: String!
227229 song: Song! @derivedFrom(field: \" media\" )
230+ author: User!
228231 }
229232
230233 interface Release {
@@ -261,6 +264,7 @@ fn test_schema(id: DeploymentHash, id_type: IdType) -> Schema {
261264 latestSongReview: SongReview!
262265 latestBandReview: BandReview!
263266 latestReview: Review!
267+ medias: [Media!]! @derivedFrom(field: \" author\" )
264268 }
265269
266270 type AnonymousUser implements Author @entity {
@@ -315,12 +319,12 @@ async fn insert_test_entities(
315319 entity! { __typename: "User" , id: "u1" , name: "Baden" , latestSongReview: "r3" , latestBandReview: "r1" , latestReview: "r1" } ,
316320 entity! { __typename: "User" , id: "u2" , name: "Goodwill" , latestSongReview: "r4" , latestBandReview: "r2" , latestReview: "r2" } ,
317321 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" } ,
324328 entity! { __typename: "Album" , id: "rl1" , title: "Pop and Folk" , songs: vec![ s[ 3 ] , s[ 4 ] ] } ,
325329 entity! { __typename: "Single" , id: "rl2" , title: "Rock" , songs: vec![ s[ 2 ] ] } ,
326330 entity! { __typename: "Single" , id: "rl3" , title: "Cheesy" , songs: vec![ s[ 1 ] ] } ,
@@ -806,13 +810,51 @@ fn can_query_with_sorting_by_child_interface() {
806810}
807811
808812#[ 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+ } ) ;
811834}
812835
813836#[ 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+ } ) ;
816858}
817859
818860#[ test]
0 commit comments