Ask coding questions

← Back to all posts
TypeGraphQL: how to access the parents fields values inside a FieldResolver
potatojs

i'm using apollo-server-express mongoose typeGraphQL and express of course
i have a book type and an author type:

i want to create a field resolver for the books author
book {
author
}
but to do that i would need the id of the book it self, so here is my code:

for some reason this doesn't work and the "book" argument is just a big object that looks like this:

the data i need is inside _doc, why i can't access it directly? isn't this the whole point of the @Root?
i can do something like this:

but c'mon, i prefer given up on typegraphql and using apollo instead, of having this in my code base

Voters
potatojs