Dmitrii Profile picture
Sep 15, 2020 22 tweets 4 min read Read on X
A small unstructured mini-thread/mini-rant on GraphQL.

I’ve now completed server prototypes for roughly the same functionality in C#, Java, Go (twice), Elixir, and nodejs.

GraphQL exemplifies everything that’s wrong in the industry :D

1/
First, it’s supposed to bring together data from different sources, right?

All GraphQL libraries have no proper examples of that. “Let’s create an array of values and serve that”. No one ever does that in real life.

As a result in reality everything is double the code 2/
Why? Because you get your data from an external service. And usually you present this data in an only slightly different way in GraphQL.

External service may provide a client with a contract id, but you present a client with a full contract from another external service 3/
Oh, screw you. Create a separate model/entity to deserialize the external service’s data, then write a separate model/entity in your GraphQL schema. And often run a generator on that schema to create a *third* model/entity just because.

4/
It’s both significantly worse and significantly better if you don’t go schema first, but define your schema in code. This can be anything from Java’s bearable fluent interface to go-graphql’s horror show.

5/
In schema-first though it often happens that if you need some custom resolver on a single field, nope, you have to write your own model/entity by hand, and probide resolvers on that. Because screw you.

Looking at you gqlgen

6/
You’d think code-first would work. I mean, whatevr you write in code is what you want/need, right?

Wrong.

Enter Elixir’s Absinthe. Schema fields are defined in snake_case. Gets automatically converted to camelCase when requested through GraphQL.

WHY?!

It gets worse 7/
This only happens with data that Absinthe itself sends. But… you get that data from external sources, and those will often have field names in camelCase.

You have to… transform those field names manually to snake_case before providing it to Absinthe.

Because screw you 8/
Goddamn dates.

Everyone needs to work with dates and timestamps. Why the *fuck* GraphQL (and protobuf) don’t have Date, DateTime, Time and Timestamp in their specs?

Becuase their authors have never been in the real world it seems. As a result every single library ends up … 9/
… you though I’d say “implementing those as custom GraphQL scalars”. Oh, sweet summer child.

Some will onlly have DateTime. Some, like Apollo, will have two pages of explanations and code examples but *not* include it in the lib by default. 10/
Some will have them as external libraries that need to be injected and will screw up things like JSON (de)serialzation. Looking at you, graphql-java-extended-scalars. 11/
Some don't implement Date, DateTime etc. “because it’s not in the graphql spec”.

Spec is bad, you exist not to please the spec, but to help people make things. *People*. 12/
Schemas.

Code-first crowd is notorious for not being able to generate the final schema. You need some external tools that will connect to the running server, introspect the schema, and generate the schema based on that.

I literally can’t even

13/
Dataloading.

Some libs think that dataloading is for others to implement. Perhaps. Is there a better way to hook up a dataloader than providing an untyped context object, and then returning a function calling function wrappers from that object in your resolve function?

14/
The whole idea that resolvers should be able to call external services (that’s why they are there to begin with!) is almost a foreign concept in a surprising number of libs.

You can always go the Java route and inject everything everywhere, including your eyeballs. 15/
Many of these issues stem from language and conventions: Java must have beans, and registries, and dependency injection, and config objects, and profiles, and…

Go’s lack of generics leads to 1500 interfaces that are the same thing. Or casting unnamed interfaces to things 16/
Apollo is only marginally better than the rest of the crowd just because JS doesn’t care what objects you through at it.

But yeah, it will not provide useful scalars out of the box because you, the programmer, are meant to suffer

17/
Errors. Oh god, I forgot errors.

Helpful messages are for losers. Figure out “Can’t query field id on type X” yourself, you child.

Stacktraces are for losers. None will be included in the error messages, in any lib IIRC. When something fails, who cares where it fails 18/
Some will gladly dump HTML at you when you accidentally retrieve a 404 page in an external service. Others will “JSON decode error: invalid symbol p at 1:30” at you.

No other messages. It’s your job to write perfect resolvers on the first try, you incompetent turd

19/
I still think GraphQL is bad for external APIs for various reason, to lenghy to list here.

But for the backoffice and exploratory APIs it could be a very nice tool. Especially since backoffice is the one place that has to deal with backend APIs in the frontend

20/
But Christ Almighty, is it ever so painful to write a backend server that prvodes a GraphQL wrapper for your backend APIs in a straghtforward concise manner that doesn’t make your eyes bleed and doesn’t take you on an accelerated path to clinical depression.

21/21
@threadreaderapp unroll, please

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Dmitrii

Dmitrii Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @dmitriid

