Cannot return null for non-nullable field Mutation.createAds graphql error

Viewed 20

I'm getting Cannot return null for non-nullable field Mutation.createAds. Error in altair graphql any help I'm trying to upload multiples photos but I'm getting this error! Hi, I'm getting Cannot return null for non-nullable field Mutation.createAds. Error in altair graphql any help I'm trying to upload multiples photos but I'm getting this error

enter image description here

type ads {
    id:        String   
  user:        User
  titel:       String
  discription: String
  photo:       [photos]
  createdAt:   String
  updatedAt:   String
}
type photos{
  id:        String
  photo:     String
  Adses:     ads     
  createdAt: String
  updatedAt: String
}
   type Mutation{

createAds( titel:       String
                   discription: String
                   photo:       [Upload]):ads!
   }
}

Resolvers

createAds: async (_, {titel,
            discription,photo},{LogedInUser}) =>{
            userProtect(LogedInUser)

            
            const simo= await MultiplereadFiles(photo)
            console.log(simo)
            
            const create = Client.ads.create({data:{
  titel,
  discription,
  photos:simo,
  user:{
    connect:{
        id:LogedInUser.id
    }
  }

            }})
           
        
        },

Prisma schema

model ads {
  id          Int      @id
  user        User     @relation(fields: [userId], references: [id])
  titel       String?
  discription String
  photo       photos[]
  files       String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  userId      Int
}

model photos {
  id        Int      @id
  Adses     ads      @relation(fields: [adsId], references: [id])
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  adsId     Int
}

1 Answers

The schema indicates a required response. From the resolver snippet you shared, it seems there's no return to the function. Could it be the reason? Either that, or there's something broken in your Client.ads.create logic

Related