Hello everyone, I want to implement type resolver ...
# orm-help
y
Hello everyone, I want to implement type resolver for "photo" filed for my "Student" model, searched some prisma docs and forum question but can't get anything to work me. I dont know how to get ID of ImageFile record to access it. What I am doing wrong where.
Copy code
type Student {
  id: ID! @id
  createdAt: DateTime! @createdAt
  name: String!
  email: String! @unique
  password: String!
  phone: String
  photo: ImageFile @relation(name: "PhotoToFile")
  coverPhoto: ImageFile @relation(name: "CoverPhotoToFile")
  bio: String
  dob: DateOfBirth
  gender: Gender! @default(value:OTHER)
  role: Role! @default(value:STUDENT)
  address: String
  classRoooms: [ClassRoom!]
  socialLinks:[SocialLink!]}
Copy code
type ImageFile {
   id: ID! @id
   assetId: String!
   publicId: String!
   url: String!
   secureUrl: String!
 }
and my type resolver:
Copy code
const Student = {
  async photo(parent, args, { prisma }, info) {
    return prisma.query.student({ where: { id: parent.id } }).photo();
  },
};

module.exports = Student;
Error:
c
In your resolver, the photo would be in reference to the photo field on the Student type which is an object
You’ll want to return either photo to get the full object or photo.url etc
y
How do I access ID of photo in my type resolver, I need ID to return the object
Copy code
photo: ImageFile @relation(name: "PhotoToFile")
this is a one way relationship
s
it should be
prisma.student({id: parent.id }).photo();
and not
prisma.query