Allow one-to-many relationships in Realm GraphQL
Two collections A & B. One field say _id of collection A is the "foreign key" for a field say "field1" in collection B.
A: {_id:1, k1:v1, k2:v2}
B: {f1:1, x1:y1} //Values of field f1 correspond to values of _id in A
B: {f1:1, x1:y2}
For one value of _id in A, there can be multiple corresponding documents in B. If we create a relationship currently in Realm GraphQL, only one document is fetched. The expected result set is 2 documents.
The current cumbersome workaround is to add an array field in collection A with all corresponding document IDs from collection B. This is not intuitive.
A simple approach to this without GraphQL is a $lookup between the two collections.
One to many is a common design pattern and exists in our sample_mflix database where documents from collection Comments relate to documents from the collection Movies.
