Every question I seem to find about converting GraphQL results to Swift Objects or using the remote access api in swift only has one answer right now which is to add the objects to a non synced realm but there’s no documentation whatsoever. So I’d love some help with this from anyone who has implemented this in their app. I’d be grateful because I’ve been trying continuously to figure it out.
For context I’m using an atlas function to search a query and return the resulting documents as objects to the user in a list. When the user taps on the ListCell it takes them to a detail view so I need the full object. I can’t use projections or individual values from the results to construct my search view.
I’ve tried to use the Object(init: value)
and it always fails with the same error citing that ObjectId was not found.
I’ve tried the BSON library on Github to try and decode the BSON values but that didn’t work either.
At this point the only solution I haven’t tried is parsing through each Document and decoding everything using a switch statement and assign values individually to each field for every object. I know that will definitely work but That just seems messy and def not the most elegant solution.
If anybody has a better solution or can tell me how to add add objects from a [String : AnyBSON]
search result to a realm. Please help.
Thank you for your time.