GraphQL on iOS and Android?

I am in the beginning stages of creating a MongoDB Realm app, and I am trying to determine how my iOS app will use Realm to communicate with the database.

I read your documentation and it appears that you provide GraphQL as a means of communication for client applications: “The MongoDB Realm GraphQL API allows client applications to access data stored in a linked MongoDB cluster using any standard GraphQL client.”

However, when I read the iOS SDK documentation, there is no mention of using GraphQL. It only appears to be supported in the Web SDK. Is this correct? Is it not possible to use GraphQL from an iOS app? If so, your documentation seems misleading since there would only be 1 SDK that supports GraphQL.

Our strong recommendation is to use MongoDB Realm Sync to synchronise your data between Atlas and a Realm database embedded in your app. That way, you always have the data available - even when not connected to the internet.

Yes it seems that you guys recommend MongoDB Realm Sync, but our mobile application will be a social networking app, which won’t benefit very much from being able to use the app offline. The reason I was interested in using GraphQL is because we are intending to make both an iOS and Android app, and we could take advantage of GraphQL’s Custom Resolvers to only write the querying/modifications-related code in the Realm app instead of writing duplicate querying/modifications-related code in both the iOS and Android apps.

Your documentation doesn’t specifically mention this, but could we use a GraphQL client like Apollo iOS to communicate between our iOS app and the Realm app via GraphQL? Assuming it’s possible, is there any reason you’d recommend MongoDB Realm Sync over GraphQL for mobile apps, given that we don’t need to take advantage of Realm Sync’s offline mode?

Hi @Elias_Heffan, you should be able to use a framework such as Apollo to access Realm’s GraphQL API.

Note that you can also access MongoDB collections directly using Realm’s SDKs. Personally, I find using the MongoDB query language easier than working with GraphQL.

MongoDB Realm also includes Functions – you can use those to implement functionality in your back-end Realm app and then call them from your iOS and Android apps.

In terms of off-line access, I think users of a social networking app could still benefit by being able to continue to work with existing data when they lose their internet connection. But, you obviously understand your app better than me!

2 Likes