What is the difference between GraphQL and mongoose?

What is the difference between GraphQL and mongoose?


-2

I am reading a book about GraphQL, and they claim that one strong point of GraphQL is selecting a field from the database. See sample below:

What is the difference between GraphQL and mongoose?

On this image, they selected just the title from the movies on the database. I can do the same using mongoose, using "select".

Could I say that mongoose is already GraphQL?

3 Answers
3


2

One is a query language that can be resolved by reaching into databases and gathering data, the other is a friendly wrapper that helps you interact with MongoDB, a NoSQL database.

You cannot say that it is already GQL because it does not deal in GraphQL language, it deals in JS queries. They are different languages with different syntaxes.

You might write a resolver for a GraphQL query using Mongoose, but they are still 2 separate things.

0


2

After I have asked the question, I gave some thoughts on the matter, indeed, as said zero298, they are two different things. Here, they build a app using both technologies, and justify the reasons it is better.
An excerpt from the aforementioned article:
"GraphQL is a technology that helps developers across the board to build more robust software more quickly. The ability to request all of the information you need in a single request is a game-changer. It has simplified my backend development of APIs for consumption by mobile and web applications that would normally rely on RESTful APIs. A normal RESTful API may have several endpoints for various entities (e.g. users, submissions, etc.); with GraphQL, you can get all of this information in a single go using GraphQL’s query language, also known as GQL."
I adding this extra answer as so if somebody falls into the same trap, they can easily get out!

Related question:

Do I need mongoose with graphql?

GraphQL with mongoose


-1

Mongoose schema define the structure for data storage from server to DB.
Graphql schema defines the queries and mutations as required by the front end and delivers the result from server to client

New contributor

user22761458 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



Leave a Reply

Your email address will not be published. Required fields are marked *