News for hackers. Stuff that matters.
Re:New React docs pretend SPAs don't exist anymore by BiteCode_dev on Friday March 17, 2023 @07:49PM (#35204465)
So after graphql, micro services, nosql and serverless, the SPA + "libs not framework" crowd join the "woooops!" club.

Ignoring the noise is really becoming a key skill to survive as a programmer.

Re:New React docs pretend SPAs don't exist anymore by jameshart on Friday March 17, 2023 @08:41PM (#35204808)
Being too eager to dismiss a technology and move on is just as much of a bandwagon-jump as being too eager to adopt it in the first place.

The Gartner Hype Cycle[1] has both a 'peak of inflated expectations' and a 'trough of disillusionment'.

The thing a lot of tech cynics fail to spot is that both of them are wrong about the long term value of the technology.

The 'plateau of productivity' awaits, where graphql, nosql, serverless, and SPAs will join every other technology, finding productive use in their appropriate niche.

[1] https://en.wikipedia.org/wiki/Gartner_hype_cycle

Re:New React docs pretend SPAs don't exist anymore by 6510 on Saturday March 18, 2023 @06:37AM (#35207876)
> The 'plateau of productivity' awaits, where graphql, nosql, serverless, and SPAs will join every other technology, finding productive use in their appropriate niche.

I keep thinking of the tower of babel.

> God was concerned that humans had blasphemed by building the tower to avoid a second flood so God brought into existence multiple languages. Thus, humans were divided into linguistic groups, unable to understand one another.

see? Now you can be wrong with the rest of us :)

Re:New React docs pretend SPAs don't exist anymore by datavirtue on Saturday March 18, 2023 @10:28AM (#35209407)
I have to agree. I ignored tailwindcss for far too long. Pry it from my cold dead fingers.
Re:New React docs pretend SPAs don't exist anymore by dmix on Friday March 17, 2023 @07:53PM (#35204484)
SPAs, microservices, nosql (Redis), and serverless are all still alive and well, they just aren’t a hammer for all problems like (some) people treated them originally. Nerds getting overexcited about new tech is an old story and it will continue to happen indefinitely as much as we like to smug post about it.

IDK about GraphQL since I’ve not used it but I’ve read lots of stuff recently about frameworks/ORMs working to better support this type of thing more directly/natively.

Re:New React docs pretend SPAs don't exist anymore by BiteCode_dev on Friday March 17, 2023 @07:55PM (#35204500)
That's exactly my point.
Re:New React docs pretend SPAs don't exist anymore by dmix on Friday March 17, 2023 @08:17PM (#35204637)
Your comment sounds a bit dismissive though. They all provide plenty value individually. A lot of this stuff needs to be used IRL for the community to understand the limits and there will always be junior devs and cowboys willing to risk it.

Plus not all of it is merely overexcitement/immaturity either, small companies and small dev teams often try to keep their toolsets small and eventually end up pigeonholing stuff into tech that doesn’t fit, until they get time/resources to do it properly. Some things are more obvious in retrospect.

The vast majority of the software world is still pretty conservative when you look beyond HN and Twitter.

Re:New React docs pretend SPAs don't exist anymore by simplotek on Saturday March 18, 2023 @01:30PM (#35211173)
> That's exactly my point.

In your own, exactly what point did you tried to make? Complaining that x and y technology users joined the "whoops" crowd when those technologies are in fact well established and proved to be effective if not nearly optimal in some applications, what do you perceive as "whoops"?

Frankly, it didn't seemed you had a point to make other than parroting cliches.

Re:New React docs pretend SPAs don't exist anymore by roflyear on Saturday March 18, 2023 @05:58PM (#35213499)
Graphql is only awful once you introduce abstractions. By itself it's really a great idea and works well.
Re:New React docs pretend SPAs don't exist anymore by alex_sf on Saturday March 18, 2023 @04:02AM (#35207143)
Honestly, the signal is just to avoid whatever full-time JS developers are getting into.
Re:New React docs pretend SPAs don't exist anymore by MartijnHols on Saturday March 18, 2023 @06:43AM (#35207907)
The signal is to avoid new technologies with marketing engines behind them for at least a few years. And anyone who is gullible enough to believe them, which are more likely the new people learning to code and yelling about the new shiny libraries they found than full time developers that are actually productive rather than bored.
Re:New React docs pretend SPAs don't exist anymore by datavirtue on Saturday March 18, 2023 @10:25AM (#35209379)
Winner!
Re:New React docs pretend SPAs don't exist anymore by mock-possum on Saturday March 18, 2023 @11:18AM (#35209765)
Get ready to have a lot of trouble finding work as a js dev if you’re not into whatever full time js devs are getting into.
Re:New React docs pretend SPAs don't exist anymore by alex_sf on Saturday March 18, 2023 @04:36PM (#35212858)
I'm totally fine with that.
Re:New React docs pretend SPAs don't exist anymore by eurasiantiger on Saturday March 18, 2023 @09:12AM (#35208826)
What are you on about? GraphQL is absolutely essential in enterprise systems.
Re:New React docs pretend SPAs don't exist anymore by roflyear on Saturday March 18, 2023 @05:59PM (#35213510)
In my experience it's the poorly implemented abstractions on top of your ORM of choice that make graphql a bad time. It itself is really a great way to do things imo
Re:New React docs pretend SPAs don't exist anymore by eurasiantiger on Saturday March 18, 2023 @07:59PM (#35214475)
Yes, exactly. The typical issue is devs not grokking the mental model of GraphQL and instead just creating more and more extra queries, essentially resolving data piece by piece in the frontend instead of leveraging GraphQL types and adding types, fields and field resolvers as needed so that the frontend can do one query to get all the data it needs.

