I had been reading everywhere about graphql and was stuck in a misunderstand implementation in the resolvers function:
This was my bad resolver, what I was getting was a undefined argument:
const jobResolvers = {
Query: {
job(id) {
//code where I call the db ODM function
}
}
}
After looking a few post I fix it: (understand the destructor part, but not why the underscore _ paremeter )
const jobResolvers = {
Query: {
job(_,{id}) {
//code where I call the db ODM function
}
}
}
Here you can see this two very good and explanatory post bad luck they don't explain, why are they two parameters in a resolver function(This is the big question)
the implementation of graphql server side getAuthor(_,{id}) the signature of the function have two parameters but only the second one is use and it will not work with only the id parameter
the other about GraphQL explained (How does a GraphQL server turn a query into a response?) author(root, args) the signature of the function have two parameters but only use the second one also the function will not work with only args parameter(root never work for me)