The discussion here is frustrating because people are assuming that you'd pass the SQL directly to your database backend and expose your entire schema and all your data. SQL is just a query language, just like GraphQL, and is no less 'secure'. You can still have a layer between the front end and application database. A practical way to use SQL would be to expose the subset of data that is visible to the user and allo…
Don’t we all just want to use SQL on the front end?
171–180 of 184 posts
Re: Don’t we all just want to use SQL on the front end?
#172Unpopular opinion: I'd like to have no code or as little code as possible on the frontend (think a tiny library - or a minimal browser) and define application flow / logic on the backend. I don't want to have SQL on the frontend, I want to have no-frontend. I'm not advocating to the good old days of backend + HTML and full page refresh, a small layer which smartly dynamically load different pages / submit requests wo…
Re: Don’t we all just want to use SQL on the front end?
#173New FE devs that come in now have a 6 month period where they must learn a new proprietary tech just so that we can circumvent what's already there, I would say that it's not a great idea if you have to work with other FE devs (who are not Full-stack) and if your app is of a significant size (YMMV I guess, we've had our own issues with GraphQL too).
Re: Don’t we all just want to use SQL on the front end?
#174I think we've all wondered this at some point in our careers. It's something you should never do. Off the top of my head: 1) Security (as has been beaten to death here) 2) Interface versioning. If you expose a generalized SQL interface to your consumers directly, good luck ever making a change to your database schema. You'll have no idea whose workflows you break. This high coupling becomes very painful very fast. 3)…
Totally valid points. I think this can be solved by a change of layout. If you do use sql queries in the frontend but have a layer between your front and your database to map which queries are valid and how to map your queries to your own DB representation. You solve a big chunk of your problems that way.
Re: Don’t we all just want to use SQL on the front end?
#175* Every user in the web interface gets a sql database user.
* A change in the database schema should reflect an instant change in the AP GUI.
A dream that I have worked towards step by step in a few different projects. I am not sure about how it scales to millions of users. But if you have a a few 100 to a thousand users. It should be fine. Main problem i have found is row level security. The app should basically just be a graphical interface that can be configured. Through a config file.
Re: Don’t we all just want to use SQL on the front end?
#176It solves the security issue by making you define the query first in Seamless, and then you get a REST API endpoint to run that query, with optional parameters that are run in a prepared statement.
Query (in the Seamless backend)
> SELECT * FROM posts WHERE author_id = ${author_id} LIMIT 50
And corresponding REST endpoint for that:
> GET https://primary.dbapi.seamless.cloud/somecompany/queries/run...
I dogfooded it while writing the serverless backend for BudgetSheet, and in practice I got tired of having to pre-define each query up front in the app before I could run it from the app. It was kinda painful to switch back and forth vs. just having the queries in the codebase. So... I have definitely been thinking a lot more about how to move the SQL to the client, but in a secure way (perhaps in cobination with the Seamless app that only allows "verified" queries to run in production, etc.) There is definitely some room here for a little innovation.
Re: Don’t we all just want to use SQL on the front end?
#177Also not SQL, IndexedDB [0] Seems like a well-supported [1] document database built into the browser would beat LocalStorage in almost every way. That's what I've found in my experience at least.
Maybe SQL just isn't the right tool on either the frontend or the backend?
[0] https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A... [1] https://caniuse.com/indexeddb
Re: Don’t we all just want to use SQL on the front end?
#178[0] https://lambdaforge.io/2021/03/03/datahike-clojurescript.htm... [1] https://github.com/metasoarous/datsync
Re: Don’t we all just want to use SQL on the front end?
#179The discussion here is frustrating because people are assuming that you'd pass the SQL directly to your database backend and expose your entire schema and all your data. SQL is just a query language, just like GraphQL, and is no less 'secure'. You can still have a layer between the front end and application database. A practical way to use SQL would be to expose the subset of data that is visible to the user and allo…
Re: Don’t we all just want to use SQL on the front end?
#180Not SQL, but https://pouchdb.com/ looks like a better version of this. Also not SQL, IndexedDB [0] Seems like a well-supported [1] document database built into the browser would beat LocalStorage in almost every way. That's what I've found in my experience at least. Maybe SQL just isn't the right tool on either the frontend or the backend? [0] https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A ... [1] https…
If you build it upon SQL, you would also need to create a CRDT schema to make replication sound. That's probably more work than just using REST/GraphQL/RPC.
Local data is king. Especially as the network connection degrades.