kamranhossain

kamranhossain

Best practices to build APIs for mobile apps

For mobile apps in Elixir, Phoenix apps what is the best practice?
Using GraphQL API with Absinthe and consume it with the mobile frontend?
Using a simple REST API and consume it with a mobile frontend?
How LiveView fit in the whole picture?

Most Liked

Eiji

Eiji

I’m not mobile developer, but I can say one thing … Many companies due to reduce costs does not optimized apps and games well and COVID-19-related problems shows us that such approach is gonna fail sooner or faster. Depends on country problems with for example overloaded networks are still noticeable.

Therefore if I would be able to choose simple REST API or GraphQL API (or similar solution) I would not need any time to think about it. Anyway still every solution is best in its own use case. The only thing I can suggest you is to choose wisely based on your project and consumer needs.

Personally I don’t like putting web-based solutions when talking about native apps. I would use LiveView only for browsers. I’m not an expert in security, but generally I’m against embedding web app in browser and delivering it like a normal app. Not sure how it works on mobile devices, but let’s even assume that such browser would be delivered by Android … If so what’s with updates?

When LiveView is a web-app (not Android app) you do not need to worry what browser is using user. However when you depend on browser or WebView (wekbit?) you are responsible for updating your dependencies. Now keep in mind that many mobile users does not updates apps often unless they are forced to do so. Therefore in my opinion web-based solutions in Android app does not makes sense. Obviously same happens even for LiveView as such dependency (client JS part) also needs to be updated (for example last time we got awesome uploads support).

outlog

outlog

I use react native - connect it to a phoenix channel and send all stuff over the channel, you can easily send graphql over the channel if that’s your thing - then you get a thin/small channel(very little code).. I just use normal msgs over the channel, so mine is kinda “thick”/a lot of code in channel..

Matsa59

Matsa59

Also it depends of your needs. Do you need real-time app using rest api? Phoenix will be the best choice IMO.

You prefer use GraphQL? You don’t need Phoenix at all (you’ll not use channel, live view …). For real-time app, you can simply use Absinthe subscription (just follow the absinthe QuickStart with plug).

For the main question :

  • GraphQL offer something really interesting for mobile : selecting data that you need easily (reduce network packet size for example).

  • Rest allow to create and update things easily. You don’t have to create your « input_object » that can be really painful sometime. (Imagine object A that use B; B use C etc). In rest you just work directly with the data.

Where Next?

Popular in Discussions Top

sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19652 166
New
ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18243 126
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement