Skip to main content


GraphQL is a query language for APIs. It is often used as an alternative to RESTful APIs, but can also be used as an additional "gateway" layer on top of existing RESTful services.

With Prisma ORM, you can build GraphQL servers that connect to a database. Prisma ORM is completely agnostic to the GraphQL tools you use. When building a GraphQL server, you can combine Prisma ORM with tools like Apollo Server, GraphQL Yoga, TypeGraphQL, GraphQL.js, or pretty much any tool or library that you're using in your GraphQL server setup.

GraphQL servers under the hood

A GraphQL server consists of two major components:

  • GraphQL schema (type definitions + resolvers)
  • HTTP server

Note that a GraphQL schema can be written code-first or SDL-first. Check out this article to learn more about these two approaches. If you like the SDL-first approach but still want to make your code type-safe, check out GraphQL Code Generator to generate various type definitions based on SDL.

The GraphQL schema and HTTP server are typically handled by separate libraries. Here is an overview of current GraphQL server tools and their purpose:

Library (npm package)PurposeCompatible with Prisma ORMPrisma integration
graphqlGraphQL schema (code-first)YesNo
graphql-toolsGraphQL schema (SDL-first)YesNo
type-graphqlGraphQL schema (code-first)Yestypegraphql-prisma
nexusGraphQL schema (code-first)Yesnexus-prisma Early Preview
apollo-serverHTTP serverYesn/a
express-graphqlHTTP serverYesn/a
fastify-gqlHTTP serverYesn/a
graphql-yogaHTTP serverYesn/a

In addition to these standalone and single-purpose libraries, there are several projects building integrated application frameworks:

FrameworkStackBuilt byPrisma ORMDescription
Redwood.jsFullstackTom Preston-WernerBuilt on top of Prisma ORMBringing full-stack to the JAMstack.

Note: If you notice any GraphQL libraries/frameworks missing from the list, please let us know.

Prisma ORM & GraphQL examples

In the following section will find several ready-to-run examples that showcase how to use Prisma ORM with different combinations of the tools mentioned in the table above.


ExampleHTTP ServerGraphQL schemaDescription
GraphQL API (Pothos)graphql-yogapothosGraphQL server based on graphql-yoga
GraphQL API (SDL-first)graphql-yogan/aGraphQL server based on the SDL-first approach
GraphQL API -- NestJs@nestjs/apollon/aGraphQL server based on NestJS
GraphQL API -- NestJs (SDL-first)@nestjs/apollon/aGraphQL server based on NestJS
GraphQL API (Nexus)@apollo/servernexusGraphQL server based on @apollo/server
GraphQL API (TypeGraphQL)apollo-servertype-graphqlGraphQL server based on the code-first approach of TypeGraphQL
GraphQL API (Auth)apollo-servernexusGraphQL server with email-password authentication & permissions
Fullstack appgraphql-yogapothosFullstack app with Next.js (React), Apollo Client, GraphQL Yoga and Pothos
GraphQL subscriptionsapollo-servernexusGraphQL server implementing realtime GraphQL subscriptions
GraphQL API -- Hapiapollo-server-hapinexusGraphQL server based on Hapi
GraphQL API -- Hapi (SDL-first)apollo-server-hapigraphql-toolsGraphQL server based on Hapi
GraphQL API -- Fastifyfastify & mercuriusn/aGraphQL server based on Fastify and Mercurius
GraphQL API -- Fastify (SDL-first)fastifyNexusGraphQL server based on Fastify and Mercurius

JavaScript (Node.js)

DemoHTTP ServerGraphQL schemaDescription
GraphQL API (Apollo Server)apollo-servernexusGraphQL server based on apollo-server
GraphQL API (Auth)apollo-servernexusGraphQL server with email-password authentication & permissions
GraphQL API (SDL-first)apollo-servergraphql-toolsGraphQL server based on the SDL-first approach of graphql-tools (Apollo)


What is Prisma ORM's role in a GraphQL server?

No matter which of the above GraphQL tools/libraries you use, Prisma ORM is used inside your GraphQL resolvers to connect to your database. It has the same role that any other ORM or SQL query builder would have inside your resolvers.

In the resolver of a GraphQL query, Prisma ORM typically reads data from the database to return it in the GraphQL response. In the resolver of a GraphQL mutation, Prisma ORM typically also writes data to the database (e.g. creating new or updating existing records).

Other GraphQL Resources

Prisma curates GraphQL Weekly, a newsletter highlighting resources and updates from the GraphQL community. Subscribe to keep up-to-date with GraphQL articles, videos, tutorials, libraries, and more.