@@ -931,6 +931,51 @@ mod tests {
931931 mostLovedBy: [User!]!
932932 }
933933
934+ interface Recipe {
935+ id: ID!
936+ name: String!
937+ author: User!
938+ lovedBy: [User!]!
939+ ingredients: [String!]!
940+ }
941+
942+ type FoodRecipe implements Recipe {
943+ id: ID!
944+ name: String!
945+ author: User!
946+ ingredients: [String!]!
947+ }
948+
949+ type DrinkRecipe implements Recipe {
950+ id: ID!
951+ name: String!
952+ author: User!
953+ ingredients: [String!]!
954+ }
955+
956+ interface Meal {
957+ id: ID!
958+ name: String!
959+ mostHatedBy: [User!]!
960+ mostLovedBy: [User!]!
961+ }
962+
963+ type Pizza implements Meal {
964+ id: ID!
965+ name: String!
966+ toppings: [String!]!
967+ mostHatedBy: [User!]!
968+ mostLovedBy: [User!]!
969+ }
970+
971+ type Burger implements Meal {
972+ id: ID!
973+ name: String!
974+ bun: String!
975+ mostHatedBy: [User!]!
976+ mostLovedBy: [User!]!
977+ }
978+
934979 type User {
935980 id: ID!
936981 name: String!
@@ -940,6 +985,10 @@ mod tests {
940985 favoritePet: Pet!
941986 leastFavoritePet: Pet @derivedFrom(field: "mostHatedBy")
942987 mostFavoritePets: [Pet!] @derivedFrom(field: "mostLovedBy")
988+ favoriteMeal: Meal!
989+ leastFavoriteMeal: Meal @derivedFrom(field: "mostHatedBy")
990+ mostFavoriteMeals: [Meal!] @derivedFrom(field: "mostLovedBy")
991+ recipes: [Recipe!]! @derivedFrom(field: "author")
943992 }
944993 "# ,
945994 )
@@ -977,8 +1026,74 @@ mod tests {
9771026 "leastFavoritePet__id" ,
9781027 "leastFavoritePet__name" ,
9791028 "mostFavoritePets" ,
1029+ "favoriteMeal" ,
1030+ "favoriteMeal__id" ,
1031+ "favoriteMeal__name" ,
1032+ "leastFavoriteMeal" ,
1033+ "leastFavoriteMeal__id" ,
1034+ "leastFavoriteMeal__name" ,
1035+ "mostFavoriteMeals" ,
1036+ "recipes" ,
9801037 ]
9811038 ) ;
1039+
1040+ let meal_order_by = schema
1041+ . get_named_type ( "Meal_orderBy" )
1042+ . expect ( "Meal_orderBy type is missing in derived API schema" ) ;
1043+
1044+ let enum_type = match meal_order_by {
1045+ TypeDefinition :: Enum ( t) => Some ( t) ,
1046+ _ => None ,
1047+ }
1048+ . expect ( "Meal_orderBy type is not an enum" ) ;
1049+
1050+ let values: Vec < & str > = enum_type
1051+ . values
1052+ . iter ( )
1053+ . map ( |value| value. name . as_str ( ) )
1054+ . collect ( ) ;
1055+
1056+ assert_eq ! (
1057+ values,
1058+ [
1059+ "id" ,
1060+ "name" ,
1061+ "mostHatedBy" ,
1062+ "mostLovedBy" ,
1063+ ]
1064+ ) ;
1065+
1066+ let recipe_order_by = schema
1067+ . get_named_type ( "Recipe_orderBy" )
1068+ . expect ( "Recipe_orderBy type is missing in derived API schema" ) ;
1069+
1070+ let enum_type = match recipe_order_by {
1071+ TypeDefinition :: Enum ( t) => Some ( t) ,
1072+ _ => None ,
1073+ }
1074+ . expect ( "Recipe_orderBy type is not an enum" ) ;
1075+
1076+ let values: Vec < & str > = enum_type
1077+ . values
1078+ . iter ( )
1079+ . map ( |value| value. name . as_str ( ) )
1080+ . collect ( ) ;
1081+
1082+ assert_eq ! (
1083+ values,
1084+ [
1085+ "id" ,
1086+ "name" ,
1087+ "author" ,
1088+ "author__id" ,
1089+ "author__name" ,
1090+ "author__favoriteFurType" ,
1091+ "author__favoritePet" ,
1092+ "author__leastFavoritePet" ,
1093+ "lovedBy" ,
1094+ "ingredients"
1095+ ]
1096+ ) ;
9821097 }
9831098
9841099 #[ test]
0 commit comments