Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is GraphQL an ORM?

Tags:

Is GraphQL an ORM? It seems like it is. At the end of the day it needs to query the database for information. You need to give it a schema (just like an ORM). From my understanding, on the front end you pass it the specifics that you want and GraphQL on the back end will give you just the info you requested.

The only difference I see from traditional ORMs, such as Sequelize or ActiveRecord, is that GraphQL will give you only what you want, making it very attractive and flexible. I suspect though that whatever's going on under the hood may leave you with some inefficient queries (common to ORMs). So is GraphQL simply an ORM that gives you 100% flexibility in what you ask for and receive?

like image 788
The Qodesmith Avatar asked Sep 18 '17 13:09

The Qodesmith


People also ask

What type of database is GraphQL?

Due to its growing popularity with accessing data, GraphQL is often confused with being a database technology, but it is NOT one. In fact, it is a query language for APIs that isn't tied to a specific database or storage engine, and it doesn't require you to even run a Graph database.

How is GraphQL different from REST?

GraphQL is an application layer server-side technology that is used for executing queries with existing data while REST is a software architectural style that defines a set of constraints for creating Web services. GraphQL can be organized in terms of a schema whereas REST can be arranged in terms of endpoints.

Is GraphQL a framework or library?

It's a highly general-purpose framework for application development. While this means that while it's more a jack of all trades solution than anything else, it also has much higher compatibility than most anything in the GraphQL world.

Is GraphQL a front end or backend?

Is GraphQL frontend or backend? GraphQL is neither the frontend or backend but rather the language spoken between the two to exchange information.


2 Answers

GraphQL is not an ORM, because it doesn't understand the concept of DBs. It just gets the data from a "data source", which could be static, from a file, etc. Nor can it figure out how to get data once you point the source at it. You have to write resolver functions that tell the DB how to find the value of each field.

Some gems/packages will simplify some of this. Some of those may be or may become ORMs, but GraphQL itself is completely platform/data source agnostic.

like image 133
Dan Friedman Avatar answered Sep 29 '22 18:09

Dan Friedman


No it's not. With only GraphQL, we can't access the database easily, because the language needed to send query isn't mapped by an ORM.

ORM makes it easy to access a database, which is in a sense is more like creating a virtual database which our programming language can easily access. Then GraphQL send its query into that virtual database.

like image 24
Alrafik Avatar answered Sep 29 '22 17:09

Alrafik