I’m working on a React Native mobile app that needs offline functionality. I want to integrate Realm for local data storage so users can work without internet and sync when they come back online.
My current setup includes a web application built with NextJS that connects to an Apollo GraphQL server running on AWS Lambda. The backend uses MongoDB with Mongoose for data management.
I’m new to Realm and wondering if I can connect it to my existing GraphQL endpoint. Here are my main concerns:
What are the potential issues with this setup?
Should I consider switching to Realm’s cloud database instead?
How do the costs compare between these options?
Most tutorials I find only show basic Realm and Apollo Client integration examples.
Built something similar last year for a logistics app and ran into a few challenges you should be aware of. The biggest issue tends to be conflict resolution when multiple users edit the same data offline. You’ll need to implement custom merge strategies since Realm’s automatic syncing may not align smoothly with your current GraphQL setup. Regarding costs, it’s advisable to stick with MongoDB if you already have a substantial amount of data and well-defined schemas. Transitioning to Realm’s cloud would require rebuilding your backend and could lead to increased storage costs during the transition. In my case, I used Realm solely for local caching while relying on GraphQL for server-side operations. This required creating manual synchronization logic, which provided us more control over the data flow, although it did add complexity in managing consistency between local and remote data. Your Apollo setup can definitely work, but be prepared to implement custom resolvers to effectively map Realm data to GraphQL.
realm + graphql works fine, but the constant data transformation between realm objects and graphql responses will kill ur performance. I’d go with watermelonDB instead - it’s made for react native offline apps and integrates way better with existing backends. plus, keeping your current setup is def cheaper than moving everything to realm cloud.
I built something similar for a project management app. Using Realm as just a local cache with GraphQL backends works really well. Treat Realm as your offline storage and keep your existing GraphQL API for server stuff. You’ll need a sync service to handle data flowing both ways between Realm and Apollo server. What worked for me was a sync queue that stores pending mutations when you’re offline, then processes them one by one when you’re back online. The biggest pain is schema changes - Realm needs migration scripts every time your data structure changes, which is way more work than MongoDB’s flexibility. But performance actually got better since data reads happen locally from Realm. Stick with your current MongoDB setup unless you’re doing major architecture changes. Realm Cloud gets expensive fast with bigger datasets and multiple environments.