DEV Community

Discussion on: Unit testing frontend code is (probably) useless

Collapse
 
brense profile image
Rense Bakker

GraphQL is a query language. It offers tools to facilitate this, but the implementation of your data model is still something you have to do yourself... How you implement the data model is up to you. There are a lot of good libraries that make it easier. A lot of people do role based authorization, but there are other options too.

Thread Thread
 
polterguy profile image
Thomas Hansen • Edited

Are you going to teach me RBAC and normalisation now too ...?

Seriously, if you're, and I paraphrase you now; "exclusively building business model in your frontend, while reducing the server down to authentication, authorisation and data storage" we have a serious problem. Or to be specific, your employer have a serious problem. To illustrate that, let me ask you a question; "How do you send emails from your frontend?"

I could mention a bajillion things not even possible to implement as business logic in the frontend, without opening up your server as a gaping security hole for all sorts of problems - But the above should get you started ...

However, my reasons for mentioning GraphQL was because of that GraphQL often tend to lead to such things as you are explaining, where all BL is on client, resulting in that your app is ipso facto one large security hole ...

Thread Thread
 
brense profile image
Rense Bakker

I never said all business logic should be in the client. The data model is also business logic, I specifically said to define the data model on the server... Also yes, there are definitely ways to send emails from the FE, not saying you should always opt to go that route, but its certainly possible... Serverless is a thing in 2022.

Thread Thread
 
polterguy profile image
Thomas Hansen • Edited

Serverless has about as much to do with frontend/backend business logic as CosmosDB has to do with SQL. Serverless is a method to create HTTP Web API methods (mostly, ignoring timer functions of course) that is (often) implemented as Kubernetes PODs, dynamically orchestrated on a "per needs basis" - I should know, we've basically implemented our ENTIRE COMPANY around the axiom ... :/

In fact, you can even have a "serverless application" without even having a frontend ...

However, you CANNOT get away from having "a server", the point about "your server" though is that it's not a statically scheduled server that is "only yours", it's a technology typically built upon Kubernetes allowing your cloud provider to orchestrate and schedule execution on a "per need" basis, using stuff such as K8s replicas, sleeping containers, etc ...

If you believe that "serverless" is about "not having backends, but putting all your business logic in the frontend" I would recommend you read up on the subject ...

Thread Thread
 
brense profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
Rense Bakker

Stop changing the subject. What you asked was this: "How do you send emails from your frontend?", answer: serverless functions are a thing and serverless functions can send emails, also plenty of cloud solutions out there: mailersend.com/features/smtp-relay So yes... thats how you can send emails from your frontend without having to maintain a server. Not saying thats what you should do, but thats the answer to your nonsense argument that you cant do business logic in the frontend.

Also... Wow! You're an arrogant asshole :B

Thread Thread
 
polterguy profile image
Thomas Hansen

serverless functions are a thing and serverless functions can send emails

Serverless functions are backend code! You're the one who's changing the subject ...

Check up Azure Functions or Lambda Functions with AWS before you make a fool out of yourself here ...

Thread Thread
 
brense profile image
Rense Bakker

I never told anyone not to write backend code. I said most business logic resides in the frontend nowadays and that backends are typically only used to define a data model and do authentication.

We have a real problem here though:

A: According to you, emails have something to do with business logic? Or why else did you bring it up?

B: Serverless functions have nothing to do with business logic (your words)

C: Fact: you can send emails with serverless functions

A, B and C can't all be true... So what's it gonna be? Either A or B has to be false since C is a fact. Or are you one of those people who believe in alternative facts and you're just going to ignore the fact that you can send emails with serverless functions?

Also, there's a lot of other ways to deploy serverless functions besides Azure or AWS.

Thread Thread
 
polterguy profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
Thomas Hansen • Edited

I said most business logic resides in the frontend nowadays and that backends are typically only used to define a data model and do authentication

I am really quite honestly speechless, and I'm not really sure what to say anymore to be honest with you. I suggest we both stop commenting before you apply permanent damage to your ego, to the point where you can no longer recover, and are forced into defending a poisonous position for the rest of your life as a consequence ... :/

Just my two cents here really. If you want the last comment though, go ahead, I will not answer you anymore, it's really futile the way I see it at this point ... :/

Edit - However, with that position you'd love Magic since it does all of the above 100% automagically (data model + authentication). Personally, I would never encourage anyone to write BL in frontend, but what do I know ... :/