```prisma.ts declare global { var prisma: Pri...
# orm-help
d
Copy code
prisma.ts

declare global {
    var prisma: PrismaClient; // This must be a `var` and not a `let / const`
  }

import { PrismaClient } from '@prisma/client'
 let prisma: PrismaClient;
 if(process.env.NODE_ENV === 'production'){
    prisma = new PrismaClient();
}
 else{
    if(!global.prisma){
        global.prisma = new PrismaClient();
    }
    prisma = global.prisma
}  
 
export default prisma;  




graphl.ts

import { createServer , createPubSub } from '@graphql-yoga/node'
import { User } from '@prisma/client'
import type { NextApiRequest, NextApiResponse } from 'next'
import prisma from '../../lib/prisma'

const schema = {schema: {
    typeDefs: /* GraphQL */ `
    
      type User {
        lname: String
        fname: String
     }
   
    type Mutation{
      addUser(lname: String, fname: String): User!
    }
    `,
    resolvers: {
    
         Mutation: {
         addUser: async(parent: any,_: any) => {
           return await prisma.user.create(
            data:{
              lname:"coucou",
              fname:"salut"
            }
       )}  

    },
    
  }
}

i just want to add a new user in graphql with prisma but the resolver don't work                  <https://github.com/doddynicolas/try-prisma.git>
1
j
Do you have any github repo that I can run on my local machine?
Please create github repo
v
👋 Hi @doddy nicolas it looks like this is part of this convo, addressed by the amazing Jarupong here: https://prisma.slack.com/archives/CA491RJH0/p1664666467089019?thread_ts=1664625385.863219&amp;cid=CA491RJH0 In the future, it would be great if you could use Slack’s thread feature when providing more info on your issue or answering questions. This helps keep the main conversation channel a bit more clear 🙏