Can I use GraphQL for mongoDB or mySQL?


I have started learning GraphQL and found that GraphQL is an awesome query language.
However I wonder if I can use GraphQL for existing databases such as mongoDB or mySQL.

Also please explain about prisma.
Is prisma a cloud database or something?


GraphQL can be used with any database as long as the data satisfies the type-strict qualification. Prisma is a node.js/typescript ORM library and works great with GraphQL.

Looking back to this a bit old question, I noticed that the question was so dumb and a bit too wide. So I’ve decided to add some more thoughts as I’m now quite familiar with GraphQL and Prisma. Hope this could be a help for new developers who are starting to learn GraphQL and Prisma.

GraphQL is a query language that we can use to interact with the API.
Like the REST API, GraphQL is another type of API format where we can use Queries to get data and Mutations to update data.
As the REST API doesn’t depend on the database type, GraphQL can also be used with any database as long as the data can be formatted into type-strict models.

On the backend side tho, you need to implement the GraphQL interface that reads data from the database and sends as the Query response, and updates the database with the data from the Mutation.

Prisma on the other hand is a node.js/typescript ORM library – similar to mongoose or sequelize. The benefits of using Prisma is that it auto-generates the TS models and makes it much easier to interact with the database in typescript.

As GraphQL and Prisma are both strict in type usages, they match quite well. Also, Prisma provides an exclusive interface for GraphQL implementation, so you can easily write GraphQL interface with Prisma.

Please check out here for more information on the combination of GraphQL and Prisma:

It was a long edit, but hope this helps.


As it was mentioned on previous post – yes, you can.

An example, if you backend application wrote on .NET stack – you may use, guess two, main libs that really tested and guys use it in real projects (google GraphQL.Net and second lib should be spelled almost the same)

But, both of these libs give you only processing of graphql queries and describe schemes (“accounts {id name}” means you should define resolver which returns data from db or another data source)

Most of guys use EF (EntityFramework) as a data-adapter between GraphQL and db. But, from my point of view it’s useless, especially, if we are talking about get data from db and that may be thousands requests.
We implemented component that based on light-weight DB lib (to almost all popular dbs like MSSQL, Postgresql, MySQL or Elasticsearch), gives ability to configure GraphQL scheme very easy and provide main features like sort, pagination and complex filter.

Answered By – Dmitriy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published