Skip to content

MercurialWeb/nexus-plugin-prisma

 
 

Repository files navigation

@mercurialweb/nexus-plugin-prisma

*Latest version of Prisma supported: 6.5.0

Note: Since the Prisma team is no longer keeping this library up to date with new Prisma versions, we have forked it.

This plugin integrates Prisma into Nexus. It gives you an API you to project fields from models defined in your Prisma schema into your GraphQL API. It also gives you an API to build GraphQL root fields that allow your API clients to query and mutate data.

You can find the documentation on the Nexus website.

New Features

Automatic Filtering for Relations

By default, all relational fields now include a where parameter allowing you to filter related records, if the underlying Prisma model supports filtering. This makes it easy to query only specific related items without additional configuration.

For example, with a User model related to Posts:

// User type with related Posts
objectType({
  name: 'User',
  definition(t) {
    t.model.id()
    t.model.name()
    t.model.posts() // automatically includes where parameter for filtering
  },
})

This allows GraphQL queries like:

{
  user(id: 1) {
    posts(where: { title: { contains: "Nexus" } }) {
      id
      title
    }
  }
}

You can disable this behavior by explicitly setting filtering: false when defining the field:

t.model.posts({ filtering: false })

Note: If a relation doesn't have filtering capabilities in the generated Prisma client, the filtering parameter will be silently omitted rather than causing an error.

Installation

npm install @mercurialweb/nexus-plugin-prisma
# OR
yarn add @mercurialweb/nexus-plugin-prisma

About

A plugin for Nexus that integrates Prisma

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • TypeScript 97.9%
  • JavaScript 2.1%