@@ -66,6 +66,9 @@ module.exports = {
66
66
isEndOfList : async function ( parent , args , info ) {
67
67
return await isEndOfList ( parent , args , info ) ;
68
68
} ,
69
+ addPossibleEdgeTypes : function ( query , schema , type_name , field_name ) {
70
+ return addPossibleEdgeTypes ( query , schema , type_name , field_name ) ;
71
+ } ,
69
72
getEdgeCollectionName : function ( type , field ) {
70
73
return getEdgeCollectionName ( type , field ) ;
71
74
} ,
@@ -1095,3 +1098,24 @@ function conditionalThrow(msg){
1095
1098
throw msg ;
1096
1099
}
1097
1100
}
1101
+
1102
+ /**
1103
+ * Add all possible edge-collections for the given type and field to query
1104
+ * @param query, schema, type_name, field_name, directionString (Optional)
1105
+ */
1106
+ function addPossibleEdgeTypes ( query , schema , type_name , field_name , directionString = "" ) {
1107
+ let type = schema . _typeMap [ type_name ] ;
1108
+ if ( graphql . isInterfaceType ( type ) ) {
1109
+ let possible_types = schema . getPossibleTypes ( type ) ;
1110
+ for ( let i in possible_types ) {
1111
+ if ( i != 0 ) {
1112
+ query . push ( aql `,` ) ;
1113
+ }
1114
+ let collection = db . collection ( getEdgeCollectionName ( possible_types [ i ] . name , field_name ) ) ;
1115
+ query . push ( aql `${ collection } ` ) ;
1116
+ }
1117
+ } else {
1118
+ let collection = db . collection ( getEdgeCollectionName ( type . name , field_name ) ) ;
1119
+ query . push ( aql `${ collection } ` ) ;
1120
+ }
1121
+ }
0 commit comments