Elektrine lite

← Feed

@appliedgo@c.im

2024-01-01 22:02 UTC

Exposing SQL via API? A strange idea... Think twice. Some scenarios require more than just a simple CRUD API but are not complicated enough to require the full power of GraphQL. Why shouldn't the API clients be able to express their query needs in SQL? Well, security for one. SQL injections, anyone? But we don't need full SQL. The WHERE clause is sufficient. And of the WHERE clause, only the parts that the current query absolutely needs. Like: "weight between 10 and 20", or "material = 'carbon'". A simple query validator can filter the incoming queries and let only valid ones pass. Valentin Willscher came up with this smart idea. In a blog article, he describes the details using Scala. I found the idea so intriguing that I re-wrote the validator in Go. https://appliedgo.net/sqlasapi/?utm_source=mastodon #golang #sql #api

Replies (0)

No replies.