Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 },
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", {
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
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
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
import { prismaObjectType } from 'nexus-prisma'
export const Image = prismaObjectType('Image')
import { prismaObjectType } from 'nexus-prisma'
export const Option = prismaObjectType('Option')