DEV Community

Cover image for Automagically REST and GraphQL endpoints from your Azure SQL database
Davide Mauri for Microsoft Azure

Posted on


Automagically REST and GraphQL endpoints from your Azure SQL database

I'm pretty sure that at some point of your developer career you have wished - dreamed! - to have something that could turn your database tables exposed as a REST or GraphQL endpoint, automatically, just by expressing that intention (maybe via a configuration file or some other conventions).

Such a thing could make your life so much easier and your work more efficient for certain projects.

Well...dream no more, now there is a solution for that and it is free and open source!

And yes, for solution I really mean creating a GraphQL and REST endpoint starting from a database (maybe even from an existing table) without the need to write any code at all.

Curious? Well, I'm sure. So, if you want to go head down to the code and the details, you can just head to this GitHub repo:

GitHub logo Azure-Samples / azure-sql-db-rest-graphql-directus

A full end-to-end demo using Vue, Directus, REST, GraphQL and Azure SQL database to create a modern Todo list solution

where you can create a full-stack / Jamstack end-to-end solution, to store a To-Do list in an Azure SQL database, and present it via Vue.JS, communicating entirely via REST or JSON.

The sample implementation uses:

  • Azure Web App: to run the Directus container
  • Vue.Js as front-end client
  • Directus to provide GraphQL and REST endpoints automatically from the Azure SQL database
  • Azure SQL as database to store ToDo data

Directus is a Node application you can run in Azure using, for example, a container. Once it is running, you just have to configure which tables you want to expose via REST and GraphQL, configure the permission level (I'm quite sure you don't want to make all your table publicly available) and...nothing else, you're done. Of course, you can do much more, but if you don't need any additional complexity, this is really all you have to do.

You can go from a completely no-code/low-code approach to a more developer oriented one (as I did, for example, in the deployment script, where I also create sample To-Do items via the REST endpoint), so depending on where you are in our career or position, you can decide what is best for you. As a developer I'm just glad that I don't have to write any plubming code anymore (unless I really need to, in that case I may want to use Prisma or Dapper).

Aside from the aforementioned GitHub post, you can also learn more about Azure SQL and Directus via this nice blog post that we just published:

Enjoy! (I surely enjoyed it A LOT!)

Top comments (2)

jgy3183 profile image
John Youngman

this is great - but have a couple of questions:

  1. How can this install / deploy of Directus allow for Directus extensions to be built/installed
  2. If Directus comes out with an update to its "core", how would it get applied?