DEV Community

What is GraphQL - the misconceptions.

Shruti Kapoor on January 07, 2020

I love talking about GraphQL, especially with people who have been working with GraphQL or thinking of adopting GraphQL. One common question peop...
Collapse
 
namsfromharlem profile image
Namkell • Edited

I’m confused with graphQL.... can u use it as a database... or does it filter database queries?
I am self taught...

Collapse
 
genspirit profile image
Genspirit

It's an API specification which means in an interface that goes between a data source and a client to allow you and other developers to access it. It has a singular endpoint(url) that you send requests to, using GraphQL specific syntax. The GraphQL spec defines how that endpoint should interpret your request and ultimately resolve it(return data, or accomplish the requested task). Query requests will return information and Mutation requests will typically either change/create/update/delete information.

The other great benefit is that if you have multiple varying data sources you can use GraphQL to easily unify them under a singular endpoint. You just have to write the resolvers and connect them to the correct data sources.

Collapse
 
koresar profile image
Vasyl Boroviak • Edited

Hi mate.
Ask yourself, can you use HTML as a database?
Answer is no. Simply because it's a programming language.

Typically, a website or an app would send a GraphQL query to the server. The sever would see your query and would read the requested data from its database. And would return the data back to the website/app.

Collapse
 
paulcosma97 profile image
Paul Cosma

Html is not a programming language though

Collapse
 
paulcosma97 profile image
Paul Cosma

I don't see how using one endpoint for all your requests is a plus. Of course it's more convenient for the frontend Dev because they don't have to remember all the endpoints but this convenience comes with performance issues like:

  • the server has to parse the query every time. This is not an issue in rest because for GET requests you only pass the URL
  • imagine having multiple microservices. A proxy would have to parse the query, find a suitable microservice and that service would have to parse it again. By using REST you could simply parse the URL in the proxy and ignore the body
Collapse
 
barucalmaguer profile image
Baruc

Another benefit of graphql is having to perform a single server call, with REST you probably would make a lot of calls to the different endpoints.
It's costs way more to make a request to a server far away (tens of ms) than to parse a request (< 1 ms)

Collapse
 
toddrobinson profile image
Todd Robinson

Great post, thank you for sharing. I'm a little confused about the myth "GraphQL is a database language like SQL." SQL is also a programming language, and more specifically a query language that is defined by a spec with many implementations of it. Is the distinction for this myth that GraphQL can be used on the frontend?

Collapse
 
nasun4o profile image
Atanas

Hello friends.
I'm going to implement a Graphql API with NodeJS (for GraphQL server will use graphql-yoga or appolo), but my Database it will be MSSQL, could you suggest my any ORM, because Prisma support only Postgre and MySQL. I've seen Knex which support most of the DB's but is there any better than it?\
Kind Regards

Collapse
 
igorpae profile image
igorPae

Hi, I'm used Hasura GraphQL API that wraps Postgres database, it's good example of how you can use GraphQL with SQL database, easy to use, ready for work in a short time

Collapse
 
jacobherrington profile image
Jacob Herrington (he/him)

Thanks for sharing! Hopefully this clarifies some misconceptions about GraphQL for those debating adoption.