No wonder it feels like a clunky extra glue layer if it’s being used as one.

Re:New React docs pretend SPAs don't exist anymore by claytongulick on Saturday March 18, 2023 @09:38PM (#35215102)
Some of us learned these lessons in the SOAP/WSDL/XML-RPC days, and learned to embrace the principles of REST to a avoid exactly those issues.

I looked at graphql and saw a return to the horror of DoSomethingBecauseItsMondayAndDueTomorrow() type API methods.

Hundreds or thousands of them that accumulate like cruft over time, and no one can delete anything because you have no idea what it'll break.

I stick with well designed and well planned REST APIs.

It's not a panacea, but it helps.

Re:New React docs pretend SPAs don't exist anymore by pjmlp on Sunday March 19, 2023 @05:53AM (#35217502)
Did we? Hello gRPC, Web sockets and language specific SDKs for REST APIs, as no one actually uses REST as designed.
Re:New React docs pretend SPAs don't exist anymore by roflyear on Sunday March 19, 2023 @10:33AM (#35219312)
> and no one can delete anything because you have no idea what it'll break.

This is a problem with GraphQL, but you can monitor if anyone is requesting that data.

Major benefit with GraphQL is you can ask for the data you need and just the data you need. So you don't have 30 different API endpoints that really return the same data, just smaller chucks. Or maybe you just need the IDs... etc.

GraphQL is also efficient here, not executing the code for the data you don't need - which is really useful.

It depends if you're in that situation or not, or what parts of your domain are in those situations.

I don't think "GraphQL everywhere" is sane.

Re:New React docs pretend SPAs don't exist anymore by claytongulick on Sunday March 19, 2023 @03:13PM (#35222418)
> Major benefit with GraphQL is you can ask for the data you need and just the data you need. So you don't have 30 different API endpoints that really return the same data, just smaller chucks. Or maybe you just need the IDs... etc.

Most sane REST-like implementations also support this, typically with query string modifiers like a "fields" param or similar.

A lot of them also support deep relationships this way too.

For example, the Directus REST API is completely feature compatible with the GraphQL API.

Re:New React docs pretend SPAs don't exist anymore by roflyear on Sunday March 19, 2023 @08:09PM (#35225311)
Well, yes, but not really. With GraphQL you can have one user:

- Request the users, their IDs, and emails, and their post ids

Or:

- Request the user, tons of profile information about them, and the posts with all the info about the posts

You'd have to implement all this filter stuff for REST - and at this point if you have a bunch of different queries, yeah GraphQL makes sense.

Re:New React docs pretend SPAs don't exist anymore by claytongulick on Monday March 20, 2023 @10:08AM (#35231707)
You should really check out modern REST APIs.

Again, as an example, Directus supports doing everything you just said over both REST and GraphQL.

There are many others that do too, and lots of libraries out there to make it easy to add that capability to your own endpoints in Node or.net or whatever.

You may also want to take a look at HATEOAS and JSON:API and similar.

REST-like APIs have long had feature parity with GraphQL and also superior mechanisms for caching etc...

Re:New React docs pretend SPAs don't exist anymore by roflyear on Monday March 20, 2023 @11:00AM (#35232481)
Yeah just seems like a different interface than GraphQL, but it's basically the same thing as GraphQL. So at this point, is it just "we don't like GraphQL" or something?

I don't see the reason to have to homebrew this for most things when GraphQL has a fairly sane standard.

GraphQL is still over HTTP. You can actually even just use the concepts in the backend (and maybe Directus does??) and hide it from the user, if you think they have some aversion to POSTing JSON for a query.

Re:New React docs pretend SPAs don't exist anymore by claytongulick on Monday March 20, 2023 @04:27PM (#35238151)
> is it just "we don't like GraphQL" or something?

Yes.

But not without reason.

GraphQL departs from web standards and semantics in order to solve a problem that doesn't really exist in most APIs.

You incur a cost in using it, some of which I've outlined but there are many others, such as working against the browser's native caching capabilities, e-tags, etc...

This cost would be worth paying if GraphQL brought new and valuable capabilities, but as I've discussed, it doesn't really do that.

With REST endpoints, you have to really reason about entities and URL structure to design it properly. It's not easy, but it shouldn't be - it's meant to be a long-lived API contract based on document location, so you should spend time reasoning about the design.

GraphQL, in my experience (much like SOAP/WSDL) encourages lazy API development with the GetWidgetsByColorForArthurOnSunday() type functions. It requires additional libraries and tooling and a whole additional layer of complexity. It works against long-standing native browser functionality, and in many cases is just a solution in search of a problem since for most popular API consumption there's a client-side library that abstracts away details like transport.

Also, I personally dislike it because I can't use my preferred data mutation strategy, JSON-PATCH [1].

[1] https://jsonpatch.com/

Re:New React docs pretend SPAs don't exist anymore by eurasiantiger on Tuesday March 21, 2023 @02:59AM (#35243248)
GraphQL enables entity-level caching. That is not possible in REST.
Re:New React docs pretend SPAs don't exist anymore by roflyear on Thursday March 23, 2023 @02:30PM (#35279220)
Oh, totally agree the best cases for GraphQL are like 10% or so of the usecases for APIs. I don't think you should use it everywhere.

I also think GraphQL should never be used for updating data, just that it is nice for a segment of problems related to querying data.

Re:New React docs pretend SPAs don't exist anymore by eurasiantiger on Monday March 20, 2023 @04:31AM (#35228728)
You looked at GraphQL and did not see the forest for the trees.

Use the @deprecated directive on your schema.

Re:New React docs pretend SPAs don't exist anymore by robertoandred on Saturday March 18, 2023 @07:11PM (#35214156)
I don’t think you understand what any of those terms mean.