How to use the nexus-prisma.makePrismaSchema function in nexus-prisma

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 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 diego3g / graphql-nexus-example / src / server.ts View on Github external
import * as path from 'path';
import { GraphQLServer } from 'graphql-yoga';
import { makePrismaSchema } from 'nexus-prisma';
import { prisma } from './generated/prisma-client';
import datamodelInfo from './generated/nexus-prisma';
import * as types from './resolvers';

const schema = makePrismaSchema({
  types,

  prisma: {
    datamodelInfo,
    client: prisma,
  },

  outputs: {
    schema: path.join(__dirname, './generated/schema.graphql'),
    typegen: path.join(__dirname, './generated/nexus.ts'),
  },
});

const server = new GraphQLServer({
  schema,
  context: { prisma },
github tonyfromundefined / serverless-graphql-workshop / cheatsheet / server / src / app.ts View on Github external
import * as types from './resolvers'

const playground = !!Number(process.env.IS_PLAYGROUND_ENABLED || '0')
const tracing = !!Number(process.env.IS_TRACING_ENABLED || '0')

const app = express()

app.use(cors())

app.get('/', (_req, res) => {
  return res.json('ok')
})

const server = new ApolloServer({
  schema: makePrismaSchema({
    types,
    prisma: {
      client: prisma,
      datamodelInfo,
    },
    outputs: {
      schema: path.resolve('./src/generated', 'schema.graphql'),
      typegen: path.resolve('./src/generated', 'nexus.ts'),
    },
  }),
  introspection: playground,
  playground,
  tracing,
})

server.applyMiddleware({
github prisma-labs / nexus-prisma / examples / src / schema.ts View on Github external
import { makePrismaSchema } from 'nexus-prisma'
import * as path from 'path'
import datamodelInfo from './generated/nexus-prisma'
import { prisma } from './generated/prisma-client'
import * as allTypes from './resolvers'

/**
 * Finally, we construct our schema (whose starting query type is the query
 * type we defined above) and export it.
 */
export const schema = makePrismaSchema({
  types: allTypes,

  prisma: {
    datamodelInfo,
    client: prisma,
  },

  outputs: {
    schema: path.join(__dirname, './generated/schema.graphql'),
    typegen: path.join(__dirname, './generated/nexus.ts'),
  },

  nonNullDefaults: {
    input: true,
    output: true,
  },
github nice-boys / product-boilerplate / web / graphql / schema / index.ts View on Github external
ctx.viewerId ? ctx.prisma.user({ id: ctx.viewerId }) : null
    });
  }
});

const outputs = process.env.GENERATE
  ? {
      schema: path.join(__dirname, "../schema.generated.graphql"),
      typegen: path.join(__dirname, "../nexus-schema-types.generated.ts")
    }
  : {
      schema: false,
      typegen: false
    };

const schema = makePrismaSchema({
  types: [Query, User],
  prisma: {
    datamodelInfo,
    client: prisma
  },
  outputs,
  typegenAutoConfig: {
    sources: [
      {
        source: path.join(__dirname, "../../types/graphql.ts"),
        alias: "types"
      }
    ],
    contextType: "types.Context"
  }
});
github prisma-labs / yoga2 / packages / yoga / src / server.ts View on Github external
async server() {
        const app = express()
        const { types, context, expressMiddleware } = importArtifacts(
          config.resolversPath,
          config.contextPath,
          config.expressPath,
        )
        const makeSchemaOptions = makeSchemaDefaults(
          config,
          types,
          info.prismaClientDir,
        )
        const schema = config.prisma
          ? makePrismaSchema({
              ...makeSchemaOptions,
              prisma: config.prisma,
            })
          : makeSchema(makeSchemaOptions)
        const server = new ApolloServer({
          schema,
          context,
        })

        if (expressMiddleware) {
          await expressMiddleware(app)
        }

        server.applyMiddleware({ app, path: '/' })

        return app

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 7 months ago

Package Health Score

70 / 100
Full package analysis