Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nexus-prisma

Package Overview
Dependencies
Maintainers
4
Versions
225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus-prisma

[![trunk](https://github.com/prisma/nexus-prisma/actions/workflows/trunk.yml/badge.svg)](https://github.com/prisma/nexus-prisma/actions/workflows/trunk.yml)

  • 0.22.1-next.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-7.88%
Maintainers
4
Weekly downloads
 
Created
Source

nexus-prisma

trunk

Official Prisma plugin for Nexus.
Currently in development - not to be used in Production. Follow the progress from here.

Example


generator client {
  provider = "prisma-client-js"
}

generator nexusPrisma {
  // This is a temporary name, soon will be just "nexus-prisma" (pending a change in Prisma core).
  provider = "nexus-prisma-2"
}


/// This is a user!
model User {
  /// This is an id!
  id  String  @id
}
$ prisma generate
import { User } from 'nexus-prisma'
import { makeSchema, objectType } from 'nexus'

export const schema = makeSchema({
  types: [
    objectType({
      name: User.$name
      description: User.$description
      definition(t) {
        t.field(User.id.name, User.id)
      }
    })
  ]
})

Features

Note: ⛑ The following use abbreviated examples that skip a complete setup of passing Nexus type definition to Nexus makeSchema. If you are new to Nexus, Consider reading the official Nexus tutorial before jumping into Nexus Prisma.

Type-safe seamless generated library code

Following the same philosophy as Prisma Client, Nexus Prisma uses generation to create an API that feels tailor made for your project.

model User {
  id  String  @id
}
import { User } from 'nexus-prisma'
import { objectType } from 'nexus'

objectType({
  name: User.$name
  description: User.$description
  definition(t) {
    t.field(User.id.name, {
      type: User.id.type,
      description: User.id.description
    })
  }
})

Prisma ID field to GraphQL ID scalar type mapping

All @id fields in your Prisma Schema get projected as ID types, not String types.

model User {
  id  String  @id
}
import { User } from 'nexus-prisma'
import { objectType } from 'nexus'

objectType({
  name: User.$name
  description: User.$description
  definition(t) {
    t.field(User.id.name, User.id)
  }
})
type User {
  id: ID
}

Prisma Schema model & field documentation re-use

GraphQL documentation for your API clients
/// A user.
model User {
  /// A stable identifier to find users by.
  id  String  @id
}
import { User } from 'nexus-prisma'
import { objectType } from 'nexus'

User.$description // JSDoc: A user.
User.id.description // JSDoc: A stable identifier to find users by.

objectType({
  name: User.$name
  description: User.$description
  definition(t) {
    t.field(User.id.name, User.id)
  }
})
"""
A user.
"""
type User {
  """
  A stable identifier to find users by.
  """
  id: ID
}
Internal JSDoc for your team
/// A user.
model User {
  /// A stable identifier to find users by.
  id  String  @id
}
import { User } from 'nexus-prisma'

User // JSDoc: A user.
User.id // JSDoc: A stable identifier to find users by.

Refined DX

These are finer points that aren't perhaps worth a top-level point but none the less add up toward a thoughtful developer experience.

Default JSDoc Prompts

Fields and models that you do not document will result in a helpful default JSDoc that teaches you about this.

Runtime Proxy

When your project is in a state where the generated Nexus Prisma part is missing (new repo clone, reinstalled deps, etc.) Nexus Prisma gives you a default runtime export named PleaseRunPrismaGenerate and will error with a clear message.

Opt-outable friendly runtime peer dependency checks

When nexus-prisma is imported it will validate that your project has peer dependencies setup correctly.

If a peer dependenvy is not installed it nexus-prisma will log an error and then exit 1. If its version does not satify the range supported by the current version of nexus-prisma that you have installed, then a warning will be logged. If you want to opt-out of this validation then set an envar as follows:

NO_PEER_DEPENDENCY_CHECK=true|1
PEER_DEPENDENCY_CHECK=false|0

FAQs

Package last updated on 06 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc