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

crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
100phlecs
Are there any downsides, like perf issues, to putting all functional components in CoreComponents as long as you prefix it with the conte...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
griffinbyatt
Sobelow Sobelow is a security-focused static analysis tool for the Phoenix framework. For security researchers, it is a useful tool for g...
New
MarioFlach
Hello, I want to share a project I’ve been working on for a while: https://github.com/almightycouch/gitgud Background Some time ago I ...
New
kostonstyle
Hi all How can I compare haskell with elixir, included tools, webservices, ect. Thanks
New

Other popular topics Top

New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
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
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement