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 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 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)Yes
nexusGraphQL schema (code-first)Yes 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
FullstackBuilt 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.

TypeScript

ExampleHTTP ServerGraphQL schemaDescription
graphql-yogapothosGraphQL server based on
graphql-yogan/aGraphQL server based on the SDL-first approach
@nestjs/apollon/aGraphQL server based on
@nestjs/apollon/aGraphQL server based on
@apollo/servernexusGraphQL server based on
apollo-servertype-graphqlGraphQL server based on the code-first approach of
apollo-servernexusGraphQL server with email-password authentication & permissions
graphql-yogapothosFullstack app with Next.js (React), Apollo Client, GraphQL Yoga and Pothos
apollo-servernexusGraphQL server implementing realtime GraphQL subscriptions
apollo-server-hapinexusGraphQL server based on
apollo-server-hapigraphql-toolsGraphQL server based on
fastify & mercuriusn/aGraphQL server based on and
fastifyNexusGraphQL server based on and

JavaScript (Node.js)

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

FAQ

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 , a newsletter highlighting resources and updates from the GraphQL community. Subscribe to keep up-to-date with GraphQL articles, videos, tutorials, libraries, and more.