How to use nexus-prisma - 10 common examples

To help you get started, we’ve selected a few nexus-prisma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma-labs / nexus-prisma / examples / src / resolvers / Query.ts View on Github external
import { stringArg } from 'nexus'
import { prismaObjectType } from 'nexus-prisma'

export const Query = prismaObjectType({
  name: 'Query',
  definition(t) {
    /**
     * - use `t.prismaFields(['*'])` to expose all the underlying object type fields
     * - use `t.primaFields(['fieldName', ...])` to pick and/or customize specific fields
     * - use `t.prismaFields({ filter: ['fieldName', ...] })` to filter and/or customize specific fields
     */

    // An empty array removes all fields from the underlying object type
    t.prismaFields([])

    t.list.field('feed', {
      type: 'Post',
      resolve: (parent, args, ctx) => {
        return ctx.prisma.posts({
          where: { published: true },
github nice-boys / product-boilerplate / web / graphql / schema / index.ts View on Github external
import { prisma } from "../../database/generated/client";
import datamodelInfo from "../../database/generated/nexus-prisma";
import { prismaObjectType, makePrismaSchema } from "nexus-prisma";
const path = require("path");

// @ts-ignore
const User = prismaObjectType({
  name: "User",
  definition(t) {
    t.prismaFields(["name", "id", "avatarUrl"]);
  }
});

const Query = prismaObjectType({
  name: "Query",
  definition(t) {
    t.prismaFields([
      {
        name: "user",
        args: ["where"]
      }
    ]);
    t.field("viewer", {
github guildspeak / guildspeak-backend / server / src / index.ts View on Github external
import { GraphQLServer } from 'graphql-yoga'
import { prisma } from './generated/prisma-client'
import resolvers from './resolvers'
import { PubSub } from 'graphql-subscriptions'
import { makePrismaSchema } from 'nexus-prisma'
import datamodelInfo from './generated/nexus-prisma'
import * as path from 'path'
import { IncomingMessage } from 'http'

const pubsub = new PubSub()

const schema = makePrismaSchema({
  // Provide all the GraphQL types we've implemented
  types: resolvers,

  // Configure the interface to Prisma
  prisma: {
    datamodelInfo,
    client: prisma
  },

  // Specify where Nexus should put the generated files
  outputs: {
    schema: path.join(__dirname, './generated/schema.graphql'),
    typegen: path.join(__dirname, './generated/nexus.ts')
  },

  // Configure nullability of input arguments: All arguments are non-nullable by default
github prisma / prisma-examples / typescript / graphql-crud / src / index.ts View on Github external
const Query = prismaObjectType({
  name: 'Query',
  definition(t) {
    t.prismaFields(['*'])
  },
})

const Mutation = prismaObjectType({
  name: 'Mutation',
  definition(t) {
    t.prismaFields(['*'])
  },
})

const schema = makePrismaSchema({
  // Provide all the GraphQL types we've implemented
  types: [Query, Mutation, User, Post],

  // Configure the interface to Prisma
  prisma: {
    datamodelInfo,
    client: prisma,
  },

  // Specify where Nexus should put the generated files
  outputs: {
    schema: path.join(__dirname, './generated/schema.graphql'),
    typegen: path.join(__dirname, './generated/nexus.ts'),
  },

  // Configure nullability of input arguments: All arguments are non-nullable by default
github Gomah / prisma-serverless / src / index.ts View on Github external
import { GraphQLSchema } from 'graphql';
import datamodelInfo from './generated/nexus-prisma';
import { permissions } from './permissions';
import * as allTypes from './resolvers';
import { Prisma, prisma } from './generated/prisma-client';
import { Ctx } from './types';

const prismaInstance = (): Prisma =>
  new Prisma({
    endpoint: process.env.PRISMA_ENDPOINT,
    debug: process.env.NODE_ENV !== 'production', // log all GraphQL queries & mutations sent to the Prisma API
    secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`)
  });

const schema: GraphQLSchema = applyMiddleware(
  makePrismaSchema({
    // Provide all the GraphQL types we've implemented
    types: allTypes,

    // Configure the interface to Prisma
    prisma: {
      datamodelInfo,
      client: prisma,
    },

    // Specify where Nexus should put the generated files
    outputs: {
      schema: path.resolve('./src/generated/schema.graphql'),
      typegen: path.resolve('./src/generated/nexus.ts'),
    },

    // Configure nullability of input arguments: All arguments are non-nullable by default
github fluidstackdev / fluidstack / packages / server / src / resolvers / Image.ts View on Github external
import { prismaObjectType } from 'nexus-prisma'

export const Image = prismaObjectType('Image')
github fluidstackdev / fluidstack / packages / server / src / resolvers / Option.ts View on Github external
import { prismaObjectType } from 'nexus-prisma'

export const Option = prismaObjectType('Option')

nexus-prisma

<p align="center"> <img src="https://i.imgur.com/8qvElTM.png" width="300" align="center" /> <h1 align="center"><a style="color:black;" href="https://graphql-nexus.github.io/nexus-prisma">nexus-prisma</a></h1> </p>

MIT
Latest version published 13 days ago

Package Health Score

87 / 100
Full package analysis