News for hackers. Stuff that matters.
Re:Why not use GraphQL? by sysashi on Saturday November 07, 2020 @10:02AM (#25015424)
sorry for stupid question, how REST and database indexes are related?
Re:Why not use GraphQL? by cs-szazz on Saturday November 07, 2020 @10:17AM (#25015520)
They're not really related here. The premise of my question is more around the fact that with REST, which database queries you'll run are fairly static and are known by the backend based on what APIs they expose. Therefore it's easy (ish) to make sure said queries are indexed properly.

With GraphQL, I'm asking about how clients _could_ write arbitrary requests, that since the backend doesn't know about them ahead of time, can't optimize for with indexes.

Re:Why not use GraphQL? by sysashi on Saturday November 07, 2020 @03:02PM (#25018576)
That makes sense, thanks!
Re:Why not use GraphQL? by diveanon on Saturday November 07, 2020 @10:06AM (#25015446)
They aren't.

There is just a lot of anti-patterns floating around because of tightly coupled API / DB's.

People apply this same logic to GQL and get confused.

Re:Why not use GraphQL? by cratermoon on Saturday November 07, 2020 @12:41PM (#25016683)
> People apply this same logic to GQL

And programmers will apply this same anti-pattern to GQL, so it doesn't really solve that problem, and arguably makes it worse for the reasons stated in the un-indexed field example.

Re:Why not use GraphQL? by diveanon on Saturday November 07, 2020 @01:33PM (#25017219)
And that is why you used gql codegen and typing to limit their capability to do so.

Part of the benefit of gql that people often overlook is its self documenting nature and when tied with automation tools its ability to provide a lot of flexibility for developers without compromising you db.

The gql server is ultimately what is responsible for this, and we use schema introspection to ensure the searchable / sortable fields are only exposed if indexed.

Re:Why not use GraphQL? by cratermoon on Saturday November 07, 2020 @03:16PM (#25018773)
Should I go back into my archives and look over the number of technologies leaning on code generation and model introspection that failed to catch on?