We know that FaunaDB supports both FQL and GraphQL as query languages.
What are the pros and cons of each?
When do I (or why would I) choose one over the other?
We know that FaunaDB supports both FQL and GraphQL as query languages.
What are the pros and cons of each?
When do I (or why would I) choose one over the other?
The initial choice between GraphQL and FQL is based on what you already know and what you want to learn. The initial language for FaunaDB is the Fauna Query Language (FQL). This means that language can be used for all the FaunaDB functionality.
In GraphQL can do a lot of things already, a lot of people are able to do most they need (or everything) with their autogenerated GraphQL API and some add some functionality (such as authentication) via custom resolvers that are implemented in User Defined Functions (written in FQL). GraphQL is great and will get you far, but at a certain point you will probably want to learn some basic FQL as well. In essence, itās not an OR but can be an AND story.
In the long run, our GraphQL layer will offer many features but will probably (I might be wrong) never be as powerful as FQL is because the goals of the language are entirely different (weāll get to that).
Most people choose GraphQL because itās a familiar language, they already know it, they like the easy syntax and itās easy to get started. That said, GraphQL is more a query language while FQL is a more like a programming language. In GraphQL, you declare what you want to retrieve and FaunaDB decides for you how it will retrieve these things (creates indexes, generates the query). In FQL you declare exactly how you want to retrieve it. The difference between what and how is the difference between a declarative language (define what you need) and a procedural (define how) language. SQL, GraphQL, etc are rather declarative, FQL is differentā¦ itās procedural. There are reasons why FQL is procedural and those reasons are interesting to know before we go further.
The tradeoffs with GraphQL:
I would also like to emphasize that it isnāt a matter of either/or, and most people are using both to some extent. FQL is unique in being a functional database query language, with all of the benefits Brecht described above, so you will inevitably find, as your app evolves, that you want to take advantage of that. And itās not that hard to use once it āclicksā