hi prisma people , could you help me with this cod...
# orm-help
d
hi prisma people , could you help me with this code? THANKS
j
The lack of formatting is making my eyes bleed a bit; however, your problem is that you aren’t returning a value from your resolver. You just have a value statement (that is likely optimized away). Use this instead.
Copy code
const schema = {
  schema: {
    typeDefs: /* GraphQL */ `
      type User {
        lname: String
        fname: String
     }
     type Mutation{
      addUser(lname: String, fname: String): User!
    }
    `,
    resolvers: {
      Mutation: {
        addUser: () => {
          return {
            fname: "salut",
            lname: "coucou",
          }
        }
      }
    },
  }
}
d
cool😅
it' s still don't work
Mutation: { addUser: async(parent: any,_: any) => { return await prisma.user.create( data:{ lname:"salut", fname:"salut" } )}
i don't know why 😂
j
That looks munged. Check your parentheses. Also, if you put your code samples between two sets of three backticks → ``` ←, it’ll be formatted to be easier to read.
d
v
Adding the original code posted in this thread, to keep the conversations stremalined:
Copy code
const schema = {schema: {
    typeDefs: /* GraphQL */ `
      type User {
        lname: String
        fname: String
     }
     type Mutation{
      addUser(lname: String, fname: String): User!
    }
    `,
    resolvers: {
           Mutation: {
         addUser: (__: any,_: any) => {
           {
            lname: "coucou"
            fname: "salut"
           }
         }
       }
    },
 }}
when i doing this
mutation{
  addUser{
    lname
    fname
  }
}
i' ve got that error
{
  "errors": [
    {
      "message": "Unexpected error.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "addUser"
      ],
      "extensions": {
        "originalError": {
          "message": "Cannot return null for non-nullable field Mutation.addUser.",
          "stack": "Error: Cannot return null for non-nullable field Mutation.addUser.\n    at completeValue (D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:594:13)\n    at executeField (D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:489:19)\n    at D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:377:22\n    at promiseReduce (D:\\prisma\\es-app\\node_modules\\graphql\\jsutils\\promiseReduce.js:23:9)\n    at executeFieldsSerially (D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:373:43)\n    at executeOperation (D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:347:14)\n    at execute (D:\\prisma\\es-app\\node_modules\\graphql\\execution\\execute.js:136:20)\n    at file:///D:/prisma/es-app/node_modules/@envelop/core/esm/orchestrator.js:377:33\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async processRequest (file:///D:/prisma/es-app/node_modules/@graphql-yoga/common/esm/processRequest.js:23:20)"
        }
      }
    }
  ],
  "data": null
}