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.
Hi all,
We recently announced that we have decided to deprecate the Atlas GraphQL API, and current users should’ve received an email explaining the details of the deprecation and end-of-life plan. Consequently, we will not be adding new features going forward and are updating the status for all related feedback accordingly.
Please read our announcement in the MongoDB Developer Center for more details and guidance on the migration process and timeline. Should you have any questions or need further assistance, please reach out to our support team via the MongoDB Support Portal.
We truly prioritize your satisfaction and success, and we thank you for your patience and the feedback you have provided us over the years.