Mar 21
A short thread on Googlers congratulating themselves an patting themselves on the back, a thread.

@sarah_edo Director of Eng Web iOS etc. announced that Angular is merging with Google's internal framework called wiz:

1/
Image
In the thread she made the following claims: that wiz powers Search, Workplace and Youtube and that the merge will bring impressive improvements to Angular's performance due to wiz:

innovative

2/




Image
Image
Image
Make no mistake, the amazing performance of Youtube looks like this:

3 seconds to render an empty page. 11 MB of JS, 2.5 MB of CSS, Lighthouse screams at every Youtube embed and suggests you use third-party embed scripts etc.

Keep this in mind as you read about this
3/


Image
Image
Image
Image
Read 13 tweets
Oct 26, 2023
Web Components are *not* using the platform. It's easy to show. They keep changing the rules of what "the platform" means, but they are still not using it, unlike literally everyone else.

Ironic because they are in a very literal sense a part of the platform themselves

1/7
Web Components: The only tech that struggled to create form components that would be seen by the browser and sent as a part of the payload.

Had they used the platform, this would be a non-issue. So they changed the rules:

2/7web.dev/articles/more-…
This didn't help much. In 2023 there's still an open issue that a web component cannot be a submit button:

Had they used the platform, like everyone else, this would be a non-issue.

They are changing the rules on this, again:

3/7github.com/WICG/webcompon…
developer.mozilla.org/en-US/docs/Web…
Read 7 tweets
Feb 17, 2022
@lil_htlr @kleschby Я не то, чтобы спец, у меня по этому поводу strong opinions :D

Итак.

*Концепция* веб-компонентов такова: зачем плодить еще больше все больше новых фреймворков, которые, по сути, создают одни и те же компоненты? Можно часть необходимого функционала впилить в браузер. 1/
@lil_htlr @kleschby Тогда если кто-то создаст, например, date picker или там menu, которые все нравятся, то их можно будет использовать напрямую, не подтягивая сторонние фреймворки.

То есть ты создаешь «черную коробочку» из JS и CSS, и используешь, как хочешь, не боясь, что она поломается 2/
@lil_htlr @kleschby Дополнительной концепцией было «userland сможет быстро проводить итерации над требуемыми вещами, стандартизировать их, а потом их можно будет постепенно втягивать в браузер», а так же «можно будет стандартным способом расширять встроенные компоненты типа select'ов и input'ов», 3/
Read 20 tweets
Nov 8, 2021
A story of

- a design change for the sake of a design change
- by people who couldn't care less
- by people who clearly never use the app they change

featuring @AmazonKindle @KindleHelp

1/
Imagine, when all you have is a 27" 5K screen where you make these mockups. Who cares to look at them on an a real screen? No one.

Most changes to Kindle are done by "designers" who have never seen a world outside their infinitely zoomable mockups

2/
They removed the list view.

So, instead of easily readable book names you now have to remember what a book's cover is and/or try to decipher the name fro the grid of images.

3/ A screenshot of the Kindle app that shows a grid of book cov
Read 11 tweets
Aug 7, 2021
Let's talk about the Web, UIs and layout.

I often hear: well, it's an amazing layout system. If there's anything lacking, show me anything that works under the same constraints: having to work with multiple screen sizes and adapt to them seamlessly.

Well, a thread🧵

1/
Let's start with this: the whole idea of "we have a web-site, and it can display itself differently in a desktop browser and in a mobile browser" is literally nothing but an extension of CSS Zen garden: csszengarden.com

The idea is as old as CSS itself:

2/
You have a website, and just by changing CSS you can make it look and feel completely differently. Here's CSS Zen Garden with various CSS applied.

It works as well as you'd expect: some manage to do it very well. Some manage to do it poorly. And some don't manage at all

3/ CSS Zen Garden with a subdu...CSS Zen Garden with a stark...CSS Zen Garden with contras...
Read 15 tweets
Oct 12, 2019
If you follow @troyhunt and @lukew you know how bad things are around passwords, password forms, and password requirements. At the same time you're thinking: "it can't be *that* bad, can it?"

Oh, boy. A thread with nine examples

1/12
My laptop was stolen. So I decided to go through ~300 accounts stored in my 1password looking for weak passwords, 10-year old passwords etc. And updating them.

I updated ~50 accounts. Too bad I was busy changing passwords and not taking screenshots. Here's what I found:

2/12
- If you use a password manager, you will have to copy paste the new generated password into the "New password/Reset password form".

Pasting text will not trigger form validation. You have to at least delete and re-type a character. The most common problem.

3/12
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(