kxkannan
Hello,
We have a pretty mature GraphQL API that our front-end iOS app uses to communicate with the backend to authenticate, query and mutate. There is also another Python SDK layer that uses this GraphQL API.
Now we are planning to develop our Web app using Phoenix framework and the question is should we be using the same GraphQL API to interact with the server or make calls directly to the Module.functions (i.e User.login(email, password) instead of calling the login GraphQL api. I am leaning towards using the GraphQL api for all the query/mutations for the Webapp as I am worried about session management, cookies, caching etc that comes into play in a typical web app.
Are there any pros/cons to consider? What do people generally use?
Trending in Discussions
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
Hi everyone! I’m the developer of PaperForge, and I’ve been working on something alongside it that I’d like your opinion on.
I’m conside...
New
A remark @Garrison made…
..has already inspired a thread for the technical side of reclaiming our internet, but there is of course anot...
New
This is where the projects in the Hologram Showcase get posted: apps built with Hologram and libraries made for it. New ones go up usuall...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #elixirconf-eu
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mindok
We built the web application first and directly access modules, and use GraphQL to server to iOS so a slightly different scenario.
I would be personally be inclined to talk directly to the module functions and bypass a whole load of overhead of handling the GraphQL call, encoding the response, decoding the response, rebuilding structs for the web application to interact with - it will make coding harder and the system less performant to have all those extra, unnecessary layers in there.
Could you elaborate on your worries about session management, cookies, caching etc that you think using GraphQL will solve for?
kxkannan
Thanks for the response @mindok.
I am just generally asking about any issues we will run into with session management, cookies, caching etc. Have you guys ran into any of these issues?
If you decide to separate the web application code from your server-side code (for whatever reason - like running it on a separate server etc.) having this direct coupling would be bad and have to refactor to make api calls. That is not in our plan currently, but just thinking about it for the future.
mindok
No issues so far. We use Phoenix infrastructure with very little modification for cookies and session. We do have a custom plug to handle auth - there are plenty of examples around for that if you deviate from Phoenix gen auth. Passing session state (e.g. user identity) into liveviews is also well covered and documented now.
For caching, it depends on your use-case. We primarily use liveviews throughout our web application. State is held in the process backing the liveview which is great for long-running editing sessions. However, ours is a pretty specific use-case - a small number of power users that use the system all day every day. The templating engine in Phoenix is so ridiculously fast, the need for caching is a lot less than for other frameworks (there’s an article on IO Lists that explains why: https://bignerdranch.com/blog/elixir-and-io-lists-part-1-building-output-efficiently/). You have straightforward and direct access to the HTTP response headers, so if you need to manipulate http cache control, you can. There’s also the excellent cachex | Hex for keeping data in memory across requests & sessions.
Fair enough. However, you are likely to need to consider scaling a lot earlier if you create unnecessary system overhead
. The way we’re looking at it is to keep our team as tiny as possible for as long as possible while the business ramps up around the product. A well-structured monolith lets us do that. If we need to scale, we can run the main application on multiple servers / VMs and have them talk to each other using the baked in capabilities of Erlang and Phoenix. If, for whatever reason, we do need to separate API server from web server, we’d be wanting to be extremely well paid for it so will organise for one or more of the luminaries in the community to sort it out for us! But thinking about it, we’d probably look at compile-time settings to enable / disable the graphql routes or the web application routes and maintain the same codebase for both.
kxkannan
Thanks for your details response @mindok - really appreciate your feedback.
I am now able to call the module.function to get the login working. Since the liveview doesn’t have access to
connobject and only thesocket- what is the approach to store thecurrent_user(logged in user) in thesession? I see there are libraries likephoenix_live_sessions(PhoenixLiveSession — phoenix_live_session v0.1.3).Any suggestions would be helpful as I am trying to figure out the logged in sessions and how to keep track of it during page reloads and opening new browser tabs on the same browser etc.
mindok
Hi @kxkannan,
Transferring credentials from the conn to the socket is discussed in the LiveView docs here:
Security considerations — Phoenix LiveView v1.2.5.
There is a pretty decent explanation of how it all hangs together here: Securing Your Phoenix LiveView Apps | AppSignal Blog
Basically, the “session” parameter in the
mountcallback in your liveview should contain the credentials, and you transfer the credentials to the liveview socket there. However, rather than do this across all liveviews, you can define a hook shared across them. The wire-up to connect a specificon_mounthook to a group of liveviews is done in the router usinglive_session.